]> OCCT Git - occt-copy.git/commitdiff
Full support of different display modes was added;
authorvpa <vpa@opencascade.com>
Fri, 8 Apr 2016 15:38:15 +0000 (18:38 +0300)
committervpa <vpa@opencascade.com>
Fri, 8 Apr 2016 17:20:07 +0000 (20:20 +0300)
Infinite loop on removal of LOD structures was eliminated.

src/Graphic3d/Graphic3d_CStructure.hxx
src/Graphic3d/Graphic3d_LOD.cxx
src/Graphic3d/Graphic3d_LOD.hxx
src/Graphic3d/Graphic3d_LODManager.cxx
src/Graphic3d/Graphic3d_LODManager.hxx
src/Graphic3d/Graphic3d_Structure.cxx
src/Graphic3d/Graphic3d_Structure.hxx
src/MeshVS/MeshVS_Mesh.cxx
src/OpenGl/OpenGl_Structure.cxx
src/OpenGl/OpenGl_Structure.hxx
src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx

index 4cfaed2f6705025ea7d323e4f30808ac9fdb6846..d7a9470c9294066e6701e0de8b196dd99ed73406 100644 (file)
@@ -137,6 +137,12 @@ public:
   //! iteration number
   virtual void SetDetailLevelRange (const Standard_Integer theLODIdx, const Standard_Real theFrom, const Standard_Real theTo) = 0;
 
+  //! Returns range of LOD.
+  //! @param theLODIdx corresponds to the index of LOD in map of LOD manager. In case if no LOD was
+  //! removed, the LODs in map are located in order of addition and IDs are identical to the addition
+  //! iteration number
+  virtual void GetDetailLevelRange (const Standard_Integer theLODIdx, Standard_Real& theFrom, Standard_Real& theTo) const = 0;
+
 public:
 
   int                      Id;
index a78f9975b962e746d8ed40608c5ac4416dcb8e69..7386f3eaf63d5aacde9d0e7b76c1c11ef0a96203 100644 (file)
@@ -59,5 +59,6 @@ void Graphic3d_LOD::Clear (const Standard_Boolean theWithDestruction)
   {
     Handle(Graphic3d_Group) aGroup = myGroups.First();
     aGroup->Remove();
+    myGroups.Remove (1);
   }
 }
index 4e6fd00b92d8111585f01b53b2d7c17230bbce99..50c5a759507dea4089dfcabf2f1faa28ce5ede25 100644 (file)
@@ -62,6 +62,16 @@ public:
     return myFrom < theOther.myFrom;
   }
 
+  const Standard_Real To() const
+  {
+    return myTo;
+  }
+
+  const Standard_Real From() const
+  {
+    return myFrom;
+  }
+
 private:
   Standard_Real myFrom;
   Standard_Real myTo;
index c8e696ad67880115033e0faeaf7a2b04be742382..1c1c52e62c609ea1b60180803ce4f2cc8540cc52 100644 (file)
@@ -97,6 +97,22 @@ void Graphic3d_LODManager::SetRange (Standard_Integer theLODIdx,
   myIsToSortLODs = Standard_True;
 }
 
+//=======================================================================
+// function : GetRange
+// purpose  :
+//=======================================================================
+void Graphic3d_LODManager::GetRange (const Standard_Integer theLODIdx,
+                                     Standard_Real& theFrom,
+                                     Standard_Real& theTo) const
+{
+  if (theLODIdx < 1 || theLODIdx > myLODs.Extent())
+    return;
+
+  Graphic3d_RangeOfLOD aRange = myLODs.FindKey (theLODIdx)->GetRange();
+  theFrom = aRange.From();
+  theTo = aRange.To();
+}
+
 //=======================================================================
 // function : GetCurrentGroups
 // purpose  :
index 2d1e6206c18b6dcfbed2ace560cea55e56e591a6..88f7fff816d5f72287701a2ef59edded19b0f7ad 100644 (file)
@@ -67,6 +67,12 @@ public:
                                  const Standard_Real theFrom,
                                  const Standard_Real theTo);
 
+  //! For ranged LODs, returns the distance interval where the LOD will be visible.
+  //! @param theLODIdx the index of LOD in sorted list
+  Standard_EXPORT void GetRange (const Standard_Integer theLODIdx,
+                                 Standard_Real& theFrom,
+                                 Standard_Real& theTo) const;
+
   //! Returns own index of the LOD that is displayed
   Standard_EXPORT Standard_Boolean HasLODToDisplay (const Handle(Graphic3d_Camera)& theCamera);
 
index 848a33ca1c01170060d4cf5e97880e8ef1a41389..3e13945c0023b9768558d6c4af48827b34081f5c 100644 (file)
@@ -1751,9 +1751,18 @@ Standard_Integer Graphic3d_Structure::NbDetailLevels() const
 //function : SetDetailLevelRange
 //purpose  :
 //=============================================================================
-void Graphic3d_Structure::SetDetailLevelRange (const Standard_Integer theIdOfLOD, const Standard_Real theFrom, const Standard_Real theTo)
+void Graphic3d_Structure::SetDetailLevelRange (const Standard_Integer theLODIdx, const Standard_Real theFrom, const Standard_Real theTo)
 {
-  myCStructure->SetDetailLevelRange (theIdOfLOD, theFrom, theTo);
+  myCStructure->SetDetailLevelRange (theLODIdx, theFrom, theTo);
+}
+
+//=============================================================================
+//function : GetDetailLevelRange
+//purpose  :
+//=============================================================================
+void Graphic3d_Structure::GetDetailLevelRange (const Standard_Integer theLODIdx, Standard_Real& theFrom, Standard_Real& theTo) const
+{
+  myCStructure->GetDetailLevelRange (theLODIdx, theFrom, theTo);
 }
 
 //=============================================================================
index 932d547d54cec974bf7cf005edff15cb29d777ce..0523c98b61eac5e3cd3a62e3162cc124dc80081c 100644 (file)
@@ -493,6 +493,12 @@ public:
   //! iteration number
   Standard_EXPORT void SetDetailLevelRange (const Standard_Integer theLODIdx, const Standard_Real theFrom, const Standard_Real theTo);
 
+  //! Returns range of LOD.
+  //! @param theLODIdx corresponds to the index of LOD in map of LOD manager. In case if no LOD was
+  //! removed, the LODs in map are located in order of addition and IDs are identical to the addition
+  //! iteration number
+  Standard_EXPORT void GetDetailLevelRange (const Standard_Integer theLODIdx, Standard_Real& theFrom, Standard_Real& theTo) const;
+
 friend class Graphic3d_Group;
 
 
index bc7f048e8c776e49adbb3971f8f1ab93ab0e48f2..0678b601c3206f084fa56ad5b7ce94e588a17be5 100644 (file)
@@ -163,10 +163,24 @@ void MeshVS_Mesh::ComputeLODs (const Handle(PrsMgr_PresentationManager3d)& thePr
       continue;
 
     aLODBldr->SetPresentationManager (thePrsMgr);
+    SetDataSource (aLODBldr->GetDataSource());
     const TColStd_PackedMapOfInteger aTrgIdxs = aLODBldr->GetDataSource()->GetAllElements();
     if (!aTrgIdxs.IsEmpty())
       aLODBldr->Build (thePrs, aTrgIdxs, aDummy, Standard_True,  theMode);
   }
+
+  // Set up default ranges for LODs in shading or other display modes
+  if (theMode > 1)
+  {
+    const Handle(Prs3d_Presentation)& aWireframePrs = thePrsMgr->Presentation (this, 1)->Presentation();
+    for (Standard_Integer aLODIdx = 1; aLODIdx <= myBuilders.Length(); ++aLODIdx)
+    {
+      // Get range for wireframe mode
+      Standard_Real aFrom, aTo = std::numeric_limits<Standard_Real>::max();
+      aWireframePrs->GetDetailLevelRange (aLODIdx, aFrom, aTo);
+      thePrs->SetDetailLevelRange (aLODIdx, aFrom, aTo);
+    }
+  }
 }
 
 //================================================================
index fda97d06c95bb14e2caa1cf36b9c641f398532dc..e2580301de7dd1178978075950d7f28b6d4553ef 100644 (file)
@@ -809,6 +809,20 @@ void OpenGl_Structure::SetDetailLevelRange (const Standard_Integer theLODIdx,
   myLODManager->SetRange (theLODIdx, theFrom, theTo);
 }
 
+//=======================================================================
+//function : GetDetailLevelRange
+//purpose  :
+//=======================================================================
+void OpenGl_Structure::GetDetailLevelRange (const Standard_Integer theLODIdx,
+                                            Standard_Real& theFrom,
+                                            Standard_Real& theTo) const
+{
+  if (myLODManager.IsNull() || theLODIdx < 1 || theLODIdx > myLODManager->NbOfDetailLevels())
+    return;
+
+  myLODManager->GetRange (theLODIdx, theFrom, theTo);
+}
+
 //=======================================================================
 //function : DrawGroups
 //purpose  :
index aee75dcd596b07306be55d8e4fe5548e7c583607..4b13e01351e7ca65f1ab8380377fa4d84b69bd46 100644 (file)
@@ -106,10 +106,22 @@ public:
   //! Remove group from this structure
   Standard_EXPORT virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup) Standard_OVERRIDE;
 
+  //! Sets range of LOD.
+  //! @param theLODIdx corresponds to the index of LOD in map of LOD manager. In case if no LOD was
+  //! removed, the LODs in map are located in order of addition and IDs are identical to the addition
+  //! iteration number
   Standard_EXPORT virtual void SetDetailLevelRange (const Standard_Integer theLODIdx,
                                                     const Standard_Real theFrom,
                                                     const Standard_Real theTo) Standard_OVERRIDE;
 
+  //! Returns range of LOD.
+  //! @param theLODIdx corresponds to the index of LOD in map of LOD manager. In case if no LOD was
+  //! removed, the LODs in map are located in order of addition and IDs are identical to the addition
+  //! iteration number
+  Standard_EXPORT virtual void GetDetailLevelRange (const Standard_Integer theLODIdx,
+                                                    Standard_Real& theFrom,
+                                                    Standard_Real& theTo) const Standard_OVERRIDE;
+
 public:
 
   //! @return graphic groups
index 2865f3bf4b9761d09bb36d2147c2af83e16ff886..6ff0a9846375b783e960f0239382cef8ceeb4581 100644 (file)
@@ -1292,7 +1292,7 @@ static int MeshGenLODs (Draw_Interpretor& theDI,
   aMeshParams.Deflection = aMaxDefl;
   aMeshParams.Angle = 0.5;
   aMeshParams.Relative =  Standard_False;
-  aMeshParams.InParallel = Standard_False;
+  aMeshParams.InParallel = Standard_True;
   aMeshParams.MinSize = Precision::Confusion();
   aMeshParams.InternalVerticesMode = Standard_True;
   aMeshParams.ControlSurfaceDeflection = Standard_True;
@@ -1318,7 +1318,7 @@ static int MeshGenLODs (Draw_Interpretor& theDI,
     aParams.Deflection = aMaxDefl - aLODIdx * aDeflDecrFactor;
     aParams.Angle = 0.5;
     aParams.Relative =  Standard_False;
-    aParams.InParallel = Standard_False;
+    aParams.InParallel = Standard_True;
     aParams.MinSize = Precision::Confusion();
     aParams.InternalVerticesMode = Standard_True;
     aParams.ControlSurfaceDeflection = Standard_True;
@@ -1393,7 +1393,7 @@ static int MeshGenLODs (Draw_Interpretor& theDI,
     }
   }
 
-  if (!aMesh.IsNull() && aSavePath != "")
+  if (aSavePath != "")
   {
     if (aSavePath.Value (aSavePath.Length()) != '/')
     {