Infinite loop on removal of LOD structures was eliminated.
//! 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;
{
Handle(Graphic3d_Group) aGroup = myGroups.First();
aGroup->Remove();
+ myGroups.Remove (1);
}
}
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;
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 :
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);
//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);
}
//=============================================================================
//! 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;
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);
+ }
+ }
}
//================================================================
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 :
//! 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
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;
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;
}
}
- if (!aMesh.IsNull() && aSavePath != "")
+ if (aSavePath != "")
{
if (aSavePath.Value (aSavePath.Length()) != '/')
{