From 3b8f64569ed333c5d861c82bebdcfbf5834d8e5f Mon Sep 17 00:00:00 2001 From: vpa Date: Mon, 23 Nov 2015 18:55:03 +0300 Subject: [PATCH] Remarks from KGV --- src/Graphic3d/Graphic3d_CStructure.hxx | 4 ++-- src/Graphic3d/Graphic3d_LOD.cxx | 19 +++++-------------- src/Graphic3d/Graphic3d_LOD.hxx | 9 ++++----- src/Graphic3d/Graphic3d_Structure.cxx | 8 ++++---- src/Graphic3d/Graphic3d_Structure.hxx | 2 +- src/MeshVS/MeshVS_LODDataSource.cxx | 12 ++++++------ src/OpenGl/OpenGl_LOD.cxx | 4 ++-- src/OpenGl/OpenGl_LOD.hxx | 9 ++++----- src/OpenGl/OpenGl_Structure.cxx | 7 +++---- src/OpenGl/OpenGl_Structure.hxx | 4 ++-- src/Prs3d/Prs3d_Root.cxx | 9 --------- src/Prs3d/Prs3d_Root.hxx | 2 -- src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx | 2 +- 13 files changed, 34 insertions(+), 57 deletions(-) diff --git a/src/Graphic3d/Graphic3d_CStructure.hxx b/src/Graphic3d/Graphic3d_CStructure.hxx index b9cadc5376..5a075b7f5d 100644 --- a/src/Graphic3d/Graphic3d_CStructure.hxx +++ b/src/Graphic3d/Graphic3d_CStructure.hxx @@ -114,12 +114,12 @@ public: virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct) = 0; //! Create new LOD within this structure - virtual Handle(Graphic3d_LOD) NewLOD (const Handle(Graphic3d_Structure)& theStruct) = 0; + virtual Handle(Graphic3d_LOD) NewLOD() = 0; //! Remove group from this structure virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup) = 0; - virtual Standard_Integer GetDetailLevelsNb() const = 0; + virtual Standard_Integer NbDetailLevels() const = 0; virtual void SetDetailLevelRange (const Standard_Integer theIdOfLOD, const Standard_Real theFrom, const Standard_Real theTo) = 0; diff --git a/src/Graphic3d/Graphic3d_LOD.cxx b/src/Graphic3d/Graphic3d_LOD.cxx index 1871d17c6c..060b093630 100644 --- a/src/Graphic3d/Graphic3d_LOD.cxx +++ b/src/Graphic3d/Graphic3d_LOD.cxx @@ -22,16 +22,6 @@ Graphic3d_LOD::~Graphic3d_LOD() { myGroups.Clear(); - myParent.Nullify(); -} - -//======================================================================= -// function : SetParent -// purpose : -//======================================================================= -void Graphic3d_LOD::SetParent (const Handle(Graphic3d_Structure)& theParent) -{ - myParent = theParent; } //======================================================================= @@ -47,7 +37,7 @@ void Graphic3d_LOD::SetRange (const Standard_Real /*theFrom*/, const Standard_Re // function : NewGroup // purpose : //======================================================================= -Handle(Graphic3d_Group) Graphic3d_LOD::NewGroup() +Handle(Graphic3d_Group) Graphic3d_LOD::NewGroup (const Handle(Graphic3d_Structure)& /*theParentStruct*/) { return NULL; } @@ -56,12 +46,13 @@ Handle(Graphic3d_Group) Graphic3d_LOD::NewGroup() // function : ComputeMetrics // purpose : //======================================================================= -Standard_Real Graphic3d_LOD::ComputeMetrics (const Handle(Graphic3d_Camera)& theCamera) const +Standard_Real Graphic3d_LOD::ComputeMetrics (const Handle(Graphic3d_Camera)& theCamera, + const Handle(Graphic3d_CStructure)& theParentStruct) const { - if (myParent.IsNull()) + if (theParentStruct.IsNull()) return std::numeric_limits::max(); - Graphic3d_BndBox4f aBndBox = myParent->CStructure()->BoundingBox(); + Graphic3d_BndBox4f aBndBox = theParentStruct->BoundingBox(); const Graphic3d_Vec4 aCenter = aBndBox.Center(); const gp_Pnt aGpCenter = gp_Pnt (aCenter.x(), aCenter.y(), aCenter.z()); return (theCamera->Eye().Distance (aGpCenter)) / theCamera->Scale(); diff --git a/src/Graphic3d/Graphic3d_LOD.hxx b/src/Graphic3d/Graphic3d_LOD.hxx index 3882cf3240..a3e41d184c 100644 --- a/src/Graphic3d/Graphic3d_LOD.hxx +++ b/src/Graphic3d/Graphic3d_LOD.hxx @@ -30,16 +30,15 @@ public: Standard_EXPORT virtual ~Graphic3d_LOD(); Standard_EXPORT virtual void SetRange (const Standard_Real theFrom, const Standard_Real theTo); - Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup(); + Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theParentStruct); - Standard_EXPORT Standard_Real ComputeMetrics (const Handle(Graphic3d_Camera)& theCamera) const; - Standard_EXPORT void SetParent (const Handle(Graphic3d_Structure)& theParent); + Standard_EXPORT Standard_Real ComputeMetrics (const Handle(Graphic3d_Camera)& theCamera, + const Handle(Graphic3d_CStructure)& theParentStruct) const; DEFINE_STANDARD_RTTI (Graphic3d_LOD, Standard_Transient) protected: - Graphic3d_SequenceOfGroup myGroups; - Handle(Graphic3d_Structure) myParent; + Graphic3d_SequenceOfGroup myGroups; }; DEFINE_STANDARD_HANDLE (Graphic3d_LOD, Standard_Transient) diff --git a/src/Graphic3d/Graphic3d_Structure.cxx b/src/Graphic3d/Graphic3d_Structure.cxx index 05e481a6cc..cc6a629e1a 100644 --- a/src/Graphic3d/Graphic3d_Structure.cxx +++ b/src/Graphic3d/Graphic3d_Structure.cxx @@ -1749,16 +1749,16 @@ Handle(Graphic3d_Group) Graphic3d_Structure::NewGroup() //============================================================================= Handle(Graphic3d_LOD) Graphic3d_Structure::NewLOD() { - return myCStructure->NewLOD (this); + return myCStructure->NewLOD(); } //============================================================================= -//function : GetDetailLevelsNb +//function : NbDetailLevels //purpose : //============================================================================= -Standard_Integer Graphic3d_Structure::GetDetailLevelsNb() const +Standard_Integer Graphic3d_Structure::NbDetailLevels() const { - return myCStructure->GetDetailLevelsNb(); + return myCStructure->NbDetailLevels(); } //============================================================================= diff --git a/src/Graphic3d/Graphic3d_Structure.hxx b/src/Graphic3d/Graphic3d_Structure.hxx index 088126f4f2..94a1fe03a5 100644 --- a/src/Graphic3d/Graphic3d_Structure.hxx +++ b/src/Graphic3d/Graphic3d_Structure.hxx @@ -497,7 +497,7 @@ public: //! Returns the low-level structure const Handle(Graphic3d_CStructure)& CStructure() const; - Standard_EXPORT Standard_Integer GetDetailLevelsNb() const; + Standard_EXPORT Standard_Integer NbDetailLevels() const; Standard_EXPORT void SetDetailLevelRange (const Standard_Integer theIdOfLOD, const Standard_Real theFrom, const Standard_Real theTo); diff --git a/src/MeshVS/MeshVS_LODDataSource.cxx b/src/MeshVS/MeshVS_LODDataSource.cxx index 36bb712124..932a3f8a40 100644 --- a/src/MeshVS/MeshVS_LODDataSource.cxx +++ b/src/MeshVS/MeshVS_LODDataSource.cxx @@ -186,7 +186,7 @@ void MeshVS_LODDataSource::ComputePrs (const Handle(AIS_InteractiveObject) theMe if (aMesh.IsNull()) return; - Standard_Boolean hasNodes = !myNodeIdxs.IsEmpty(); + // Standard_Boolean hasNodes = !myNodeIdxs.IsEmpty(); Standard_Boolean hasTrgs = !myTriangleIdxs.IsEmpty(); Handle(Prs3d_Presentation) aMainPrs = theMesh->Presentation(); const Standard_Integer aDispMode = theMesh->DisplayMode(); @@ -591,12 +591,12 @@ void MeshVS_LODDataSource::drawArrays (const Handle(Prs3d_Presentation)& theBase Aspect_TypeOfLine aType; Standard_Real aWidth; - Handle(Graphic3d_LOD) aNewLod = Prs3d_Root::NewLOD (theBasePrs); + Handle(Graphic3d_LOD) aNewLod = theBasePrs->NewLOD(); theFillAsp->Values (aStyle, anIntColor, aBackColor, anEdgeColor, aType, aWidth); if (isPolygons && theFillAsp->FrontMaterial().Transparency() < 0.01) { - Handle (Graphic3d_Group) aGroup = aNewLod->NewGroup(); + Handle (Graphic3d_Group) aGroup = aNewLod->NewGroup (theBasePrs); theFillAsp->SetEdgeOff(); @@ -626,7 +626,7 @@ void MeshVS_LODDataSource::drawArrays (const Handle(Prs3d_Presentation)& theBase if (isPolylines && !theIsPolygonsEdgesOff) { - Handle (Graphic3d_Group) aLGroup = aNewLod->NewGroup(); + Handle (Graphic3d_Group) aLGroup = aNewLod->NewGroup (theBasePrs); theFillAsp->SetEdgeOff(); if (theIsSelected) @@ -642,7 +642,7 @@ void MeshVS_LODDataSource::drawArrays (const Handle(Prs3d_Presentation)& theBase if (isLinkPolylines) { - Handle (Graphic3d_Group) aBeamGroup = aNewLod->NewGroup(); + Handle (Graphic3d_Group) aBeamGroup = aNewLod->NewGroup (theBasePrs); theFillAsp->SetEdgeOff(); if (!theIsSelected) @@ -654,7 +654,7 @@ void MeshVS_LODDataSource::drawArrays (const Handle(Prs3d_Presentation)& theBase if (isPolygons && theFillAsp->FrontMaterial().Transparency() >= 0.01) { - Handle (Graphic3d_Group) aGroup = aNewLod->NewGroup(); + Handle (Graphic3d_Group) aGroup = aNewLod->NewGroup (theBasePrs); theFillAsp->SetEdgeOff(); diff --git a/src/OpenGl/OpenGl_LOD.cxx b/src/OpenGl/OpenGl_LOD.cxx index 5016d3086a..6fcbf98d6e 100644 --- a/src/OpenGl/OpenGl_LOD.cxx +++ b/src/OpenGl/OpenGl_LOD.cxx @@ -39,9 +39,9 @@ void OpenGl_LOD::SetRange (const Standard_Real theFrom, const Standard_Real theT // function : NewGroup // purpose : //======================================================================= -Handle(Graphic3d_Group) OpenGl_LOD::NewGroup() +Handle(Graphic3d_Group) OpenGl_LOD::NewGroup (const Handle(Graphic3d_Structure)& theParentStruct) { - Handle(OpenGl_Group) aGroup = new OpenGl_Group (myParent); + Handle(OpenGl_Group) aGroup = new OpenGl_Group (theParentStruct); myGroups.Append (aGroup); return aGroup; } diff --git a/src/OpenGl/OpenGl_LOD.hxx b/src/OpenGl/OpenGl_LOD.hxx index cf410e8b1c..925d0b9a98 100644 --- a/src/OpenGl/OpenGl_LOD.hxx +++ b/src/OpenGl/OpenGl_LOD.hxx @@ -25,12 +25,11 @@ struct OpenGl_RangeOfLOD { public: OpenGl_RangeOfLOD (const Standard_Real theFrom, const Standard_Real theTo) + : myTo (theTo), + myFrom (theFrom) { Standard_ASSERT_RAISE (theFrom < theTo, "The upper boundary of the interval must be greater than lower one!"); - - myTo = theTo; - myFrom = theFrom; } Standard_Boolean IsIn (const Standard_Real theVal) const @@ -72,7 +71,7 @@ public: return myRange; } - Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup() Standard_OVERRIDE; + Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theParentStruct) Standard_OVERRIDE; const Graphic3d_SequenceOfGroup& DrawGroups() const { @@ -82,7 +81,7 @@ public: DEFINE_STANDARD_RTTI (OpenGl_LOD, Graphic3d_LOD) private: - OpenGl_RangeOfLOD myRange; + OpenGl_RangeOfLOD myRange; }; DEFINE_STANDARD_HANDLE (OpenGl_LOD, Graphic3d_LOD) diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index 686009e75a..9430ec32e6 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -437,10 +437,9 @@ Handle(Graphic3d_Group) OpenGl_Structure::NewGroup (const Handle(Graphic3d_Struc // function : NewLOD // purpose : // ======================================================================= -Handle(Graphic3d_LOD) OpenGl_Structure::NewLOD (const Handle(Graphic3d_Structure)& theStruct) +Handle(Graphic3d_LOD) OpenGl_Structure::NewLOD() { Handle(OpenGl_LOD) aLOD = new OpenGl_LOD(); - aLOD->SetParent (theStruct); myLODVec.Append (aLOD); return aLOD; } @@ -539,7 +538,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con return; } - Handle(OpenGl_LOD) aLODToRender = NULL; + Handle(OpenGl_LOD) aLODToRender; if (myLODVec.Size() > 0) { findCurrentLOD (theWorkspace); @@ -818,7 +817,7 @@ Standard_Integer OpenGl_Structure::binSearchLOD (const Standard_Integer theFirst //======================================================================= void OpenGl_Structure::findCurrentLOD (const Handle(OpenGl_Workspace)& theWorkspace) const { - Standard_Real aMetric = myLODVec.Value (0)->ComputeMetrics (theWorkspace->View()->Camera()); + Standard_Real aMetric = myLODVec.Value (0)->ComputeMetrics (theWorkspace->View()->Camera(), this); std::cout << aMetric << std::endl; if (myCurrentLodId != -1 && myLODVec.Value (myCurrentLodId)->GetRange().IsIn (aMetric)) return; diff --git a/src/OpenGl/OpenGl_Structure.hxx b/src/OpenGl/OpenGl_Structure.hxx index 78dedba7df..1485ec60f6 100644 --- a/src/OpenGl/OpenGl_Structure.hxx +++ b/src/OpenGl/OpenGl_Structure.hxx @@ -101,7 +101,7 @@ public: Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct); //! Create new LOD within this structure - Standard_EXPORT virtual Handle(Graphic3d_LOD) NewLOD (const Handle(Graphic3d_Structure)& theStruct) Standard_OVERRIDE; + Standard_EXPORT virtual Handle(Graphic3d_LOD) NewLOD() Standard_OVERRIDE; //! Remove group from this structure Standard_EXPORT virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup); @@ -201,7 +201,7 @@ public: //! Is the structure ray-tracable (contains ray-tracable elements)? Standard_Boolean IsRaytracable() const; - Standard_EXPORT virtual Standard_Integer GetDetailLevelsNb() const Standard_OVERRIDE + Standard_EXPORT virtual Standard_Integer NbDetailLevels() const Standard_OVERRIDE { return (Standard_Integer)myLODVec.Size(); } diff --git a/src/Prs3d/Prs3d_Root.cxx b/src/Prs3d/Prs3d_Root.cxx index a9530394b4..516705011b 100644 --- a/src/Prs3d/Prs3d_Root.cxx +++ b/src/Prs3d/Prs3d_Root.cxx @@ -25,12 +25,3 @@ Handle (Graphic3d_Group) Prs3d_Root::NewGroup (const Handle (Prs3d_Presentation) { return Prs3d->NewGroup(); } - -//======================================================================= -//function : CreateLOD -//purpose : -//======================================================================= -Handle(Graphic3d_LOD) Prs3d_Root::NewLOD (const Handle (Prs3d_Presentation)& theParentPrs) -{ - return theParentPrs->NewLOD(); -} diff --git a/src/Prs3d/Prs3d_Root.hxx b/src/Prs3d/Prs3d_Root.hxx index ed35e2c548..c7c5d05c2e 100644 --- a/src/Prs3d/Prs3d_Root.hxx +++ b/src/Prs3d/Prs3d_Root.hxx @@ -45,8 +45,6 @@ public: //! objects in the display. //! A group also contains the attributes whose ranges are limited to the primitives in it. Standard_EXPORT static Handle(Graphic3d_Group) NewGroup (const Handle(Prs3d_Presentation)& Prs3d); - - Standard_EXPORT static Handle(Graphic3d_LOD) NewLOD (const Handle (Prs3d_Presentation)& theParentPrs); }; diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx index 25aabbc931..1123970390 100644 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx +++ b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx @@ -1488,7 +1488,7 @@ static int MeshLod (Draw_Interpretor& theDI, Handle(MeshVS_LODDataSource) aLod = new MeshVS_LODDataSource (aSTLMesh); aLod->ComputePrs (aMesh); - Standard_Integer aIdOfLod = aMesh->Presentation()->GetDetailLevelsNb(); + Standard_Integer aIdOfLod = aMesh->Presentation()->NbDetailLevels(); aMesh->Presentation()->SetDetailLevelRange (aIdOfLod - 1, aFromRange, aToRange); return 0; -- 2.39.5