]> OCCT Git - occt-copy.git/commitdiff
FitAll for objects represented via LODs is fixed
authorvpa <vpa@opencascade.com>
Thu, 31 Mar 2016 16:22:21 +0000 (19:22 +0300)
committervpa <vpa@opencascade.com>
Fri, 8 Apr 2016 17:20:01 +0000 (20:20 +0300)
src/Graphic3d/Graphic3d_LODManager.cxx
src/Graphic3d/Graphic3d_LODManager.hxx
src/Graphic3d/Graphic3d_Structure.cxx
src/MeshVS/MeshVS_LODBuilder.cxx

index 7b38cd17bd1422963e682c55682b42268e92b6e6..f7d8d5e0aa0dcb0d06340c25baa77ac2024d80c6 100644 (file)
@@ -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;
+}
index cabb925ddbbf1ad0c6b6e0a8f88bb7b44e39ff04..ab5299ce1d0a8cb33a47f651f5ddd98288647222 100644 (file)
@@ -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:
index a3c95b838c9b1d66d7965bb723458ff59a7beef1..cba7c821fb3c981d72ac5305c6daa54334bbdbe1 100644 (file)
@@ -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;
 }
 
index 2a885a08f2bc2ddc99b3079b27b5d7b668e77937..ecdcd8ea70ce4d020e56f995408c7536a4e98bf4 100644 (file)
@@ -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();