#include <Graphic3d_StructureDefinitionError.hxx>
#include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_TransformError.hxx>
-#include <Graphic3d_Vector.hxx>
#include <Quantity_Color.hxx>
-#include <Standard_Type.hxx>
-#include <TColStd_Array2OfReal.hxx>
#include "Graphic3d_Structure.pxx"
+#include <Standard_Dump.hxx>
+
#include <stdio.h>
-IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Structure,MMgt_TShared)
-
-//=============================================================================
-//function : Graphic3d_Structure
-//purpose :
-//=============================================================================
-Graphic3d_Structure::Graphic3d_Structure (const Handle(Graphic3d_StructureManager)& theManager)
-: myStructureManager (theManager.operator->()),
- myFirstStructureManager (theManager.operator->()),
- myComputeVisual (Graphic3d_TOS_ALL),
- myHighlightColor (Quantity_NOC_WHITE),
- myHighlightMethod (Aspect_TOHM_COLOR),
- myOwner (NULL),
- myVisual (Graphic3d_TOS_ALL)
-{
- myCStructure = theManager->GraphicDriver()->CreateStructure (theManager);
-}
+IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Structure,Standard_Transient)
//=============================================================================
//function : Graphic3d_Structure
//purpose :
//=============================================================================
Graphic3d_Structure::Graphic3d_Structure (const Handle(Graphic3d_StructureManager)& theManager,
- const Handle(Graphic3d_Structure)& thePrs)
-: myStructureManager (theManager.operator->()),
- myFirstStructureManager (theManager.operator->()),
- myComputeVisual (thePrs->myComputeVisual),
- myHighlightColor (thePrs->myHighlightColor),
- myHighlightMethod (thePrs->myHighlightMethod),
- myOwner (thePrs->myOwner),
- myVisual (thePrs->myVisual)
+ const Handle(Graphic3d_Structure)& theLinkPrs)
+: myStructureManager(theManager.get()),
+ myOwner (NULL),
+ myVisual (Graphic3d_TOS_ALL),
+ myComputeVisual (Graphic3d_TOS_ALL)
{
- myCStructure = thePrs->myCStructure->ShadowLink (theManager);
+ if (!theLinkPrs.IsNull())
+ {
+ myOwner = theLinkPrs->myOwner;
+ myVisual = theLinkPrs->myVisual;
+ myComputeVisual = theLinkPrs->myComputeVisual;
+ myCStructure = theLinkPrs->myCStructure->ShadowLink (theManager);
+ }
+ else
+ {
+ myCStructure = theManager->GraphicDriver()->CreateStructure (theManager);
+ }
}
//=============================================================================
//=============================================================================
Graphic3d_Structure::~Graphic3d_Structure()
{
- // as myFirstStructureManager can be already destroyed,
+ // as myStructureManager can be already destroyed,
// avoid attempts to access it
- myFirstStructureManager = NULL;
+ myStructureManager = NULL;
Remove();
}
//=============================================================================
-//function : Clear
+//function : clear
//purpose :
//=============================================================================
-void Graphic3d_Structure::Clear (const Standard_Boolean theWithDestruction)
+void Graphic3d_Structure::clear (const Standard_Boolean theWithDestruction)
{
if (IsDeleted()) return;
//=======================================================================
void Graphic3d_Structure::CalculateBoundBox()
{
- Graphic3d_BndBox4d aBox;
+ Graphic3d_BndBox3d aBox;
addTransformed (aBox, Standard_True);
- if (aBox.IsValid())
- {
- Graphic3d_Vec4 aMinPt (RealToShortReal (aBox.CornerMin().x()),
- RealToShortReal (aBox.CornerMin().y()),
- RealToShortReal (aBox.CornerMin().z()),
- 1.0f);
- Graphic3d_Vec4 aMaxPt (RealToShortReal (aBox.CornerMax().x()),
- RealToShortReal (aBox.CornerMax().y()),
- RealToShortReal (aBox.CornerMax().z()),
- 1.0f);
- myCStructure->ChangeBoundingBox() = Graphic3d_BndBox4f (aMinPt, aMaxPt);
- }
- else
- {
- myCStructure->ChangeBoundingBox().Clear();
- }
+ myCStructure->ChangeBoundingBox() = aBox;
}
//=============================================================================
aGroupIter.ChangeValue()->Clear (Standard_False);
}
- Standard_Address APtr = (void *) this;
- // It is necessary to remove the eventual pointer on the structure
- // that can be destroyed, in the list of descendants
- // of ancestors of this structure and in the list of ancestors
- // of descendants of the same structure.
-
+ // It is necessary to remove the eventual pointer on the structure that can be destroyed, in the list of descendants
+ // of ancestors of this structure and in the list of ancestors of descendants of the same structure.
for (Standard_Integer aStructIdx = 1, aNbDesc = myDescendants.Size(); aStructIdx <= aNbDesc; ++aStructIdx)
{
- ((Graphic3d_Structure *)myDescendants.FindKey (aStructIdx))->Remove (APtr, Graphic3d_TOC_ANCESTOR);
+ myDescendants.FindKey (aStructIdx)->Remove (this, Graphic3d_TOC_ANCESTOR);
}
for (Standard_Integer aStructIdx = 1, aNbAnces = myAncestors.Size(); aStructIdx <= aNbAnces; ++aStructIdx)
{
- ((Graphic3d_Structure *)myAncestors.FindKey (aStructIdx))->Remove (APtr, Graphic3d_TOC_DESCENDANT);
+ myAncestors.FindKey (aStructIdx)->Remove (this, Graphic3d_TOC_DESCENDANT);
}
// Destruction of me in the graphic library
}
}
-//=============================================================================
-//function : SetIsForHighlight
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::SetIsForHighlight (const Standard_Boolean isForHighlight)
-{
- myCStructure->IsForHighlight = isForHighlight;
-}
-
//=============================================================================
//function : SetDisplayPriority
//purpose :
}
//=============================================================================
-//function : DisplayPriority
+//function : erase
//purpose :
//=============================================================================
-Standard_Integer Graphic3d_Structure::DisplayPriority() const
-{
- return myCStructure->Priority;
-}
-
-//=============================================================================
-//function : Erase
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::Erase()
+void Graphic3d_Structure::erase()
{
if (IsDeleted())
{
//function : Highlight
//purpose :
//=============================================================================
-void Graphic3d_Structure::Highlight (const Aspect_TypeOfHighlightMethod theMethod,
- const Quantity_Color& theColor,
- const Standard_Boolean theToUpdateMgr)
+void Graphic3d_Structure::Highlight (const Handle(Graphic3d_PresentationAttributes)& theStyle,
+ const Standard_Boolean theToUpdateMgr)
{
if (IsDeleted())
{
return;
}
- myHighlightColor = theColor;
-
- // Highlight on already Highlighted structure.
- if (myCStructure->highlight)
- {
- Aspect_TypeOfUpdate anUpdateMode = myStructureManager->UpdateMode();
- if (anUpdateMode == Aspect_TOU_WAIT)
- {
- UnHighlight();
- }
- else
- {
- // To avoid call of method : Update()
- // Not useful and can be costly.
- myStructureManager->SetUpdateMode (Aspect_TOU_WAIT);
- UnHighlight();
- myStructureManager->SetUpdateMode (anUpdateMode);
- }
- }
-
SetDisplayPriority (Structure_MAX_PRIORITY - 1);
- GraphicHighlight (theMethod);
+ myCStructure->GraphicHighlight (theStyle);
if (!theToUpdateMgr)
{
if (myCStructure->stick)
{
- myStructureManager->Highlight (this, theMethod);
+ myStructureManager->Highlight (this);
}
Update();
{
myCStructure->highlight = 0;
- GraphicUnHighlight();
+ myCStructure->GraphicUnhighlight();
myStructureManager->UnHighlight (this);
ResetDisplayPriority();
}
}
-//=============================================================================
-//function : HighlightColor
-//purpose :
-//=============================================================================
-const Quantity_Color& Graphic3d_Structure::HighlightColor() const
-{
- return myHighlightColor;
-}
-
-//=============================================================================
-//function : IsDisplayed
-//purpose :
-//=============================================================================
-Standard_Boolean Graphic3d_Structure::IsDisplayed() const
-{
- return myCStructure->stick ? Standard_True : Standard_False;
-}
-
-//=============================================================================
-//function : IsDeleted
-//purpose :
-//=============================================================================
-Standard_Boolean Graphic3d_Structure::IsDeleted() const
-{
- return myCStructure.IsNull();
-}
-
-//=============================================================================
-//function : IsHighlighted
-//purpose :
-//=============================================================================
-Standard_Boolean Graphic3d_Structure::IsHighlighted() const
-{
- return myCStructure->highlight ? Standard_True : Standard_False;
-}
-
-//=============================================================================
-//function : IsVisible
-//purpose :
-//=============================================================================
-Standard_Boolean Graphic3d_Structure::IsVisible() const
-{
- return myCStructure->visible ? Standard_True : Standard_False;
-}
-
-//=============================================================================
-//function : IsTransformed
-//purpose :
-//=============================================================================
-Standard_Boolean Graphic3d_Structure::IsTransformed() const
-{
- return !myCStructure->Transformation.IsIdentity();
-}
-
//=============================================================================
//function : ContainsFacet
//purpose :
}
// stop at the first descendant containing at least one facet
- for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
+ for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
{
- if (((const Graphic3d_Structure *)anIter.Value())->ContainsFacet())
+ if (anIter.Value()->ContainsFacet())
{
return Standard_True;
}
}
// stop at the first non-empty descendant
- for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
+ for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
{
- if (!((const Graphic3d_Structure* )anIter.Value())->IsEmpty())
+ if (!anIter.Value()->IsEmpty())
{
return Standard_False;
}
}
}
-//=============================================================================
-//function : Compute
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::Compute()
-{
- // Implemented by Presentation
-}
-
-//=============================================================================
-//function : Compute
-//purpose :
-//=============================================================================
-Handle(Graphic3d_Structure) Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& )
-{
- // Implemented by Presentation
- return this;
-}
-
-//=============================================================================
-//function : Compute
-//purpose :
-//=============================================================================
-Handle(Graphic3d_Structure) Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& ,
- const TColStd_Array2OfReal& )
-{
- // Implemented by Presentation
- return this;
-}
-
-//=============================================================================
-//function : Compute
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& ,
- Handle(Graphic3d_Structure)& )
-{
- // Implemented by Presentation
-}
-
-//=============================================================================
-//function : Compute
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& ,
- const TColStd_Array2OfReal& ,
- Handle(Graphic3d_Structure)& )
-{
- // Implemented by Presentation
-}
-
//=============================================================================
//function : ReCompute
//purpose :
myStructureManager->ReCompute (this, theProjector);
}
-//=============================================================================
-//function : SetInfiniteState
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::SetInfiniteState (const Standard_Boolean theToSet)
-{
- myCStructure->IsInfinite = theToSet ? 1 : 0;
-}
-
-//=============================================================================
-//function : IsInfinite
-//purpose :
-//=============================================================================
-Standard_Boolean Graphic3d_Structure::IsInfinite() const
-{
- return IsDeleted()
- || myCStructure->IsInfinite;
-}
-
//=============================================================================
//function : GraphicClear
//purpose :
myCStructure->Clear();
}
-//=============================================================================
-//function : GraphicConnect
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::GraphicConnect (const Handle(Graphic3d_Structure)& theDaughter)
-{
- myCStructure->Connect (*theDaughter->myCStructure);
-}
-
-//=============================================================================
-//function : GraphicDisconnect
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::GraphicDisconnect (const Handle(Graphic3d_Structure)& theDaughter)
-{
- myCStructure->Disconnect (*theDaughter->myCStructure);
-}
-
-//=============================================================================
-//function : Groups
-//purpose :
-//=============================================================================
-const Graphic3d_SequenceOfGroup& Graphic3d_Structure::Groups() const
-{
- return myCStructure->Groups();
-}
-
-//=============================================================================
-//function : NumberOfGroups
-//purpose :
-//=============================================================================
-Standard_Integer Graphic3d_Structure::NumberOfGroups() const
-{
- return myCStructure->Groups().Length();
-}
-
//=============================================================================
//function : SetVisual
//purpose :
}
else
{
- Aspect_TypeOfUpdate anUpdateMode = myStructureManager->UpdateMode();
- if (anUpdateMode == Aspect_TOU_WAIT)
- {
- Erase();
- myVisual = theVisual;
- SetComputeVisual (theVisual);
- Display();
- }
- else {
- // To avoid calling method : Update ()
- // Not useful and can be costly.
- myStructureManager->SetUpdateMode (Aspect_TOU_WAIT);
- Erase();
- myVisual = theVisual;
- SetComputeVisual (theVisual);
- myStructureManager->SetUpdateMode (anUpdateMode);
- Display();
- }
+ erase();
+ myVisual = theVisual;
+ SetComputeVisual (theVisual);
+ Display();
}
}
"ZoomLimit sup < ZoomLimit inf");
}
-//=============================================================================
-//function : Visual
-//purpose :
-//=============================================================================
-Graphic3d_TypeOfStructure Graphic3d_Structure::Visual() const
-{
- return myVisual;
-}
-
//=============================================================================
//function : AcceptConnection
//purpose :
//=============================================================================
-Standard_Boolean Graphic3d_Structure::AcceptConnection (const Handle(Graphic3d_Structure)& theStructure1,
- const Handle(Graphic3d_Structure)& theStructure2,
- const Graphic3d_TypeOfConnection theType)
+Standard_Boolean Graphic3d_Structure::AcceptConnection (Graphic3d_Structure* theStructure1,
+ Graphic3d_Structure* theStructure2,
+ Graphic3d_TypeOfConnection theType)
{
// cycle detection
- Graphic3d_MapOfStructure aSet;
+ NCollection_Map<Graphic3d_Structure*> aSet;
Graphic3d_Structure::Network (theStructure2, theType, aSet);
return !aSet.Contains (theStructure1);
}
//=============================================================================
void Graphic3d_Structure::Ancestors (Graphic3d_MapOfStructure& theSet) const
{
- for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myAncestors); anIter.More(); anIter.Next())
+ for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myAncestors); anIter.More(); anIter.Next())
{
- theSet.Add ((Graphic3d_Structure* )anIter.Value());
+ theSet.Add (anIter.Value());
}
}
-//=============================================================================
-//function : SetOwner
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::SetOwner (const Standard_Address theOwner)
-{
- myOwner = theOwner;
-}
-
-//=============================================================================
-//function : Owner
-//purpose :
-//=============================================================================
-Standard_Address Graphic3d_Structure::Owner() const
-{
- return myOwner;
-}
-
//=============================================================================
//function : Descendants
//purpose :
//=============================================================================
void Graphic3d_Structure::Descendants (Graphic3d_MapOfStructure& theSet) const
{
- for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
+ for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
{
- theSet.Add ((Graphic3d_Structure* )anIter.Value());
+ theSet.Add (anIter.Value());
}
}
//function : AppendAncestor
//purpose :
//=============================================================================
-Standard_Boolean Graphic3d_Structure::AppendAncestor (const Standard_Address theAncestor)
+Standard_Boolean Graphic3d_Structure::AppendAncestor (Graphic3d_Structure* theAncestor)
{
const Standard_Integer aSize = myAncestors.Size();
//function : AppendDescendant
//purpose :
//=============================================================================
-Standard_Boolean Graphic3d_Structure::AppendDescendant (const Standard_Address theDescendant)
+Standard_Boolean Graphic3d_Structure::AppendDescendant (Graphic3d_Structure* theDescendant)
{
const Standard_Integer aSize = myDescendants.Size();
//function : RemoveAncestor
//purpose :
//=============================================================================
-Standard_Boolean Graphic3d_Structure::RemoveAncestor (const Standard_Address theAncestor)
+Standard_Boolean Graphic3d_Structure::RemoveAncestor (Graphic3d_Structure* theAncestor)
{
const Standard_Integer anIndex = myAncestors.FindIndex (theAncestor);
//function : RemoveDescendant
//purpose :
//=============================================================================
-Standard_Boolean Graphic3d_Structure::RemoveDescendant (const Standard_Address theDescendant)
+Standard_Boolean Graphic3d_Structure::RemoveDescendant (Graphic3d_Structure* theDescendant)
{
const Standard_Integer anIndex = myDescendants.FindIndex (theDescendant);
//function : Connect
//purpose :
//=============================================================================
-void Graphic3d_Structure::Connect (const Handle(Graphic3d_Structure)& theStructure,
- const Graphic3d_TypeOfConnection theType,
- const Standard_Boolean theWithCheck)
+void Graphic3d_Structure::Connect (Graphic3d_Structure* theStructure,
+ Graphic3d_TypeOfConnection theType,
+ Standard_Boolean theWithCheck)
{
if (IsDeleted())
{
return;
}
- const Standard_Address aStructure = theStructure.operator->();
-
if (theType == Graphic3d_TOC_DESCENDANT)
{
- if (!AppendDescendant (aStructure))
+ if (!AppendDescendant (theStructure))
{
return;
}
}
else // Graphic3d_TOC_ANCESTOR
{
- if (!AppendAncestor (aStructure))
+ if (!AppendAncestor (theStructure))
{
return;
}
//function : Disconnect
//purpose :
//=============================================================================
-void Graphic3d_Structure::Disconnect (const Handle(Graphic3d_Structure)& theStructure)
+void Graphic3d_Structure::Disconnect (Graphic3d_Structure* theStructure)
{
if (IsDeleted())
{
return;
}
- const Standard_Address aStructure = theStructure.operator->();
-
- if (RemoveDescendant (aStructure))
+ if (RemoveDescendant (theStructure))
{
theStructure->Disconnect (this);
CalculateBoundBox();
Update (true);
}
- else if (RemoveAncestor (aStructure))
+ else if (RemoveAncestor (theStructure))
{
theStructure->Disconnect (this);
CalculateBoundBox();
// is modified by :
// Graphic3d_Structure::Disconnect (AStructure)
// that takes AStructure from myDescendants
- ((Graphic3d_Structure* )(myDescendants.FindKey (1)))->Disconnect (this);
+ myDescendants.FindKey (1)->Disconnect (this);
}
break;
}
// is modified by :
// Graphic3d_Structure::Disconnect (AStructure)
// that takes AStructure from myAncestors
- ((Graphic3d_Structure* )(myAncestors.FindKey (1)))->Disconnect (this);
+ myAncestors.FindKey (1)->Disconnect (this);
}
break;
}
//function : SetTransform
//purpose :
//=============================================================================
-void Graphic3d_Structure::SetTransform (const TColStd_Array2OfReal& theMatrix,
- const Graphic3d_TypeOfComposition theType)
+void Graphic3d_Structure::SetTransformation (const Handle(TopLoc_Datum3D)& theTrsf)
{
if (IsDeleted()) return;
- Standard_Real valuetrsf;
- Standard_Real valueoldtrsf;
- Standard_Real valuenewtrsf;
- TColStd_Array2OfReal aNewTrsf (0, 3, 0, 3);
- TColStd_Array2OfReal aMatrix44 (0, 3, 0, 3);
-
- // Assign the new transformation in an array [0..3][0..3]
- // 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();
- Standard_Integer uc = theMatrix.UpperCol();
-
- if ((ur - lr + 1 != 4) || (uc - lc + 1 != 4))
+ const Standard_Boolean wasTransformed = IsTransformed();
+
+ if (!theTrsf.IsNull()
+ && theTrsf->Trsf().Form() == gp_Identity)
{
- Graphic3d_TransformError::Raise ("Transform : not a 4x4 matrix");
+ myCStructure->SetTransformation (Handle(TopLoc_Datum3D)());
}
-
- const Standard_Boolean wasTransformed = IsTransformed();
- switch (theType)
+ else
{
- case Graphic3d_TOC_REPLACE:
- {
- // Update of CStructure
- for (Standard_Integer i = 0; i <= 3; ++i)
- {
- for (Standard_Integer j = 0; j <= 3; ++j)
- {
- myCStructure->Transformation.ChangeValue (i, j) = float (theMatrix (lr + i, lc + j));
- aNewTrsf (i, j) = theMatrix (lr + i, lc + j);
- }
- }
- break;
- }
- case Graphic3d_TOC_POSTCONCATENATE:
- {
- // To simplify management of indices
- for (Standard_Integer i = 0; i <= 3; ++i)
- {
- for (Standard_Integer j = 0; j <= 3; ++j)
- {
- aMatrix44 (i, j) = theMatrix (lr + i, lc + j);
- }
- }
-
- // Calculation of the product of matrices
- for (Standard_Integer i = 0; i <= 3; ++i)
- {
- for (Standard_Integer j = 0; j <= 3; ++j)
- {
- aNewTrsf (i, j) = 0.0;
- for (Standard_Integer k = 0; k <= 3; ++k)
- {
- valueoldtrsf = myCStructure->Transformation.GetValue (i, k);
- valuetrsf = aMatrix44 (k, j);
- valuenewtrsf = aNewTrsf (i, j) + valueoldtrsf * valuetrsf;
- aNewTrsf (i, j) = valuenewtrsf;
- }
- }
- }
-
- // Update of CStructure
- for (Standard_Integer i = 0; i <= 3; ++i)
- {
- for (Standard_Integer j = 0; j <= 3; ++j)
- {
- myCStructure->Transformation.ChangeValue (i, j) = float (aNewTrsf (i, j));
- }
- }
- break;
- }
+ myCStructure->SetTransformation (theTrsf);
}
// If transformation, no validation of hidden already calculated parts
ReCompute();
}
- myCStructure->UpdateTransformation();
- myStructureManager->SetTransform (this, aNewTrsf);
+ myStructureManager->SetTransform (this, theTrsf);
Update (true);
}
-//=============================================================================
-//function : Transform
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::Transform (TColStd_Array2OfReal& theMatrix) const
-{
-
- Standard_Integer lr = theMatrix.LowerRow ();
- Standard_Integer ur = theMatrix.UpperRow ();
- Standard_Integer lc = theMatrix.LowerCol ();
- Standard_Integer uc = theMatrix.UpperCol ();
-
- if ((ur - lr + 1 != 4) || (uc - lc + 1 != 4))
- Graphic3d_TransformError::Raise ("Transform : not a 4x4 matrix");
-
- for (Standard_Integer i = 0; i <= 3; ++i)
- {
- for (Standard_Integer j = 0; j <= 3; ++j)
- {
- theMatrix (lr + i, lc + j) = myCStructure->Transformation.GetValue (i, j);
- }
- }
-}
-
-
//=============================================================================
//function : MinMaxValues
//purpose :
//=============================================================================
Bnd_Box Graphic3d_Structure::MinMaxValues (const Standard_Boolean theToIgnoreInfiniteFlag) const
{
- Graphic3d_BndBox4d aBox;
- Bnd_Box aResult;
+ Graphic3d_BndBox3d aBox;
addTransformed (aBox, theToIgnoreInfiniteFlag);
- if (aBox.IsValid())
+ if (!aBox.IsValid())
{
- aResult.Add (gp_Pnt (aBox.CornerMin().x(),
- aBox.CornerMin().y(),
- aBox.CornerMin().z()));
- aResult.Add (gp_Pnt (aBox.CornerMax().x(),
- aBox.CornerMax().y(),
- aBox.CornerMax().z()));
-
- Standard_Real aLimMin = ShortRealFirst() + 1.0;
- Standard_Real aLimMax = ShortRealLast() - 1.0;
- gp_Pnt aMin = aResult.CornerMin();
- gp_Pnt aMax = aResult.CornerMax();
- if (aMin.X() < aLimMin && aMin.Y() < aLimMin && aMin.Z() < aLimMin &&
- aMax.X() > aLimMax && aMax.Y() > aLimMax && aMax.Z() > aLimMax)
- {
- //For structure which infinite in all three dimensions the Whole bounding box will be returned
- aResult.SetWhole();
- }
+ return Bnd_Box();
}
- return aResult;
-}
-//=============================================================================
-//function : Identification
-//purpose :
-//=============================================================================
-Standard_Integer Graphic3d_Structure::Identification() const
-{
- return myCStructure->Id;
-}
+ Bnd_Box aResult;
+ aResult.Update (aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
+ aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
-//=============================================================================
-//function : SetTransformPersistence
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::SetTransformPersistence (const Graphic3d_TransModeFlags& theFlag)
-{
- SetTransformPersistence (theFlag, gp_Pnt (0.0, 0.0, 0.0));
+ Standard_Real aLimMin = ShortRealFirst() + 1.0;
+ Standard_Real aLimMax = ShortRealLast() - 1.0;
+ gp_Pnt aMin = aResult.CornerMin();
+ gp_Pnt aMax = aResult.CornerMax();
+ if (aMin.X() < aLimMin && aMin.Y() < aLimMin && aMin.Z() < aLimMin
+ && aMax.X() > aLimMax && aMax.Y() > aLimMax && aMax.Z() > aLimMax)
+ {
+ //For structure which infinite in all three dimensions the Whole bounding box will be returned
+ aResult.SetWhole();
+ }
+ return aResult;
}
//=============================================================================
//function : SetTransformPersistence
//purpose :
//=============================================================================
-void Graphic3d_Structure::SetTransformPersistence (const Graphic3d_TransModeFlags& theFlag,
- const gp_Pnt& thePoint)
+void Graphic3d_Structure::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
- if (IsDeleted()) return;
-
- myCStructure->TransformPersistence.Flags = theFlag;
- myCStructure->TransformPersistence.Point.x() = thePoint.X();
- myCStructure->TransformPersistence.Point.y() = thePoint.Y();
- myCStructure->TransformPersistence.Point.z() = thePoint.Z();
-}
+ if (IsDeleted())
+ {
+ return;
+ }
-//=============================================================================
-//function : TransformPersistenceMode
-//purpose :
-//=============================================================================
-Graphic3d_TransModeFlags Graphic3d_Structure::TransformPersistenceMode() const
-{
- return myCStructure->TransformPersistence.Flags;
-}
-
-//=============================================================================
-//function : TransformPersistencePoint
-//purpose :
-//=============================================================================
-gp_Pnt Graphic3d_Structure::TransformPersistencePoint() const
-{
- gp_Pnt aPnt (0.0, 0.0, 0.0);
- aPnt.SetX (myCStructure->TransformPersistence.Point.x());
- aPnt.SetY (myCStructure->TransformPersistence.Point.y());
- aPnt.SetZ (myCStructure->TransformPersistence.Point.z());
- return aPnt;
+ myCStructure->SetTransformPersistence (theTrsfPers);
}
//=============================================================================
//function : Remove
//purpose :
//=============================================================================
-void Graphic3d_Structure::Remove (const Standard_Address thePtr,
+void Graphic3d_Structure::Remove (Graphic3d_Structure* thePtr,
const Graphic3d_TypeOfConnection theType)
{
if (theType == Graphic3d_TOC_DESCENDANT)
//function : addTransformed
//purpose :
//=============================================================================
-void Graphic3d_Structure::getBox (Graphic3d_BndBox4d& theBox,
+void Graphic3d_Structure::getBox (Graphic3d_BndBox3d& theBox,
const Standard_Boolean theToIgnoreInfiniteFlag) const
{
Graphic3d_BndBox4f aBoxF = minMaxCoord();
if (aBoxF.IsValid())
{
- theBox = Graphic3d_BndBox4d (Graphic3d_Vec4d ((Standard_Real )aBoxF.CornerMin().x(),
+ theBox = Graphic3d_BndBox3d (Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMin().x(),
(Standard_Real )aBoxF.CornerMin().y(),
- (Standard_Real )aBoxF.CornerMin().z(),
- (Standard_Real )aBoxF.CornerMin().w()),
- Graphic3d_Vec4d ((Standard_Real )aBoxF.CornerMax().x(),
+ (Standard_Real )aBoxF.CornerMin().z()),
+ Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMax().x(),
(Standard_Real )aBoxF.CornerMax().y(),
- (Standard_Real )aBoxF.CornerMax().z(),
- (Standard_Real )aBoxF.CornerMax().w()));
+ (Standard_Real )aBoxF.CornerMax().z()));
if (IsInfinite()
&& !theToIgnoreInfiniteFlag)
{
- const Graphic3d_Vec4d aDiagVec = theBox.CornerMax() - theBox.CornerMin();
- if (aDiagVec.xyz().SquareModulus() >= 500000.0 * 500000.0)
+ const Graphic3d_Vec3d aDiagVec = theBox.CornerMax() - theBox.CornerMin();
+ if (aDiagVec.SquareModulus() >= 500000.0 * 500000.0)
{
// bounding borders of infinite line has been calculated as own point in center of this line
- theBox = Graphic3d_BndBox4d ((theBox.CornerMin() + theBox.CornerMax()) * 0.5);
+ theBox = Graphic3d_BndBox3d ((theBox.CornerMin() + theBox.CornerMax()) * 0.5);
}
else
{
- theBox = Graphic3d_BndBox4d (Graphic3d_Vec4d (RealFirst(), RealFirst(), RealFirst(), 1.0),
- Graphic3d_Vec4d (RealLast(), RealLast(), RealLast(), 1.0));
+ theBox = Graphic3d_BndBox3d (Graphic3d_Vec3d (RealFirst(), RealFirst(), RealFirst()),
+ Graphic3d_Vec3d (RealLast(), RealLast(), RealLast()));
return;
}
}
//function : addTransformed
//purpose :
//=============================================================================
-void Graphic3d_Structure::addTransformed (Graphic3d_BndBox4d& theBox,
+void Graphic3d_Structure::addTransformed (Graphic3d_BndBox3d& theBox,
const Standard_Boolean theToIgnoreInfiniteFlag) const
{
- Graphic3d_BndBox4d aCombinedBox, aBox;
+ Graphic3d_BndBox3d aCombinedBox, aBox;
getBox (aCombinedBox, theToIgnoreInfiniteFlag);
- for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
+ for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
{
- const Graphic3d_Structure* aStruct = (const Graphic3d_Structure* )anIter.Value();
+ const Graphic3d_Structure* aStruct = anIter.Value();
aStruct->getBox (aBox, theToIgnoreInfiniteFlag);
aCombinedBox.Combine (aBox);
}
aBox = aCombinedBox;
if (aBox.IsValid())
{
- TColStd_Array2OfReal aTrsf (0, 3, 0, 3);
- Transform (aTrsf);
- TransformBoundaries (aTrsf, aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
- aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
+ if (!myCStructure->Transformation().IsNull())
+ {
+ TransformBoundaries (myCStructure->Transformation()->Trsf(),
+ aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
+ aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
+ }
// if box is still valid after transformation
if (aBox.IsValid())
//function : Transforms
//purpose :
//=============================================================================
-void Graphic3d_Structure::Transforms (const TColStd_Array2OfReal& theTrsf,
+void Graphic3d_Structure::Transforms (const gp_Trsf& theTrsf,
const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ,
Standard_Real& theNewX, Standard_Real& theNewY, Standard_Real& theNewZ)
{
const Standard_Real aRL = RealLast();
const Standard_Real aRF = RealFirst();
+ theNewX = theX;
+ theNewY = theY;
+ theNewZ = theZ;
if ((theX == aRF) || (theY == aRF) || (theZ == aRF)
|| (theX == aRL) || (theY == aRL) || (theZ == aRL))
{
- theNewX = theX;
- theNewY = theY;
- theNewZ = theZ;
- }
- else
- {
- Standard_Real A, B, C, D;
- A = theTrsf (0, 0);
- B = theTrsf (0, 1);
- C = theTrsf (0, 2);
- D = theTrsf (0, 3);
- theNewX = A * theX + B * theY + C * theZ + D;
- A = theTrsf (1, 0);
- B = theTrsf (1, 1);
- C = theTrsf (1, 2);
- D = theTrsf (1, 3);
- theNewY = A * theX + B * theY + C * theZ + D;
- A = theTrsf (2, 0);
- B = theTrsf (2, 1);
- C = theTrsf (2, 2);
- D = theTrsf (2, 3);
- theNewZ = A * theX + B * theY + C * theZ + D;
+ return;
}
-}
-//=============================================================================
-//function : Transforms
-//purpose :
-//=============================================================================
-Graphic3d_Vector Graphic3d_Structure::Transforms (const TColStd_Array2OfReal& theTrsf,
- const Graphic3d_Vector& theCoord)
-{
- Standard_Real anXYZ[3];
- Graphic3d_Structure::Transforms (theTrsf,
- theCoord.X(), theCoord.Y(), theCoord.Z(),
- anXYZ[0], anXYZ[1], anXYZ[2]);
- return Graphic3d_Vector (anXYZ[0], anXYZ[1], anXYZ[2]);
-}
-
-//=============================================================================
-//function : Transforms
-//purpose :
-//=============================================================================
-Graphic3d_Vertex Graphic3d_Structure::Transforms (const TColStd_Array2OfReal& theTrsf,
- const Graphic3d_Vertex& theCoord)
-{
- Standard_Real anXYZ[3];
- Graphic3d_Structure::Transforms (theTrsf,
- theCoord.X(), theCoord.Y(), theCoord.Z(),
- anXYZ[0], anXYZ[1], anXYZ[2]);
- return Graphic3d_Vertex (anXYZ[0], anXYZ[1], anXYZ[2]);
+ theTrsf.Transforms (theNewX, theNewY, theNewZ);
}
//=============================================================================
//function : Transforms
//purpose :
//=============================================================================
-void Graphic3d_Structure::TransformBoundaries (const TColStd_Array2OfReal& theTrsf,
+void Graphic3d_Structure::TransformBoundaries (const gp_Trsf& theTrsf,
Standard_Real& theXMin,
Standard_Real& theYMin,
Standard_Real& theZMin,
//function : Network
//purpose :
//=============================================================================
-void Graphic3d_Structure::Network (const Handle(Graphic3d_Structure)& theStructure,
- const Graphic3d_TypeOfConnection theType,
- Graphic3d_MapOfStructure& theSet)
+void Graphic3d_Structure::Network (Graphic3d_Structure* theStructure,
+ const Graphic3d_TypeOfConnection theType,
+ NCollection_Map<Graphic3d_Structure*>& theSet)
{
- Graphic3d_MapOfStructure aSetD, aSetA;
- theStructure->Descendants (aSetD);
- theStructure->Ancestors (aSetA);
theSet.Add (theStructure);
switch (theType)
{
case Graphic3d_TOC_DESCENDANT:
- for (Graphic3d_MapIteratorOfMapOfStructure anIter (aSetD); anIter.More(); anIter.Next())
+ {
+ for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (theStructure->myDescendants); anIter.More(); anIter.Next())
{
- Graphic3d_Structure::Network (anIter.Key(), theType, theSet);
+ Graphic3d_Structure::Network (anIter.Value(), theType, theSet);
}
break;
+ }
case Graphic3d_TOC_ANCESTOR:
- for (Graphic3d_MapIteratorOfMapOfStructure anIter (aSetA); anIter.More(); anIter.Next())
+ {
+ for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (theStructure->myAncestors); anIter.More(); anIter.Next())
{
- Graphic3d_Structure::Network (anIter.Key (), theType, theSet);
+ Graphic3d_Structure::Network (anIter.Value(), theType, theSet);
}
break;
+ }
}
}
void Graphic3d_Structure::PrintNetwork (const Handle(Graphic3d_Structure)& theStructure,
const Graphic3d_TypeOfConnection theType)
{
- Graphic3d_MapOfStructure aSet;
- Graphic3d_Structure::Network (theStructure, theType, aSet);
- for (Graphic3d_MapIteratorOfMapOfStructure anIter (aSet); anIter.More(); anIter.Next())
+ NCollection_Map<Graphic3d_Structure*> aSet;
+ Graphic3d_Structure::Network (theStructure.get(), theType, aSet);
+ for (NCollection_Map<Graphic3d_Structure*>::Iterator anIter (aSet); anIter.More(); anIter.Next())
{
std::cout << "\tIdent " << (anIter.Key())->Identification () << "\n";
}
return;
}
- myStructureManager->Update (myStructureManager->UpdateMode(),
- theUpdateLayer ? myCStructure->ZLayer() : Graphic3d_ZLayerId_UNKNOWN);
-}
-
-//=============================================================================
-//function : GraphicHighlight
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::GraphicHighlight (const Aspect_TypeOfHighlightMethod theMethod)
-{
- Standard_Real anRGB[3];
- myCStructure->highlight = 1;
- myHighlightMethod = theMethod;
- switch (theMethod)
- {
- case Aspect_TOHM_COLOR:
- {
- myHighlightColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB);
- myCStructure->HighlightWithColor (Graphic3d_Vec3 (float (anRGB[0]), float (anRGB[1]), float (anRGB[2])), Standard_True);
- break;
- }
- case Aspect_TOHM_BOUNDBOX:
- {
- myHighlightColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB);
- myCStructure->HighlightColor.r = float (anRGB[0]);
- myCStructure->HighlightColor.g = float (anRGB[1]);
- myCStructure->HighlightColor.b = float (anRGB[2]);
- myCStructure->HighlightWithBndBox (this, Standard_True);
- break;
- }
- }
-}
-
-//=============================================================================
-//function : GraphicTransform
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::GraphicTransform (const TColStd_Array2OfReal& theMatrix)
-{
- for (Standard_Integer i = 0; i <= 3; ++i)
- {
- for (Standard_Integer j = 0; j <= 3; ++j)
- {
- myCStructure->Transformation.ChangeValue (i, j) = float (theMatrix (i, j));
- }
- }
- myCStructure->UpdateTransformation();
-}
-
-//=============================================================================
-//function : GraphicUnHighlight
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::GraphicUnHighlight()
-{
- myCStructure->highlight = 0;
- switch (myHighlightMethod)
- {
- case Aspect_TOHM_COLOR:
- myCStructure->HighlightWithColor (Graphic3d_Vec3 (0.0f, 0.0f, 0.0f), Standard_False);
- break;
- case Aspect_TOHM_BOUNDBOX:
- myCStructure->HighlightWithBndBox (this, Standard_False);
- break;
- }
-}
-
-//=============================================================================
-//function : ComputeVisual
-//purpose :
-//=============================================================================
-Graphic3d_TypeOfStructure Graphic3d_Structure::ComputeVisual() const
-{
- return myComputeVisual;
-}
-
-//=============================================================================
-//function : SetComputeVisual
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::SetComputeVisual (const Graphic3d_TypeOfStructure theVisual)
-{
- // The ComputeVisual is saved only if the structure is declared TOS_ALL, TOS_WIREFRAME or TOS_SHADING.
- // This declaration permits to calculate proper representation of the structure calculated by Compute instead of passage to TOS_COMPUTED.
- if (theVisual != Graphic3d_TOS_COMPUTED)
- {
- myComputeVisual = theVisual;
- }
-}
-
-//=============================================================================
-//function : SetHLRValidation
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::SetHLRValidation (const Standard_Boolean theFlag)
-{
- myCStructure->HLRValidation = theFlag ? 1 : 0;
-}
-
-//=============================================================================
-//function : HLRValidation
-//purpose :
-//=============================================================================
-Standard_Boolean Graphic3d_Structure::HLRValidation() const
-{
- // Hidden parts stored in <me> are valid if :
- // 1/ the owner is defined.
- // 2/ they are not invalid.
- return myOwner != NULL
- && myCStructure->HLRValidation != 0;
+ myStructureManager->Update (theUpdateLayer ? myCStructure->ZLayer() : Graphic3d_ZLayerId_UNKNOWN);
}
//=======================================================================
}
//=======================================================================
-//function : GetZLayer
-//purpose :
+//function : DumpJson
+//purpose :
//=======================================================================
-Graphic3d_ZLayerId Graphic3d_Structure::GetZLayer() const
+void Graphic3d_Structure::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
{
- return myCStructure->ZLayer();
-}
+ OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
-//=======================================================================
-//function : SetClipPlanes
-//purpose :
-//=======================================================================
-void Graphic3d_Structure::SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes)
-{
- myCStructure->SetClipPlanes (thePlanes);
-}
-
-//=======================================================================
-//function : GetClipPlanes
-//purpose :
-//=======================================================================
-const Graphic3d_SequenceOfHClipPlane& Graphic3d_Structure::GetClipPlanes() const
-{
- return myCStructure->ClipPlanes();
-}
+ OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myCStructure.get())
-//=======================================================================
-//function : SetMutable
-//purpose :
-//=======================================================================
-void Graphic3d_Structure::SetMutable (const Standard_Boolean theIsMutable)
-{
- myCStructure->IsMutable = theIsMutable;
-}
-
-//=======================================================================
-//function : IsMutable
-//purpose :
-//=======================================================================
-Standard_Boolean Graphic3d_Structure::IsMutable() const
-{
- return myCStructure->IsMutable;
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myVisual)
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myComputeVisual)
}