1 // Created by: NW,JPB,CAL
2 // Copyright (c) 1991-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <Graphic3d_Structure.hxx>
18 #include <Bnd_Box.hxx>
20 #include <Graphic3d_GraphicDriver.hxx>
21 #include <Graphic3d_Group.hxx>
22 #include <Graphic3d_MapOfStructure.hxx>
23 #include <Graphic3d_PriorityDefinitionError.hxx>
24 #include <Graphic3d_StructureDefinitionError.hxx>
25 #include <Graphic3d_StructureManager.hxx>
27 #include <Standard_Dump.hxx>
31 IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Structure,Standard_Transient)
33 //=============================================================================
34 //function : Graphic3d_Structure
36 //=============================================================================
37 Graphic3d_Structure::Graphic3d_Structure (const Handle(Graphic3d_StructureManager)& theManager,
38 const Handle(Graphic3d_Structure)& theLinkPrs)
39 : myStructureManager(theManager.get()),
41 myVisual (Graphic3d_TOS_ALL),
42 myComputeVisual (Graphic3d_TOS_ALL)
44 if (!theLinkPrs.IsNull())
46 myOwner = theLinkPrs->myOwner;
47 if (theLinkPrs->myVisual != Graphic3d_TOS_COMPUTED)
49 myVisual = theLinkPrs->myVisual;
51 myComputeVisual = theLinkPrs->myComputeVisual;
52 myCStructure = theLinkPrs->myCStructure->ShadowLink (theManager);
56 myCStructure = theManager->GraphicDriver()->CreateStructure (theManager);
60 //=============================================================================
61 //function : ~Graphic3d_Structure
63 //=============================================================================
64 Graphic3d_Structure::~Graphic3d_Structure()
66 // as myStructureManager can be already destroyed,
67 // avoid attempts to access it
68 myStructureManager = NULL;
72 //=============================================================================
75 //=============================================================================
76 void Graphic3d_Structure::clear (const Standard_Boolean theWithDestruction)
78 if (IsDeleted()) return;
80 // clean groups in graphics driver at first
81 GraphicClear (theWithDestruction);
83 myCStructure->SetGroupTransformPersistence (false);
84 myStructureManager->Clear (this, theWithDestruction);
89 //=======================================================================
90 //function : CalculateBoundBox
91 //purpose : Calculates AABB of a structure.
92 //=======================================================================
93 void Graphic3d_Structure::CalculateBoundBox()
95 Graphic3d_BndBox3d aBox;
96 addTransformed (aBox, Standard_True);
97 myCStructure->ChangeBoundingBox() = aBox;
100 //=============================================================================
103 //=============================================================================
104 void Graphic3d_Structure::Remove()
106 if (IsDeleted()) return;
108 // clean groups in graphics driver at first; this is also should be done
109 // to avoid unwanted group cleaning in group's destructor
110 // Pass Standard_False to Clear(..) method to avoid updating in
111 // structure manager, it isn't necessary, besides of it structure manager
112 // could be already destroyed and invalid pointers used in structure;
113 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
115 aGroupIter.ChangeValue()->Clear (Standard_False);
118 // It is necessary to remove the eventual pointer on the structure that can be destroyed, in the list of descendants
119 // of ancestors of this structure and in the list of ancestors of descendants of the same structure.
120 for (Standard_Integer aStructIdx = 1, aNbDesc = myDescendants.Size(); aStructIdx <= aNbDesc; ++aStructIdx)
122 myDescendants.FindKey (aStructIdx)->Remove (this, Graphic3d_TOC_ANCESTOR);
125 for (Standard_Integer aStructIdx = 1, aNbAnces = myAncestors.Size(); aStructIdx <= aNbAnces; ++aStructIdx)
127 myAncestors.FindKey (aStructIdx)->Remove (this, Graphic3d_TOC_DESCENDANT);
130 // Destruction of me in the graphic library
131 const Standard_Integer aStructId = myCStructure->Identification();
132 myCStructure->GraphicDriver()->RemoveIdentification(aStructId);
133 myCStructure->GraphicDriver()->RemoveStructure (myCStructure);
134 myCStructure.Nullify();
137 //=============================================================================
140 //=============================================================================
141 void Graphic3d_Structure::Display()
143 if (IsDeleted()) return;
145 if (!myCStructure->stick)
147 myCStructure->stick = 1;
148 myStructureManager->Display (this);
151 if (myCStructure->visible != 1)
153 myCStructure->visible = 1;
154 myCStructure->OnVisibilityChanged();
158 //=============================================================================
159 //function : SetDisplayPriority
161 //=============================================================================
162 void Graphic3d_Structure::SetDisplayPriority (const Graphic3d_DisplayPriority thePriority)
165 || thePriority == myCStructure->Priority())
170 Graphic3d_PriorityDefinitionError_Raise_if ((thePriority > Graphic3d_DisplayPriority_Topmost)
171 || (thePriority < Graphic3d_DisplayPriority_Bottom),
172 "Bad value for StructurePriority");
174 myCStructure->SetPreviousPriority (myCStructure->Priority());
175 myCStructure->SetPriority (thePriority);
176 if (myCStructure->Priority() != myCStructure->PreviousPriority())
178 if (myCStructure->stick)
180 myStructureManager->ChangeDisplayPriority (this, myCStructure->PreviousPriority(), myCStructure->Priority());
185 //=============================================================================
186 //function : ResetDisplayPriority
188 //=============================================================================
189 void Graphic3d_Structure::ResetDisplayPriority()
192 || myCStructure->Priority() == myCStructure->PreviousPriority())
197 const Graphic3d_DisplayPriority aPriority = myCStructure->Priority();
198 myCStructure->SetPriority (myCStructure->PreviousPriority());
199 if (myCStructure->stick)
201 myStructureManager->ChangeDisplayPriority (this, aPriority, myCStructure->Priority());
205 //=============================================================================
208 //=============================================================================
209 void Graphic3d_Structure::erase()
216 if (myCStructure->stick)
218 myCStructure->stick = 0;
219 myStructureManager->Erase (this);
223 //=============================================================================
224 //function : Highlight
226 //=============================================================================
227 void Graphic3d_Structure::Highlight (const Handle(Graphic3d_PresentationAttributes)& theStyle,
228 const Standard_Boolean theToUpdateMgr)
235 SetDisplayPriority (Graphic3d_DisplayPriority_Highlight);
236 myCStructure->GraphicHighlight (theStyle);
242 if (myCStructure->stick)
244 myStructureManager->Highlight (this);
250 //=============================================================================
251 //function : SetVisible
253 //=============================================================================
254 void Graphic3d_Structure::SetVisible (const Standard_Boolean theValue)
256 if (IsDeleted()) return;
258 const unsigned isVisible = theValue ? 1 : 0;
259 if (myCStructure->visible == isVisible)
264 myCStructure->visible = isVisible;
265 myCStructure->OnVisibilityChanged();
269 //=============================================================================
270 //function : UnHighlight
272 //=============================================================================
273 void Graphic3d_Structure::UnHighlight()
275 if (IsDeleted()) return;
277 if (myCStructure->highlight)
279 myCStructure->highlight = 0;
281 myCStructure->GraphicUnhighlight();
282 myStructureManager->UnHighlight (this);
284 ResetDisplayPriority();
289 //=============================================================================
292 //=============================================================================
293 Standard_Boolean Graphic3d_Structure::IsEmpty() const
297 return Standard_True;
300 // structure is empty:
301 // - if all these groups are empty
302 // - or if all groups are empty and all their descendants are empty
303 // - or if all its descendants are empty
304 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
306 if (!aGroupIter.Value()->IsEmpty())
308 return Standard_False;
312 // stop at the first non-empty descendant
313 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
315 if (!anIter.Value()->IsEmpty())
317 return Standard_False;
320 return Standard_True;
323 //=============================================================================
324 //function : ReCompute
326 //=============================================================================
327 void Graphic3d_Structure::ReCompute()
329 myStructureManager->ReCompute (this);
332 //=============================================================================
333 //function : ReCompute
335 //=============================================================================
336 void Graphic3d_Structure::ReCompute (const Handle(Graphic3d_DataStructureManager)& theProjector)
338 myStructureManager->ReCompute (this, theProjector);
341 //=============================================================================
342 //function : GraphicClear
344 //=============================================================================
345 void Graphic3d_Structure::GraphicClear (const Standard_Boolean theWithDestruction)
347 if (myCStructure.IsNull())
352 // clean and empty each group
353 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
355 aGroupIter.ChangeValue()->Clear();
357 if (!theWithDestruction)
362 while (!myCStructure->Groups().IsEmpty())
364 Handle(Graphic3d_Group) aGroup = myCStructure->Groups().First();
367 myCStructure->Clear();
370 //=============================================================================
371 //function : SetVisual
373 //=============================================================================
374 void Graphic3d_Structure::SetVisual (const Graphic3d_TypeOfStructure theVisual)
377 || myVisual == theVisual)
382 if (!myCStructure->stick)
384 myVisual = theVisual;
385 SetComputeVisual (theVisual);
390 myVisual = theVisual;
391 SetComputeVisual (theVisual);
396 //=============================================================================
397 //function : SetZoomLimit
399 //=============================================================================
400 void Graphic3d_Structure::SetZoomLimit (const Standard_Real theLimitInf,
401 const Standard_Real theLimitSup)
405 Graphic3d_StructureDefinitionError_Raise_if (theLimitInf <= 0.0,
406 "Bad value for ZoomLimit inf");
407 Graphic3d_StructureDefinitionError_Raise_if (theLimitSup <= 0.0,
408 "Bad value for ZoomLimit sup");
409 Graphic3d_StructureDefinitionError_Raise_if (theLimitSup < theLimitInf,
410 "ZoomLimit sup < ZoomLimit inf");
413 //=============================================================================
414 //function : AcceptConnection
416 //=============================================================================
417 Standard_Boolean Graphic3d_Structure::AcceptConnection (Graphic3d_Structure* theStructure1,
418 Graphic3d_Structure* theStructure2,
419 Graphic3d_TypeOfConnection theType)
422 NCollection_Map<Graphic3d_Structure*> aSet;
423 Graphic3d_Structure::Network (theStructure2, theType, aSet);
424 return !aSet.Contains (theStructure1);
427 //=============================================================================
428 //function : Ancestors
430 //=============================================================================
431 void Graphic3d_Structure::Ancestors (Graphic3d_MapOfStructure& theSet) const
433 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myAncestors); anIter.More(); anIter.Next())
435 theSet.Add (anIter.Value());
439 //=============================================================================
440 //function : Descendants
442 //=============================================================================
443 void Graphic3d_Structure::Descendants (Graphic3d_MapOfStructure& theSet) const
445 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
447 theSet.Add (anIter.Value());
451 //=============================================================================
452 //function : AppendAncestor
454 //=============================================================================
455 Standard_Boolean Graphic3d_Structure::AppendAncestor (Graphic3d_Structure* theAncestor)
457 const Standard_Integer aSize = myAncestors.Size();
459 return myAncestors.Add (theAncestor) > aSize; // new object
462 //=============================================================================
463 //function : AppendDescendant
465 //=============================================================================
466 Standard_Boolean Graphic3d_Structure::AppendDescendant (Graphic3d_Structure* theDescendant)
468 const Standard_Integer aSize = myDescendants.Size();
470 return myDescendants.Add (theDescendant) > aSize; // new object
473 //=============================================================================
474 //function : RemoveAncestor
476 //=============================================================================
477 Standard_Boolean Graphic3d_Structure::RemoveAncestor (Graphic3d_Structure* theAncestor)
479 const Standard_Integer anIndex = myAncestors.FindIndex (theAncestor);
483 myAncestors.Swap (anIndex, myAncestors.Size());
484 myAncestors.RemoveLast();
487 return anIndex != 0; // object was found
490 //=============================================================================
491 //function : RemoveDescendant
493 //=============================================================================
494 Standard_Boolean Graphic3d_Structure::RemoveDescendant (Graphic3d_Structure* theDescendant)
496 const Standard_Integer anIndex = myDescendants.FindIndex (theDescendant);
500 myDescendants.Swap (anIndex, myDescendants.Size());
501 myDescendants.RemoveLast();
504 return anIndex != 0; // object was found
507 //=============================================================================
510 //=============================================================================
511 void Graphic3d_Structure::Connect (Graphic3d_Structure* theStructure,
512 Graphic3d_TypeOfConnection theType,
513 Standard_Boolean theWithCheck)
522 && !Graphic3d_Structure::AcceptConnection (this, theStructure, theType))
527 if (theType == Graphic3d_TOC_DESCENDANT)
529 if (!AppendDescendant (theStructure))
535 theStructure->Connect (this, Graphic3d_TOC_ANCESTOR);
537 GraphicConnect (theStructure);
538 myStructureManager->Connect (this, theStructure);
542 else // Graphic3d_TOC_ANCESTOR
544 if (!AppendAncestor (theStructure))
550 theStructure->Connect (this, Graphic3d_TOC_DESCENDANT);
552 // myStructureManager->Connect is called in case if connection between parent and child
556 //=============================================================================
557 //function : Disconnect
559 //=============================================================================
560 void Graphic3d_Structure::Disconnect (Graphic3d_Structure* theStructure)
567 if (RemoveDescendant (theStructure))
569 theStructure->Disconnect (this);
571 GraphicDisconnect (theStructure);
572 myStructureManager->Disconnect (this, theStructure);
577 else if (RemoveAncestor (theStructure))
579 theStructure->Disconnect (this);
582 // no call of myStructureManager->Disconnect in case of an ancestor
586 //=============================================================================
587 //function : DisconnectAll
589 //=============================================================================
590 void Graphic3d_Structure::DisconnectAll (const Graphic3d_TypeOfConnection theType)
592 if (IsDeleted()) return;
596 case Graphic3d_TOC_DESCENDANT:
598 for (Standard_Integer anIdx = 1, aLength = myDescendants.Size(); anIdx <= aLength; ++anIdx)
600 // Value (1) instead of Value (i) as myDescendants
602 // Graphic3d_Structure::Disconnect (AStructure)
603 // that takes AStructure from myDescendants
604 myDescendants.FindKey (1)->Disconnect (this);
608 case Graphic3d_TOC_ANCESTOR:
610 for (Standard_Integer anIdx = 1, aLength = myAncestors.Size(); anIdx <= aLength; ++anIdx)
612 // Value (1) instead of Value (i) as myAncestors
614 // Graphic3d_Structure::Disconnect (AStructure)
615 // that takes AStructure from myAncestors
616 myAncestors.FindKey (1)->Disconnect (this);
623 //=============================================================================
624 //function : SetTransform
626 //=============================================================================
627 void Graphic3d_Structure::SetTransformation (const Handle(TopLoc_Datum3D)& theTrsf)
629 if (IsDeleted()) return;
631 const Standard_Boolean wasTransformed = IsTransformed();
633 if (!theTrsf.IsNull()
634 && theTrsf->Trsf().Form() == gp_Identity)
636 myCStructure->SetTransformation (Handle(TopLoc_Datum3D)());
640 myCStructure->SetTransformation (theTrsf);
643 // If transformation, no validation of hidden already calculated parts
644 if (IsTransformed() || (!IsTransformed() && wasTransformed))
649 myStructureManager->SetTransform (this, theTrsf);
654 //=============================================================================
655 //function : MinMaxValues
657 //=============================================================================
658 Bnd_Box Graphic3d_Structure::MinMaxValues (const Standard_Boolean theToIgnoreInfiniteFlag) const
660 Graphic3d_BndBox3d aBox;
661 addTransformed (aBox, theToIgnoreInfiniteFlag);
668 aResult.Update (aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
669 aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
671 Standard_Real aLimMin = ShortRealFirst() + 1.0;
672 Standard_Real aLimMax = ShortRealLast() - 1.0;
673 gp_Pnt aMin = aResult.CornerMin();
674 gp_Pnt aMax = aResult.CornerMax();
675 if (aMin.X() < aLimMin && aMin.Y() < aLimMin && aMin.Z() < aLimMin
676 && aMax.X() > aLimMax && aMax.Y() > aLimMax && aMax.Z() > aLimMax)
678 //For structure which infinite in all three dimensions the Whole bounding box will be returned
684 //=============================================================================
685 //function : SetTransformPersistence
687 //=============================================================================
688 void Graphic3d_Structure::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
695 myCStructure->SetTransformPersistence (theTrsfPers);
698 //=============================================================================
701 //=============================================================================
702 void Graphic3d_Structure::Remove (Graphic3d_Structure* thePtr,
703 const Graphic3d_TypeOfConnection theType)
705 if (theType == Graphic3d_TOC_DESCENDANT)
707 RemoveDescendant (thePtr);
711 RemoveAncestor (thePtr);
715 //=============================================================================
716 //function : NewGroup
718 //=============================================================================
719 Handle(Graphic3d_Group) Graphic3d_Structure::NewGroup()
721 return myCStructure->NewGroup (this);
724 //=============================================================================
727 //=============================================================================
728 void Graphic3d_Structure::Remove (const Handle(Graphic3d_Group)& theGroup)
730 if (theGroup.IsNull()
731 || theGroup->myStructure != this)
736 myCStructure->RemoveGroup (theGroup);
737 theGroup->myStructure = NULL;
740 //=============================================================================
741 //function : StructureManager
743 //=============================================================================
744 Handle(Graphic3d_StructureManager) Graphic3d_Structure::StructureManager() const
746 return myStructureManager;
749 //=============================================================================
750 //function : minMaxCoord
752 //=============================================================================
753 Graphic3d_BndBox4f Graphic3d_Structure::minMaxCoord() const
755 Graphic3d_BndBox4f aBnd;
756 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
758 if (!aGroupIter.Value()->TransformPersistence().IsNull())
760 continue; // should be translated to current view orientation to make sense
763 aBnd.Combine (aGroupIter.Value()->BoundingBox());
768 //=============================================================================
769 //function : addTransformed
771 //=============================================================================
772 void Graphic3d_Structure::getBox (Graphic3d_BndBox3d& theBox,
773 const Standard_Boolean theToIgnoreInfiniteFlag) const
775 Graphic3d_BndBox4f aBoxF = minMaxCoord();
778 theBox = Graphic3d_BndBox3d (Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMin().x(),
779 (Standard_Real )aBoxF.CornerMin().y(),
780 (Standard_Real )aBoxF.CornerMin().z()),
781 Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMax().x(),
782 (Standard_Real )aBoxF.CornerMax().y(),
783 (Standard_Real )aBoxF.CornerMax().z()));
785 && !theToIgnoreInfiniteFlag)
787 const Graphic3d_Vec3d aDiagVec = theBox.CornerMax() - theBox.CornerMin();
788 if (aDiagVec.SquareModulus() >= 500000.0 * 500000.0)
790 // bounding borders of infinite line has been calculated as own point in center of this line
791 theBox = Graphic3d_BndBox3d ((theBox.CornerMin() + theBox.CornerMax()) * 0.5);
795 theBox = Graphic3d_BndBox3d (Graphic3d_Vec3d (RealFirst(), RealFirst(), RealFirst()),
796 Graphic3d_Vec3d (RealLast(), RealLast(), RealLast()));
803 //=============================================================================
804 //function : addTransformed
806 //=============================================================================
807 void Graphic3d_Structure::addTransformed (Graphic3d_BndBox3d& theBox,
808 const Standard_Boolean theToIgnoreInfiniteFlag) const
810 Graphic3d_BndBox3d aCombinedBox, aBox;
811 getBox (aCombinedBox, theToIgnoreInfiniteFlag);
813 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
815 const Graphic3d_Structure* aStruct = anIter.Value();
816 aStruct->getBox (aBox, theToIgnoreInfiniteFlag);
817 aCombinedBox.Combine (aBox);
823 if (!myCStructure->Transformation().IsNull())
825 TransformBoundaries (myCStructure->Transformation()->Trsf(),
826 aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
827 aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
830 // if box is still valid after transformation
833 theBox.Combine (aBox);
835 else // it was infinite, return untransformed
837 theBox.Combine (aCombinedBox);
842 //=============================================================================
843 //function : Transforms
845 //=============================================================================
846 void Graphic3d_Structure::Transforms (const gp_Trsf& theTrsf,
847 const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ,
848 Standard_Real& theNewX, Standard_Real& theNewY, Standard_Real& theNewZ)
850 const Standard_Real aRL = RealLast();
851 const Standard_Real aRF = RealFirst();
855 if ((theX == aRF) || (theY == aRF) || (theZ == aRF)
856 || (theX == aRL) || (theY == aRL) || (theZ == aRL))
861 theTrsf.Transforms (theNewX, theNewY, theNewZ);
864 //=============================================================================
865 //function : Transforms
867 //=============================================================================
868 void Graphic3d_Structure::TransformBoundaries (const gp_Trsf& theTrsf,
869 Standard_Real& theXMin,
870 Standard_Real& theYMin,
871 Standard_Real& theZMin,
872 Standard_Real& theXMax,
873 Standard_Real& theYMax,
874 Standard_Real& theZMax)
876 Standard_Real aXMin, aYMin, aZMin, aXMax, aYMax, aZMax, anU, aV, aW;
878 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMin, theZMin, aXMin, aYMin, aZMin);
879 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMax, theZMax, aXMax, aYMax, aZMax);
881 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMin, theZMax, anU, aV, aW);
882 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
883 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
884 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
886 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMin, theZMax, anU, aV, aW);
887 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
888 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
889 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
891 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMin, theZMin, anU, aV, aW);
892 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
893 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
894 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
896 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMax, theZMin, anU, aV, aW);
897 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
898 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
899 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
901 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMax, theZMax, anU, aV, aW);
902 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
903 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
904 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
906 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMax, theZMin, anU, aV, aW);
907 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
908 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
909 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
919 //=============================================================================
922 //=============================================================================
923 void Graphic3d_Structure::Network (Graphic3d_Structure* theStructure,
924 const Graphic3d_TypeOfConnection theType,
925 NCollection_Map<Graphic3d_Structure*>& theSet)
927 theSet.Add (theStructure);
930 case Graphic3d_TOC_DESCENDANT:
932 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (theStructure->myDescendants); anIter.More(); anIter.Next())
934 Graphic3d_Structure::Network (anIter.Value(), theType, theSet);
938 case Graphic3d_TOC_ANCESTOR:
940 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (theStructure->myAncestors); anIter.More(); anIter.Next())
942 Graphic3d_Structure::Network (anIter.Value(), theType, theSet);
949 //=============================================================================
950 //function : PrintNetwork
952 //=============================================================================
953 void Graphic3d_Structure::PrintNetwork (const Handle(Graphic3d_Structure)& theStructure,
954 const Graphic3d_TypeOfConnection theType)
956 NCollection_Map<Graphic3d_Structure*> aSet;
957 Graphic3d_Structure::Network (theStructure.get(), theType, aSet);
958 for (NCollection_Map<Graphic3d_Structure*>::Iterator anIter (aSet); anIter.More(); anIter.Next())
960 std::cout << "\tIdent " << (anIter.Key())->Identification () << "\n";
962 std::cout << std::flush;
965 //=============================================================================
968 //=============================================================================
969 void Graphic3d_Structure::Update (const bool theUpdateLayer) const
976 myStructureManager->Update (theUpdateLayer ? myCStructure->ZLayer() : Graphic3d_ZLayerId_UNKNOWN);
979 //=======================================================================
980 //function : SetZLayer
982 //=======================================================================
983 void Graphic3d_Structure::SetZLayer (const Graphic3d_ZLayerId theLayerId)
985 // if the structure is not displayed, unable to change its display layer
989 myStructureManager->ChangeZLayer (this, theLayerId);
990 myCStructure->SetZLayer (theLayerId);
993 //=======================================================================
994 //function : DumpJson
996 //=======================================================================
997 void Graphic3d_Structure::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
999 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
1001 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStructureManager)
1002 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myCStructure.get())
1004 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myAncestors); anIter.More(); anIter.Next())
1006 Graphic3d_Structure* anAncestor = anIter.Value();
1007 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, anAncestor)
1010 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
1012 Graphic3d_Structure* aDescendant = anIter.Value();
1013 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, aDescendant)
1016 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myOwner)
1017 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myVisual)
1018 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myComputeVisual)