- Graphic3d_Structure's Remove and GraphicClear now take into account LOD structures;
- LOD graphic resources are cleaned up properly in OpenGl_Structure;
Correction of warnings.
TODO:
There are a lot of places in OpenGl_Structure where the structure tries to iterate through its own graphic groups.
In case of objects represented as LODs, such loops are useless and likely will affect the performance.
//=======================================================================
Graphic3d_LOD::~Graphic3d_LOD()
{
+ Clear (Standard_True);
myGroups.Clear();
}
myRange = Graphic3d_RangeOfLOD (theFrom, theTo);
}
+
+//=======================================================================
+// function : Clear
+// purpose :
+//=======================================================================
+void Graphic3d_LOD::Clear (const Standard_Boolean theWithDestruction)
+{
+ for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next())
+ {
+ aGroupIter.ChangeValue()->Clear();
+ }
+
+ if (!theWithDestruction)
+ {
+ return;
+ }
+
+ while (!myGroups.IsEmpty())
+ {
+ Handle(Graphic3d_Group) aGroup = myGroups.First();
+ aGroup->Remove();
+ }
+}
return myGroups;
}
+ Standard_EXPORT virtual void Clear (const Standard_Boolean theWithDestruction);
+
DEFINE_STANDARD_RTTIEXT (Graphic3d_LOD, Standard_Transient)
protected:
return Standard_True;
}
+
+//=======================================================================
+// function : Clear
+// purpose :
+//=======================================================================
+void Graphic3d_LODManager::Clear (const Standard_Boolean theWithDestruction)
+{
+ for (Standard_Integer aLodIdx = 0; aLodIdx < myLODs.Size(); ++aLodIdx)
+ {
+ myLODs.Value (aLodIdx)->Clear (theWithDestruction);
+ }
+}
+
+//=======================================================================
+// function : GetLodById
+// purpose :
+//=======================================================================
+const Handle(Graphic3d_LOD)& Graphic3d_LODManager::GetLodById (const Standard_Integer theLodIdx)
+{
+ Standard_ASSERT_RAISE (theLodIdx >= 0 || theLodIdx < myLODs.Size(),
+ "Index of LOD is out of range");
+
+ return myLODs.Value (theLodIdx);
+}
//! Returns false if at least one of LODs has non-empty sequence of Graphic3d_Groups
Standard_EXPORT Standard_Boolean IsEmpty() const;
+ Standard_EXPORT void Clear (const Standard_Boolean theWithDestruction);
+
+ Standard_EXPORT const Handle(Graphic3d_LOD)& GetLodById (const Standard_Integer theLodIdx);
+
DEFINE_STANDARD_RTTIEXT (Graphic3d_LODManager, Standard_Transient)
protected:
((Graphic3d_Structure *)myAncestors.FindKey (aStructIdx))->Remove (APtr, Graphic3d_TOC_DESCENDANT);
}
+ // Clear LODs graphic groups if there are any
+ if (!myCStructure->GetLodManager().IsNull())
+ {
+ myCStructure->GetLodManager()->Clear (Standard_False);
+ }
+
// Destruction of me in the graphic library
const Standard_Integer aStructId = myCStructure->Id;
myCStructure->GraphicDriver()->RemoveStructure (myCStructure);
return;
}
+ if (!myCStructure->GetLodManager().IsNull())
+ {
+ myCStructure->GetLodManager()->Clear (theWithDestruction);
+ if (theWithDestruction)
+ myCStructure->Clear();
+ }
+
// clean and empty each group
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
{
Graphic3d_BndBox4f Graphic3d_Structure::minMaxCoord() const
{
Graphic3d_BndBox4f aBnd;
- const Handle(Graphic3d_LODManager)& aLodMgr = myCStructure->GetLodManager();
- if (aLodMgr.IsNull())
+ if (myCStructure->GetLodManager().IsNull())
{
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
{
}
else
{
- aLodMgr->GetCombinedBndBox (aBnd);
+ myCStructure->GetLodManager()->GetCombinedBndBox (aBnd);
}
return aBnd;
}
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{
+ TColStd_PackedMapOfInteger aDummy;
for (Standard_Integer aLodBldrIdx = 1; aLodBldrIdx <= myBuilders.Length(); ++aLodBldrIdx)
{
const Handle(MeshVS_LODBuilder) aLodBldr = Handle(MeshVS_LODBuilder)::DownCast (myBuilders.Value (aLodBldrIdx));
if (aLodBldr.IsNull())
continue;
+ aLodBldr->SetPresentationManager (thePrsMgr);
const TColStd_PackedMapOfInteger aTrgIdxs = aLodBldr->GetDataSource()->GetAllElements();
if (!aTrgIdxs.IsEmpty())
- aLodBldr->Build (thePrs, aTrgIdxs, TColStd_PackedMapOfInteger(), Standard_True, theMode);
+ aLodBldr->Build (thePrs, aTrgIdxs, aDummy, Standard_True, theMode);
}
}
myGroups.Append (aGroup);
return aGroup;
}
+
+//=======================================================================
+// function : ReleaseGraphicResources
+// purpose :
+//=======================================================================
+void OpenGl_LOD::ReleaseGraphicResources (const Handle(OpenGl_Context)& theGlCtx)
+{
+ for (OpenGl_Structure::GroupIterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next())
+ {
+ aGroupIter.ChangeValue()->Release (theGlCtx);
+ }
+}
Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theParentStruct) Standard_OVERRIDE;
+ void ReleaseGraphicResources (const Handle(OpenGl_Context)& theGlCtx);
+
DEFINE_STANDARD_RTTIEXT (OpenGl_LOD, Graphic3d_LOD)
};
{
aGroupIter.ChangeValue()->Release (theGlCtx);
}
+ if (!myLODManager.IsNull())
+ {
+ for (Standard_Integer aLodIdx = 0; aLodIdx < myLODManager->NbOfDetailLevels(); ++aLodIdx)
+ {
+ Handle(OpenGl_LOD) aLod = Handle(OpenGl_LOD)::DownCast (myLODManager->GetLodById (aLodIdx));
+ aLod->ReleaseGraphicResources (theGlCtx);
+ }
+ }
if (myAspectLine != NULL)
{
myAspectLine->Release (theGlCtx.operator->());