mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-07-20 12:45:50 +03:00
0026220: Visualization - In Graphic3d_Structure use single NCollection_IndexedMap instead of NCollection_DataMap and NCollection_Sequence
This commit is contained in:
parent
b34ca16935
commit
7197da1a33
@ -16,8 +16,8 @@
|
|||||||
#ifndef _Graphic3d_IndexedMapOfAddress
|
#ifndef _Graphic3d_IndexedMapOfAddress
|
||||||
#define _Graphic3d_IndexedMapOfAddress
|
#define _Graphic3d_IndexedMapOfAddress
|
||||||
|
|
||||||
#include <NCollection_DataMap.hxx>
|
#include <NCollection_IndexedMap.hxx>
|
||||||
|
|
||||||
typedef NCollection_DataMap<const Standard_Address, Standard_Integer> Graphic3d_IndexedMapOfAddress;
|
typedef NCollection_IndexedMap<const Standard_Address> Graphic3d_IndexedMapOfAddress;
|
||||||
|
|
||||||
#endif // _Graphic3d_IndexedMapOfAddress
|
#endif // _Graphic3d_IndexedMapOfAddress
|
||||||
|
@ -1003,17 +1003,11 @@ fields
|
|||||||
-- the associated low-level structure
|
-- the associated low-level structure
|
||||||
myCStructure : CStructure from Graphic3d;
|
myCStructure : CStructure from Graphic3d;
|
||||||
|
|
||||||
-- the structures to which the structure is attached
|
-- the set of structures to which the structure is attached
|
||||||
myAncestors : SequenceOfAddress from TColStd;
|
myAncestors : IndexedMapOfAddress from Graphic3d;
|
||||||
|
|
||||||
-- the structures attached to the structure
|
-- the set of structures attached to the structure
|
||||||
myDescendants : SequenceOfAddress from TColStd;
|
myDescendants : IndexedMapOfAddress from Graphic3d;
|
||||||
|
|
||||||
-- the map of structures to which the structure is attached
|
|
||||||
myAncestorMap : IndexedMapOfAddress from Graphic3d;
|
|
||||||
|
|
||||||
-- the map of structures attached to the structure
|
|
||||||
myDescendantMap : IndexedMapOfAddress from Graphic3d;
|
|
||||||
|
|
||||||
-- the highlight method of the structure
|
-- the highlight method of the structure
|
||||||
myHighlightColor : Color from Quantity;
|
myHighlightColor : Color from Quantity;
|
||||||
|
@ -164,16 +164,14 @@ void Graphic3d_Structure::Remove()
|
|||||||
// of ancestors of this structure and in the list of ancestors
|
// of ancestors of this structure and in the list of ancestors
|
||||||
// of descendants of the same structure.
|
// of descendants of the same structure.
|
||||||
|
|
||||||
const Standard_Integer aNbDesc = myDescendants.Length();
|
for (Standard_Integer aStructIdx = 1, aNbDesc = myDescendants.Size(); aStructIdx <= aNbDesc; ++aStructIdx)
|
||||||
for (Standard_Integer aStructIter = 1; aStructIter <= aNbDesc; ++aStructIter)
|
|
||||||
{
|
{
|
||||||
((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 aStructIdx = 1, aNbAnces = myAncestors.Size(); aStructIdx <= aNbAnces; ++aStructIdx)
|
||||||
for (Standard_Integer aStructIter = 1; aStructIter <= aNbAnces; ++aStructIter)
|
|
||||||
{
|
{
|
||||||
((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
|
// Destruction of me in the graphic library
|
||||||
@ -479,10 +477,9 @@ Standard_Boolean Graphic3d_Structure::ContainsFacet() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stop at the first descendant containing at least one facet
|
// stop at the first descendant containing at least one facet
|
||||||
const Standard_Integer aNbDesc = myDescendants.Length();
|
for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
|
||||||
for (Standard_Integer aStructIter = 1; aStructIter <= aNbDesc; ++aStructIter)
|
|
||||||
{
|
{
|
||||||
if (((const Graphic3d_Structure *)(myDescendants.Value (aStructIter)))->ContainsFacet())
|
if (((const Graphic3d_Structure *)anIter.Value())->ContainsFacet())
|
||||||
{
|
{
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
@ -514,10 +511,9 @@ Standard_Boolean Graphic3d_Structure::IsEmpty() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stop at the first non-empty descendant
|
// stop at the first non-empty descendant
|
||||||
const Standard_Integer aNbDesc = myDescendants.Length();
|
for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
|
||||||
for (Standard_Integer aDescIter = 1; aDescIter <= aNbDesc; ++aDescIter)
|
|
||||||
{
|
{
|
||||||
if (!((const Graphic3d_Structure* )(myDescendants.Value (aDescIter)))->IsEmpty())
|
if (!((const Graphic3d_Structure* )anIter.Value())->IsEmpty())
|
||||||
{
|
{
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
@ -1274,10 +1270,9 @@ Standard_Boolean Graphic3d_Structure::AcceptConnection (const Handle(Graphic3d_S
|
|||||||
//=============================================================================
|
//=============================================================================
|
||||||
void Graphic3d_Structure::Ancestors (Graphic3d_MapOfStructure& theSet) const
|
void Graphic3d_Structure::Ancestors (Graphic3d_MapOfStructure& theSet) const
|
||||||
{
|
{
|
||||||
const Standard_Integer aNbAnces = myAncestors.Length ();
|
for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myAncestors); anIter.More(); anIter.Next())
|
||||||
for (Standard_Integer anIter = 1; anIter <= aNbAnces; ++anIter)
|
|
||||||
{
|
{
|
||||||
theSet.Add ((Graphic3d_Structure* )(myAncestors.Value (anIter)));
|
theSet.Add ((Graphic3d_Structure* )anIter.Value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1305,70 +1300,32 @@ Standard_Address Graphic3d_Structure::Owner() const
|
|||||||
//=============================================================================
|
//=============================================================================
|
||||||
void Graphic3d_Structure::Descendants (Graphic3d_MapOfStructure& theSet) const
|
void Graphic3d_Structure::Descendants (Graphic3d_MapOfStructure& theSet) const
|
||||||
{
|
{
|
||||||
const Standard_Integer aNbDesc = myDescendants.Length ();
|
for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
|
||||||
for (Standard_Integer anIter = 1; anIter <= aNbDesc; ++anIter)
|
|
||||||
{
|
{
|
||||||
theSet.Add ((Graphic3d_Structure* )(myDescendants.Value (anIter)));
|
theSet.Add ((Graphic3d_Structure* )anIter.Value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//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
|
//function : AppendAncestor
|
||||||
//purpose :
|
//purpose :
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
Standard_Boolean Graphic3d_Structure::AppendAncestor (const Standard_Address theAncestor)
|
Standard_Boolean Graphic3d_Structure::AppendAncestor (const Standard_Address theAncestor)
|
||||||
{
|
{
|
||||||
if (myAncestorMap.IsBound (theAncestor))
|
const Standard_Integer aSize = myAncestors.Size();
|
||||||
{
|
|
||||||
return Standard_False; // already connected
|
|
||||||
}
|
|
||||||
|
|
||||||
myAncestorMap.Bind (theAncestor, myAncestors.Length() + 1);
|
return myAncestors.Add (theAncestor) > aSize; // new object
|
||||||
myAncestors.Append (theAncestor);
|
}
|
||||||
|
|
||||||
return Standard_True;
|
//=============================================================================
|
||||||
|
//function : AppendDescendant
|
||||||
|
//purpose :
|
||||||
|
//=============================================================================
|
||||||
|
Standard_Boolean Graphic3d_Structure::AppendDescendant (const Standard_Address theDescendant)
|
||||||
|
{
|
||||||
|
const Standard_Integer aSize = myDescendants.Size();
|
||||||
|
|
||||||
|
return myDescendants.Add (theDescendant) > aSize; // new object
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
@ -1377,23 +1334,32 @@ Standard_Boolean Graphic3d_Structure::AppendAncestor (const Standard_Address the
|
|||||||
//=============================================================================
|
//=============================================================================
|
||||||
Standard_Boolean Graphic3d_Structure::RemoveAncestor (const Standard_Address theAncestor)
|
Standard_Boolean Graphic3d_Structure::RemoveAncestor (const Standard_Address theAncestor)
|
||||||
{
|
{
|
||||||
Standard_Integer aStructIdx;
|
const Standard_Integer anIndex = myAncestors.FindIndex (theAncestor);
|
||||||
if (!myAncestorMap.Find (theAncestor, aStructIdx))
|
|
||||||
|
if (anIndex != 0)
|
||||||
{
|
{
|
||||||
return Standard_False;
|
myAncestors.Swap (anIndex, myAncestors.Size());
|
||||||
|
myAncestors.RemoveLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
myAncestorMap.UnBind (theAncestor);
|
return anIndex != 0; // object was found
|
||||||
|
}
|
||||||
|
|
||||||
if (aStructIdx != myAncestors.Length())
|
//=============================================================================
|
||||||
|
//function : RemoveDescendant
|
||||||
|
//purpose :
|
||||||
|
//=============================================================================
|
||||||
|
Standard_Boolean Graphic3d_Structure::RemoveDescendant (const Standard_Address theDescendant)
|
||||||
|
{
|
||||||
|
const Standard_Integer anIndex = myDescendants.FindIndex (theDescendant);
|
||||||
|
|
||||||
|
if (anIndex != 0)
|
||||||
{
|
{
|
||||||
myAncestors.Exchange (aStructIdx, myAncestors.Length());
|
myDescendants.Swap (anIndex, myDescendants.Size());
|
||||||
myAncestorMap.Bind (myAncestors (aStructIdx), aStructIdx);
|
myDescendants.RemoveLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
myAncestors.Remove (myAncestors.Length());
|
return anIndex != 0; // object was found
|
||||||
|
|
||||||
return Standard_True;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
@ -1491,27 +1457,25 @@ void Graphic3d_Structure::DisconnectAll (const Graphic3d_TypeOfConnection theTyp
|
|||||||
{
|
{
|
||||||
case Graphic3d_TOC_DESCENDANT:
|
case Graphic3d_TOC_DESCENDANT:
|
||||||
{
|
{
|
||||||
const Standard_Integer aLength = myDescendants.Length();
|
for (Standard_Integer anIdx = 1, aLength = myDescendants.Size(); anIdx <= aLength; ++anIdx)
|
||||||
for (Standard_Integer anIter = 1; anIter <= aLength; ++anIter)
|
|
||||||
{
|
{
|
||||||
// Value (1) instead of Value (i) as myDescendants
|
// Value (1) instead of Value (i) as myDescendants
|
||||||
// is modified by :
|
// is modified by :
|
||||||
// Graphic3d_Structure::Disconnect (AStructure)
|
// Graphic3d_Structure::Disconnect (AStructure)
|
||||||
// that takes AStructure from myDescendants
|
// that takes AStructure from myDescendants
|
||||||
((Graphic3d_Structure* )(myDescendants.Value (1)))->Disconnect (this);
|
((Graphic3d_Structure* )(myDescendants.FindKey (1)))->Disconnect (this);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Graphic3d_TOC_ANCESTOR:
|
case Graphic3d_TOC_ANCESTOR:
|
||||||
{
|
{
|
||||||
const Standard_Integer aLength = myAncestors.Length();
|
for (Standard_Integer anIdx = 1, aLength = myAncestors.Size(); anIdx <= aLength; ++anIdx)
|
||||||
for (Standard_Integer anIter = 1; anIter <= aLength; ++anIter)
|
|
||||||
{
|
{
|
||||||
// Value (1) instead of Value (i) as myAncestors
|
// Value (1) instead of Value (i) as myAncestors
|
||||||
// is modified by :
|
// is modified by :
|
||||||
// Graphic3d_Structure::Disconnect (AStructure)
|
// Graphic3d_Structure::Disconnect (AStructure)
|
||||||
// that takes AStructure from myAncestors
|
// that takes AStructure from myAncestors
|
||||||
((Graphic3d_Structure* )(myAncestors.Value (1)))->Disconnect (this);
|
((Graphic3d_Structure* )(myAncestors.FindKey (1)))->Disconnect (this);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1543,7 +1507,7 @@ void Graphic3d_Structure::SetTransform (const TColStd_Array2OfReal& theMat
|
|||||||
TColStd_Array2OfReal aMatrix44 (0, 3, 0, 3);
|
TColStd_Array2OfReal aMatrix44 (0, 3, 0, 3);
|
||||||
|
|
||||||
// Assign the new transformation in an array [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]
|
// Avoid problems if the user has defined matrix [1..4][1..4]
|
||||||
// or [3..6][-1..2] !!
|
// or [3..6][-1..2] !!
|
||||||
Standard_Integer lr = theMatrix.LowerRow();
|
Standard_Integer lr = theMatrix.LowerRow();
|
||||||
Standard_Integer ur = theMatrix.UpperRow();
|
Standard_Integer ur = theMatrix.UpperRow();
|
||||||
@ -1851,9 +1815,9 @@ void Graphic3d_Structure::addTransformed (Graphic3d_BndBox4d& theBox,
|
|||||||
Graphic3d_BndBox4d aCombinedBox, aBox;
|
Graphic3d_BndBox4d aCombinedBox, aBox;
|
||||||
getBox (aCombinedBox, theToIgnoreInfiniteFlag);
|
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);
|
aStruct->getBox (aBox, theToIgnoreInfiniteFlag);
|
||||||
aCombinedBox.Combine (aBox);
|
aCombinedBox.Combine (aBox);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user