// of ancestors of this structure and in the list of ancestors
// of descendants of the same structure.
- const Standard_Integer aNbDesc = myDescendants.Length();
- for (Standard_Integer aStructIter = 1; aStructIter <= aNbDesc; ++aStructIter)
+ for (Standard_Integer aStructIdx = 1, aNbDesc = myDescendants.Size(); aStructIdx <= aNbDesc; ++aStructIdx)
{
- ((Graphic3d_Structure *)(myDescendants.ChangeValue (aStructIter)))->Remove (APtr, Graphic3d_TOC_ANCESTOR);
+ ((Graphic3d_Structure *)myDescendants.FindKey (aStructIdx))->Remove (APtr, Graphic3d_TOC_ANCESTOR);
}
- const Standard_Integer aNbAnces = myAncestors.Length();
- for (Standard_Integer aStructIter = 1; aStructIter <= aNbAnces; ++aStructIter)
+ for (Standard_Integer aStructIdx = 1, aNbAnces = myAncestors.Size(); aStructIdx <= aNbAnces; ++aStructIdx)
{
- ((Graphic3d_Structure *)(myAncestors.ChangeValue (aStructIter)))->Remove (APtr, Graphic3d_TOC_DESCENDANT);
+ ((Graphic3d_Structure *)myAncestors.FindKey (aStructIdx))->Remove (APtr, Graphic3d_TOC_DESCENDANT);
}
// Destruction of me in the graphic library
}
// stop at the first descendant containing at least one facet
- const Standard_Integer aNbDesc = myDescendants.Length();
- for (Standard_Integer aStructIter = 1; aStructIter <= aNbDesc; ++aStructIter)
+ for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
{
- if (((const Graphic3d_Structure *)(myDescendants.Value (aStructIter)))->ContainsFacet())
+ if (((const Graphic3d_Structure *)anIter.Value())->ContainsFacet())
{
return Standard_True;
}
}
// stop at the first non-empty descendant
- const Standard_Integer aNbDesc = myDescendants.Length();
- for (Standard_Integer aDescIter = 1; aDescIter <= aNbDesc; ++aDescIter)
+ for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
{
- if (!((const Graphic3d_Structure* )(myDescendants.Value (aDescIter)))->IsEmpty())
+ if (!((const Graphic3d_Structure* )anIter.Value())->IsEmpty())
{
return Standard_False;
}
//=============================================================================
void Graphic3d_Structure::Ancestors (Graphic3d_MapOfStructure& theSet) const
{
- const Standard_Integer aNbAnces = myAncestors.Length ();
- for (Standard_Integer anIter = 1; anIter <= aNbAnces; ++anIter)
+ for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myAncestors); anIter.More(); anIter.Next())
{
- theSet.Add ((Graphic3d_Structure* )(myAncestors.Value (anIter)));
+ theSet.Add ((Graphic3d_Structure* )anIter.Value());
}
}
//=============================================================================
void Graphic3d_Structure::Descendants (Graphic3d_MapOfStructure& theSet) const
{
- const Standard_Integer aNbDesc = myDescendants.Length ();
- for (Standard_Integer anIter = 1; anIter <= aNbDesc; ++anIter)
+ for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
{
- theSet.Add ((Graphic3d_Structure* )(myDescendants.Value (anIter)));
+ theSet.Add ((Graphic3d_Structure* )anIter.Value());
}
}
//=============================================================================
-//function : AppendDescendant
+//function : AppendAncestor
//purpose :
//=============================================================================
-Standard_Boolean Graphic3d_Structure::AppendDescendant (const Standard_Address theDescendant)
+Standard_Boolean Graphic3d_Structure::AppendAncestor (const Standard_Address theAncestor)
{
- if (myDescendantMap.IsBound (theDescendant))
- {
- return Standard_False; // already connected
- }
-
- myDescendantMap.Bind (theDescendant, myDescendants.Length() + 1);
- myDescendants.Append (theDescendant);
+ const Standard_Integer aSize = myAncestors.Size();
- return Standard_True;
+ return myAncestors.Add (theAncestor) > aSize; // new object
}
//=============================================================================
-//function : RemoveDescendant
+//function : AppendDescendant
//purpose :
//=============================================================================
-Standard_Boolean Graphic3d_Structure::RemoveDescendant (const Standard_Address theDescendant)
+Standard_Boolean Graphic3d_Structure::AppendDescendant (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);
- }
+ const Standard_Integer aSize = myDescendants.Size();
- myDescendants.Remove (myDescendants.Length());
-
- return Standard_True;
+ return myDescendants.Add (theDescendant) > aSize; // new object
}
//=============================================================================
-//function : AppendAncestor
+//function : RemoveAncestor
//purpose :
//=============================================================================
-Standard_Boolean Graphic3d_Structure::AppendAncestor (const Standard_Address theAncestor)
+Standard_Boolean Graphic3d_Structure::RemoveAncestor (const Standard_Address theAncestor)
{
- if (myAncestorMap.IsBound (theAncestor))
+ const Standard_Integer anIndex = myAncestors.FindIndex (theAncestor);
+
+ if (anIndex != 0)
{
- return Standard_False; // already connected
+ myAncestors.Swap (anIndex, myAncestors.Size());
+ myAncestors.RemoveLast();
}
- myAncestorMap.Bind (theAncestor, myAncestors.Length() + 1);
- myAncestors.Append (theAncestor);
-
- return Standard_True;
+ return anIndex != 0; // object was found
}
//=============================================================================
-//function : RemoveAncestor
+//function : RemoveDescendant
//purpose :
//=============================================================================
-Standard_Boolean Graphic3d_Structure::RemoveAncestor (const Standard_Address theAncestor)
+Standard_Boolean Graphic3d_Structure::RemoveDescendant (const Standard_Address theDescendant)
{
- Standard_Integer aStructIdx;
- if (!myAncestorMap.Find (theAncestor, aStructIdx))
- {
- return Standard_False;
- }
-
- myAncestorMap.UnBind (theAncestor);
+ const Standard_Integer anIndex = myDescendants.FindIndex (theDescendant);
- if (aStructIdx != myAncestors.Length())
+ if (anIndex != 0)
{
- myAncestors.Exchange (aStructIdx, myAncestors.Length());
- myAncestorMap.Bind (myAncestors (aStructIdx), aStructIdx);
+ myDescendants.Swap (anIndex, myDescendants.Size());
+ myDescendants.RemoveLast();
}
- myAncestors.Remove (myAncestors.Length());
-
- return Standard_True;
+ return anIndex != 0; // object was found
}
//=============================================================================
{
case Graphic3d_TOC_DESCENDANT:
{
- const Standard_Integer aLength = myDescendants.Length();
- for (Standard_Integer anIter = 1; anIter <= aLength; ++anIter)
+ for (Standard_Integer anIdx = 1, aLength = myDescendants.Size(); anIdx <= aLength; ++anIdx)
{
// Value (1) instead of Value (i) as myDescendants
// is modified by :
// Graphic3d_Structure::Disconnect (AStructure)
// that takes AStructure from myDescendants
- ((Graphic3d_Structure* )(myDescendants.Value (1)))->Disconnect (this);
+ ((Graphic3d_Structure* )(myDescendants.FindKey (1)))->Disconnect (this);
}
break;
}
case Graphic3d_TOC_ANCESTOR:
{
- const Standard_Integer aLength = myAncestors.Length();
- for (Standard_Integer anIter = 1; anIter <= aLength; ++anIter)
+ for (Standard_Integer anIdx = 1, aLength = myAncestors.Size(); anIdx <= aLength; ++anIdx)
{
// Value (1) instead of Value (i) as myAncestors
// is modified by :
// Graphic3d_Structure::Disconnect (AStructure)
// that takes AStructure from myAncestors
- ((Graphic3d_Structure* )(myAncestors.Value (1)))->Disconnect (this);
+ ((Graphic3d_Structure* )(myAncestors.FindKey (1)))->Disconnect (this);
}
break;
}
TColStd_Array2OfReal aMatrix44 (0, 3, 0, 3);
// Assign the new transformation in an array [0..3][0..3]
- // Avoid problemes if the user has defined matrice [1..4][1..4]
- // or [3..6][-1..2] !!
+ // Avoid problems if the user has defined matrix [1..4][1..4]
+ // or [3..6][-1..2] !!
Standard_Integer lr = theMatrix.LowerRow();
Standard_Integer ur = theMatrix.UpperRow();
Standard_Integer lc = theMatrix.LowerCol();
Graphic3d_BndBox4d aCombinedBox, aBox;
getBox (aCombinedBox, theToIgnoreInfiniteFlag);
- for (Standard_Integer aStructIt = 1; aStructIt <= myDescendants.Length(); ++aStructIt)
+ for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
{
- const Graphic3d_Structure* aStruct = (const Graphic3d_Structure* )myDescendants.Value (aStructIt);
+ const Graphic3d_Structure* aStruct = (const Graphic3d_Structure* )anIter.Value();
aStruct->getBox (aBox, theToIgnoreInfiniteFlag);
aCombinedBox.Combine (aBox);
}