From 3d7e35768f0b1f559225103097b5175a58bb05a8 Mon Sep 17 00:00:00 2001 From: vpa Date: Thu, 31 Mar 2016 19:22:21 +0300 Subject: [PATCH] FitAll for objects represented via LODs is fixed --- src/Graphic3d/Graphic3d_LODManager.cxx | 48 +++++++++++++++++--------- src/Graphic3d/Graphic3d_LODManager.hxx | 3 ++ src/Graphic3d/Graphic3d_Structure.cxx | 8 +++++ src/MeshVS/MeshVS_LODBuilder.cxx | 8 ----- 4 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/Graphic3d/Graphic3d_LODManager.cxx b/src/Graphic3d/Graphic3d_LODManager.cxx index 7b38cd17bd..f7d8d5e0aa 100644 --- a/src/Graphic3d/Graphic3d_LODManager.cxx +++ b/src/Graphic3d/Graphic3d_LODManager.cxx @@ -79,23 +79,39 @@ void Graphic3d_LODManager::SetRange (const Standard_Integer theLodIdx, // function : GetCurrentGroups // purpose : //======================================================================= - const Graphic3d_SequenceOfGroup& Graphic3d_LODManager::GetCurrentGroups() const - { - return myLODs.Value (myCurrentLODIdx)->GetDrawGroups(); - } +const Graphic3d_SequenceOfGroup& Graphic3d_LODManager::GetCurrentGroups() const +{ + return myLODs.Value (myCurrentLODIdx)->GetDrawGroups(); +} - //======================================================================= +//======================================================================= // function : GetCombinedBndBox // purpose : //======================================================================= - void Graphic3d_LODManager::GetCombinedBndBox (Graphic3d_BndBox4f& theBndBox) const - { - for (Standard_Integer aLodIdx = 0; aLodIdx < myLODs.Size(); ++aLodIdx) - { - const Graphic3d_SequenceOfGroup& aGroups = myLODs.Value (aLodIdx)->GetDrawGroups(); - for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next()) - { - theBndBox.Combine (aGroupIter.Value()->BoundingBox()); - } - } - } +void Graphic3d_LODManager::GetCombinedBndBox (Graphic3d_BndBox4f& theBndBox) const +{ + for (Standard_Integer aLodIdx = 0; aLodIdx < myLODs.Size(); ++aLodIdx) + { + const Graphic3d_SequenceOfGroup& aGroups = myLODs.Value (aLodIdx)->GetDrawGroups(); + for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next()) + { + theBndBox.Combine (aGroupIter.Value()->BoundingBox()); + } + } +} + +//======================================================================= +// function : IsEmpty +// purpose : +//======================================================================= +Standard_Boolean Graphic3d_LODManager::IsEmpty() const +{ + for (Standard_Integer aLodIdx = 0; aLodIdx < myLODs.Size(); ++aLodIdx) + { + const Graphic3d_SequenceOfGroup& aGroups = myLODs.Value (aLodIdx)->GetDrawGroups(); + if (!aGroups.IsEmpty()) + return Standard_False; + } + + return Standard_True; +} diff --git a/src/Graphic3d/Graphic3d_LODManager.hxx b/src/Graphic3d/Graphic3d_LODManager.hxx index cabb925ddb..ab5299ce1d 100644 --- a/src/Graphic3d/Graphic3d_LODManager.hxx +++ b/src/Graphic3d/Graphic3d_LODManager.hxx @@ -55,6 +55,9 @@ public: Standard_EXPORT void GetCombinedBndBox (Graphic3d_BndBox4f& theBndBox) const; + //! Returns false if at least one of LODs has non-empty sequence of Graphic3d_Groups + Standard_EXPORT Standard_Boolean IsEmpty() const; + DEFINE_STANDARD_RTTIEXT (Graphic3d_LODManager, Standard_Transient) protected: diff --git a/src/Graphic3d/Graphic3d_Structure.cxx b/src/Graphic3d/Graphic3d_Structure.cxx index a3c95b838c..cba7c821fb 100644 --- a/src/Graphic3d/Graphic3d_Structure.cxx +++ b/src/Graphic3d/Graphic3d_Structure.cxx @@ -486,9 +486,16 @@ Standard_Boolean Graphic3d_Structure::IsEmpty() const } // structure is empty: + // - in case if it is represented by LODs, all LODs have no graphic groups // - if all these groups are empty // - or if all groups are empty and all their descendants are empty // - or if all its descendants are empty + // - or, in case if it is represented by LODs, all LODs have no graphic groups + if (!myCStructure->GetLodManager().IsNull()) + { + return myCStructure->GetLodManager()->IsEmpty(); + } + for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next()) { if (!aGroupIter.Value()->IsEmpty()) @@ -505,6 +512,7 @@ Standard_Boolean Graphic3d_Structure::IsEmpty() const return Standard_False; } } + return Standard_True; } diff --git a/src/MeshVS/MeshVS_LODBuilder.cxx b/src/MeshVS/MeshVS_LODBuilder.cxx index 2a885a08f2..ecdcd8ea70 100644 --- a/src/MeshVS/MeshVS_LODBuilder.cxx +++ b/src/MeshVS/MeshVS_LODBuilder.cxx @@ -417,8 +417,6 @@ void MeshVS_LODBuilder::drawArrays (const Handle(Prs3d_Presentation)& theBasePrs if (isPolygons && theFillAsp->FrontMaterial().Transparency() < 0.01) { Handle (Graphic3d_Group) aGroup = aNewLod->NewGroup (theBasePrs); - //Prs3d_Root::NewGroup ( theBasePrs ); - //Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup ( theBasePrs ); theFillAsp->SetEdgeOff(); @@ -449,8 +447,6 @@ void MeshVS_LODBuilder::drawArrays (const Handle(Prs3d_Presentation)& theBasePrs if (isPolylines && !theIsPolygonsEdgesOff) { Handle (Graphic3d_Group) aLGroup = aNewLod->NewGroup (theBasePrs); - //Prs3d_Root::NewGroup ( theBasePrs ); - //Handle (Graphic3d_Group) aLGroup = Prs3d_Root::CurrentGroup ( theBasePrs ); theFillAsp->SetEdgeOff(); if (theIsSelected) @@ -467,8 +463,6 @@ void MeshVS_LODBuilder::drawArrays (const Handle(Prs3d_Presentation)& theBasePrs if (isLinkPolylines) { Handle (Graphic3d_Group) aBeamGroup = aNewLod->NewGroup (theBasePrs); - //Prs3d_Root::NewGroup ( theBasePrs ); - //Handle (Graphic3d_Group) aBeamGroup = Prs3d_Root::CurrentGroup ( theBasePrs ); theFillAsp->SetEdgeOff(); if (!theIsSelected) @@ -481,8 +475,6 @@ void MeshVS_LODBuilder::drawArrays (const Handle(Prs3d_Presentation)& theBasePrs if (isPolygons && theFillAsp->FrontMaterial().Transparency() >= 0.01) { Handle (Graphic3d_Group) aGroup = aNewLod->NewGroup (theBasePrs); - //Prs3d_Root::NewGroup ( theBasePrs ); - //Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup ( theBasePrs ); theFillAsp->SetEdgeOff(); -- 2.39.5