mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0026029: Visualization - Poor performance of connected objects
Fix performance issue with SelectMgr_SelectableObjectSet.
This commit is contained in:
@@ -1312,6 +1312,90 @@ void Graphic3d_Structure::Descendants (Graphic3d_MapOfStructure& theSet) const
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : AppendDescendant
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Graphic3d_Structure::AppendDescendant (const Standard_Address theDescendant)
|
||||
{
|
||||
if (myDescendantMap.IsBound (theDescendant))
|
||||
{
|
||||
return Standard_False; // already connected
|
||||
}
|
||||
|
||||
myDescendantMap.Bind (theDescendant, myDescendants.Length() + 1);
|
||||
myDescendants.Append (theDescendant);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : RemoveDescendant
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Graphic3d_Structure::RemoveDescendant (const Standard_Address theDescendant)
|
||||
{
|
||||
Standard_Integer aStructIdx;
|
||||
if (!myDescendantMap.Find (theDescendant, aStructIdx))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myDescendantMap.UnBind (theDescendant);
|
||||
|
||||
if (aStructIdx != myDescendants.Length())
|
||||
{
|
||||
myDescendants.Exchange (aStructIdx, myDescendants.Length());
|
||||
myDescendantMap.Bind (myDescendants (aStructIdx), aStructIdx);
|
||||
}
|
||||
|
||||
myDescendants.Remove (myDescendants.Length());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : AppendAncestor
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Graphic3d_Structure::AppendAncestor (const Standard_Address theAncestor)
|
||||
{
|
||||
if (myAncestorMap.IsBound (theAncestor))
|
||||
{
|
||||
return Standard_False; // already connected
|
||||
}
|
||||
|
||||
myAncestorMap.Bind (theAncestor, myAncestors.Length() + 1);
|
||||
myAncestors.Append (theAncestor);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : RemoveAncestor
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Graphic3d_Structure::RemoveAncestor (const Standard_Address theAncestor)
|
||||
{
|
||||
Standard_Integer aStructIdx;
|
||||
if (!myAncestorMap.Find (theAncestor, aStructIdx))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myAncestorMap.UnBind (theAncestor);
|
||||
|
||||
if (aStructIdx != myAncestors.Length())
|
||||
{
|
||||
myAncestors.Exchange (aStructIdx, myAncestors.Length());
|
||||
myAncestorMap.Bind (myAncestors (aStructIdx), aStructIdx);
|
||||
}
|
||||
|
||||
myAncestors.Remove (myAncestors.Length());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Connect
|
||||
//purpose :
|
||||
@@ -1320,7 +1404,10 @@ void Graphic3d_Structure::Connect (const Handle(Graphic3d_Structure)& theStructu
|
||||
const Graphic3d_TypeOfConnection theType,
|
||||
const Standard_Boolean theWithCheck)
|
||||
{
|
||||
if (IsDeleted()) return;
|
||||
if (IsDeleted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// cycle detection
|
||||
if (theWithCheck
|
||||
@@ -1329,47 +1416,34 @@ void Graphic3d_Structure::Connect (const Handle(Graphic3d_Structure)& theStructu
|
||||
return;
|
||||
}
|
||||
|
||||
switch (theType)
|
||||
const Standard_Address aStructure = theStructure.operator->();
|
||||
|
||||
if (theType == Graphic3d_TOC_DESCENDANT)
|
||||
{
|
||||
case Graphic3d_TOC_DESCENDANT:
|
||||
if (!AppendDescendant (aStructure))
|
||||
{
|
||||
const Standard_Integer aNbDesc = myDescendants.Length();
|
||||
for (Standard_Integer anIter = 1; anIter <= aNbDesc; ++anIter)
|
||||
{
|
||||
if (myDescendants.Value (anIter) == theStructure.operator->())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
myDescendants.Append (theStructure.operator->());
|
||||
CalculateBoundBox();
|
||||
theStructure->Connect (this, Graphic3d_TOC_ANCESTOR);
|
||||
|
||||
GraphicConnect (theStructure);
|
||||
myStructureManager->Connect (this, theStructure);
|
||||
|
||||
Update();
|
||||
return;
|
||||
}
|
||||
case Graphic3d_TOC_ANCESTOR:
|
||||
|
||||
CalculateBoundBox();
|
||||
theStructure->Connect (this, Graphic3d_TOC_ANCESTOR);
|
||||
|
||||
GraphicConnect (theStructure);
|
||||
myStructureManager->Connect (this, theStructure);
|
||||
|
||||
Update();
|
||||
}
|
||||
else // Graphic3d_TOC_ANCESTOR
|
||||
{
|
||||
if (!AppendAncestor (aStructure))
|
||||
{
|
||||
const Standard_Integer aNbAnces = myAncestors.Length();
|
||||
for (Standard_Integer anIter = 1; anIter <= aNbAnces; ++anIter)
|
||||
{
|
||||
if (myAncestors.Value (anIter) == theStructure.operator->())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
myAncestors.Append (theStructure.operator->());
|
||||
CalculateBoundBox();
|
||||
theStructure->Connect (this, Graphic3d_TOC_DESCENDANT);
|
||||
|
||||
// myGraphicDriver->Connect is called in case if connection between parent and child
|
||||
return;
|
||||
}
|
||||
|
||||
CalculateBoundBox();
|
||||
theStructure->Connect (this, Graphic3d_TOC_DESCENDANT);
|
||||
|
||||
// myStructureManager->Connect is called in case if connection between parent and child
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1379,37 +1453,29 @@ void Graphic3d_Structure::Connect (const Handle(Graphic3d_Structure)& theStructu
|
||||
//=============================================================================
|
||||
void Graphic3d_Structure::Disconnect (const Handle(Graphic3d_Structure)& theStructure)
|
||||
{
|
||||
if (IsDeleted()) return;
|
||||
|
||||
const Standard_Integer aNbDesc = myDescendants.Length();
|
||||
for (Standard_Integer anIter = 1; anIter <= aNbDesc; ++anIter)
|
||||
if (IsDeleted())
|
||||
{
|
||||
if (myDescendants.Value (anIter) == theStructure.operator->())
|
||||
{
|
||||
myDescendants.Remove (anIter);
|
||||
theStructure->Disconnect (this);
|
||||
|
||||
GraphicDisconnect (theStructure);
|
||||
myStructureManager->Disconnect (this, theStructure);
|
||||
|
||||
CalculateBoundBox();
|
||||
|
||||
Update();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const Standard_Integer aNbAnces = myAncestors.Length();
|
||||
for (Standard_Integer anIter = 1; anIter <= aNbAnces; ++anIter)
|
||||
const Standard_Address aStructure = theStructure.operator->();
|
||||
|
||||
if (RemoveDescendant (aStructure))
|
||||
{
|
||||
if (myAncestors.Value (anIter) == theStructure.operator->())
|
||||
{
|
||||
myAncestors.Remove (anIter);
|
||||
theStructure->Disconnect (this);
|
||||
CalculateBoundBox();
|
||||
// no call of myGraphicDriver->Disconnect in case of an ancestor
|
||||
return;
|
||||
}
|
||||
theStructure->Disconnect (this);
|
||||
|
||||
GraphicDisconnect (theStructure);
|
||||
myStructureManager->Disconnect (this, theStructure);
|
||||
|
||||
CalculateBoundBox();
|
||||
Update();
|
||||
}
|
||||
else if (RemoveAncestor (aStructure))
|
||||
{
|
||||
theStructure->Disconnect (this);
|
||||
CalculateBoundBox();
|
||||
|
||||
// no call of myStructureManager->Disconnect in case of an ancestor
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1680,34 +1746,13 @@ gp_Pnt Graphic3d_Structure::TransformPersistencePoint() const
|
||||
void Graphic3d_Structure::Remove (const Standard_Address thePtr,
|
||||
const Graphic3d_TypeOfConnection theType)
|
||||
{
|
||||
switch (theType)
|
||||
if (theType == Graphic3d_TOC_DESCENDANT)
|
||||
{
|
||||
case Graphic3d_TOC_DESCENDANT:
|
||||
{
|
||||
const Standard_Integer aNbDesc = myDescendants.Length();
|
||||
for (Standard_Integer anIter = 1; anIter <= aNbDesc; ++anIter)
|
||||
{
|
||||
if (myDescendants.Value (anIter) == thePtr)
|
||||
{
|
||||
myDescendants.Remove (anIter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOC_ANCESTOR:
|
||||
{
|
||||
const Standard_Integer aNbAncestors = myAncestors.Length();
|
||||
for (Standard_Integer anIter = 1; anIter <= aNbAncestors; ++anIter)
|
||||
{
|
||||
if (myAncestors.Value (anIter) == thePtr)
|
||||
{
|
||||
myAncestors.Remove (anIter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
RemoveDescendant (thePtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveAncestor (thePtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user