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_DataStructureManager.hxx>
21 #include <Graphic3d_GraphicDriver.hxx>
22 #include <Graphic3d_Group.hxx>
23 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
24 #include <Graphic3d_MapOfStructure.hxx>
25 #include <Graphic3d_PriorityDefinitionError.hxx>
26 #include <Graphic3d_StructureDefinitionError.hxx>
27 #include <Graphic3d_StructureManager.hxx>
28 #include <Graphic3d_TransformError.hxx>
29 #include <Quantity_Color.hxx>
31 #include "Graphic3d_Structure.pxx"
33 #include <Standard_Dump.hxx>
37 IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Structure,Standard_Transient)
39 //=============================================================================
40 //function : Graphic3d_Structure
42 //=============================================================================
43 Graphic3d_Structure::Graphic3d_Structure (const Handle(Graphic3d_StructureManager)& theManager,
44 const Handle(Graphic3d_Structure)& theLinkPrs)
45 : myStructureManager(theManager.get()),
47 myVisual (Graphic3d_TOS_ALL),
48 myComputeVisual (Graphic3d_TOS_ALL)
50 if (!theLinkPrs.IsNull())
52 myOwner = theLinkPrs->myOwner;
53 myVisual = theLinkPrs->myVisual;
54 myComputeVisual = theLinkPrs->myComputeVisual;
55 myCStructure = theLinkPrs->myCStructure->ShadowLink (theManager);
59 myCStructure = theManager->GraphicDriver()->CreateStructure (theManager);
63 //=============================================================================
64 //function : ~Graphic3d_Structure
66 //=============================================================================
67 Graphic3d_Structure::~Graphic3d_Structure()
69 // as myStructureManager can be already destroyed,
70 // avoid attempts to access it
71 myStructureManager = NULL;
75 //=============================================================================
78 //=============================================================================
79 void Graphic3d_Structure::Clear (const Standard_Boolean theWithDestruction)
81 if (IsDeleted()) return;
83 // clean groups in graphics driver at first
84 GraphicClear (theWithDestruction);
86 myCStructure->ContainsFacet = 0;
87 myStructureManager->Clear (this, theWithDestruction);
92 //=======================================================================
93 //function : CalculateBoundBox
94 //purpose : Calculates AABB of a structure.
95 //=======================================================================
96 void Graphic3d_Structure::CalculateBoundBox()
98 Graphic3d_BndBox3d aBox;
99 addTransformed (aBox, Standard_True);
100 myCStructure->ChangeBoundingBox() = aBox;
103 //=============================================================================
106 //=============================================================================
107 void Graphic3d_Structure::Remove()
109 if (IsDeleted()) return;
111 // clean groups in graphics driver at first; this is also should be done
112 // to avoid unwanted group cleaning in group's destructor
113 // Pass Standard_False to Clear(..) method to avoid updating in
114 // structure manager, it isn't necessary, besides of it structure manager
115 // could be already destroyed and invalid pointers used in structure;
116 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
118 aGroupIter.ChangeValue()->Clear (Standard_False);
121 // It is necessary to remove the eventual pointer on the structure that can be destroyed, in the list of descendants
122 // of ancestors of this structure and in the list of ancestors of descendants of the same structure.
123 for (Standard_Integer aStructIdx = 1, aNbDesc = myDescendants.Size(); aStructIdx <= aNbDesc; ++aStructIdx)
125 myDescendants.FindKey (aStructIdx)->Remove (this, Graphic3d_TOC_ANCESTOR);
128 for (Standard_Integer aStructIdx = 1, aNbAnces = myAncestors.Size(); aStructIdx <= aNbAnces; ++aStructIdx)
130 myAncestors.FindKey (aStructIdx)->Remove (this, Graphic3d_TOC_DESCENDANT);
133 // Destruction of me in the graphic library
134 const Standard_Integer aStructId = myCStructure->Id;
135 myCStructure->GraphicDriver()->RemoveIdentification(aStructId);
136 myCStructure->GraphicDriver()->RemoveStructure (myCStructure);
137 myCStructure.Nullify();
140 //=============================================================================
143 //=============================================================================
144 void Graphic3d_Structure::Display()
146 if (IsDeleted()) return;
148 if (!myCStructure->stick)
150 myCStructure->stick = 1;
151 myStructureManager->Display (this);
154 if (myCStructure->visible != 1)
156 myCStructure->visible = 1;
157 myCStructure->OnVisibilityChanged();
161 //=============================================================================
162 //function : SetDisplayPriority
164 //=============================================================================
165 void Graphic3d_Structure::SetDisplayPriority (const Standard_Integer thePriority)
168 || thePriority == myCStructure->Priority)
173 myCStructure->PreviousPriority = myCStructure->Priority;
174 myCStructure->Priority = thePriority;
176 if (myCStructure->Priority != myCStructure->PreviousPriority)
178 Graphic3d_PriorityDefinitionError_Raise_if ((myCStructure->Priority > Structure_MAX_PRIORITY)
179 || (myCStructure->Priority < Structure_MIN_PRIORITY),
180 "Bad value for StructurePriority");
181 if (myCStructure->stick)
183 myStructureManager->ChangeDisplayPriority (this, myCStructure->PreviousPriority, myCStructure->Priority);
188 //=============================================================================
189 //function : ResetDisplayPriority
191 //=============================================================================
192 void Graphic3d_Structure::ResetDisplayPriority()
195 || myCStructure->Priority == myCStructure->PreviousPriority)
200 const Standard_Integer aPriority = myCStructure->Priority;
201 myCStructure->Priority = myCStructure->PreviousPriority;
202 if (myCStructure->stick)
204 myStructureManager->ChangeDisplayPriority (this, aPriority, myCStructure->Priority);
208 //=============================================================================
211 //=============================================================================
212 void Graphic3d_Structure::Erase()
219 if (myCStructure->stick)
221 myCStructure->stick = 0;
222 myStructureManager->Erase (this);
226 //=============================================================================
227 //function : Highlight
229 //=============================================================================
230 void Graphic3d_Structure::Highlight (const Handle(Graphic3d_PresentationAttributes)& theStyle,
231 const Standard_Boolean theToUpdateMgr)
238 SetDisplayPriority (Structure_MAX_PRIORITY - 1);
240 myCStructure->GraphicHighlight (theStyle);
247 if (myCStructure->stick)
249 myStructureManager->Highlight (this);
255 //=============================================================================
256 //function : SetVisible
258 //=============================================================================
259 void Graphic3d_Structure::SetVisible (const Standard_Boolean theValue)
261 if (IsDeleted()) return;
263 const unsigned isVisible = theValue ? 1 : 0;
264 if (myCStructure->visible == isVisible)
269 myCStructure->visible = isVisible;
270 myCStructure->OnVisibilityChanged();
274 //=============================================================================
275 //function : UnHighlight
277 //=============================================================================
278 void Graphic3d_Structure::UnHighlight()
280 if (IsDeleted()) return;
282 if (myCStructure->highlight)
284 myCStructure->highlight = 0;
286 myCStructure->GraphicUnhighlight();
287 myStructureManager->UnHighlight (this);
289 ResetDisplayPriority();
294 //=============================================================================
295 //function : ContainsFacet
297 //=============================================================================
298 Standard_Boolean Graphic3d_Structure::ContainsFacet() const
302 return Standard_False;
304 else if (myCStructure->ContainsFacet > 0)
306 // if one of groups contains at least one facet, the structure contains it too
307 return Standard_True;
310 // stop at the first descendant containing at least one facet
311 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
313 if (anIter.Value()->ContainsFacet())
315 return Standard_True;
318 return Standard_False;
321 //=============================================================================
324 //=============================================================================
325 Standard_Boolean Graphic3d_Structure::IsEmpty() const
329 return Standard_True;
332 // structure is empty:
333 // - if all these groups are empty
334 // - or if all groups are empty and all their descendants are empty
335 // - or if all its descendants are empty
336 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
338 if (!aGroupIter.Value()->IsEmpty())
340 return Standard_False;
344 // stop at the first non-empty descendant
345 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
347 if (!anIter.Value()->IsEmpty())
349 return Standard_False;
352 return Standard_True;
355 //=============================================================================
356 //function : GroupsWithFacet
358 //=============================================================================
359 void Graphic3d_Structure::GroupsWithFacet (const Standard_Integer theDelta)
361 myCStructure->ContainsFacet = myCStructure->ContainsFacet + theDelta;
362 if (myCStructure->ContainsFacet < 0)
364 myCStructure->ContainsFacet = 0;
368 //=============================================================================
369 //function : ReCompute
371 //=============================================================================
372 void Graphic3d_Structure::ReCompute()
374 myStructureManager->ReCompute (this);
377 //=============================================================================
378 //function : ReCompute
380 //=============================================================================
381 void Graphic3d_Structure::ReCompute (const Handle(Graphic3d_DataStructureManager)& theProjector)
383 myStructureManager->ReCompute (this, theProjector);
386 //=============================================================================
387 //function : GraphicClear
389 //=============================================================================
390 void Graphic3d_Structure::GraphicClear (const Standard_Boolean theWithDestruction)
392 if (myCStructure.IsNull())
397 // clean and empty each group
398 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
400 aGroupIter.ChangeValue()->Clear();
402 if (!theWithDestruction)
407 while (!myCStructure->Groups().IsEmpty())
409 Handle(Graphic3d_Group) aGroup = myCStructure->Groups().First();
412 myCStructure->Clear();
415 //=============================================================================
416 //function : SetVisual
418 //=============================================================================
419 void Graphic3d_Structure::SetVisual (const Graphic3d_TypeOfStructure theVisual)
422 || myVisual == theVisual)
427 if (!myCStructure->stick)
429 myVisual = theVisual;
430 SetComputeVisual (theVisual);
435 myVisual = theVisual;
436 SetComputeVisual (theVisual);
441 //=============================================================================
442 //function : SetZoomLimit
444 //=============================================================================
445 void Graphic3d_Structure::SetZoomLimit (const Standard_Real theLimitInf,
446 const Standard_Real theLimitSup)
450 Graphic3d_StructureDefinitionError_Raise_if (theLimitInf <= 0.0,
451 "Bad value for ZoomLimit inf");
452 Graphic3d_StructureDefinitionError_Raise_if (theLimitSup <= 0.0,
453 "Bad value for ZoomLimit sup");
454 Graphic3d_StructureDefinitionError_Raise_if (theLimitSup < theLimitInf,
455 "ZoomLimit sup < ZoomLimit inf");
458 //=============================================================================
459 //function : AcceptConnection
461 //=============================================================================
462 Standard_Boolean Graphic3d_Structure::AcceptConnection (Graphic3d_Structure* theStructure1,
463 Graphic3d_Structure* theStructure2,
464 Graphic3d_TypeOfConnection theType)
467 NCollection_Map<Graphic3d_Structure*> aSet;
468 Graphic3d_Structure::Network (theStructure2, theType, aSet);
469 return !aSet.Contains (theStructure1);
472 //=============================================================================
473 //function : Ancestors
475 //=============================================================================
476 void Graphic3d_Structure::Ancestors (Graphic3d_MapOfStructure& theSet) const
478 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myAncestors); anIter.More(); anIter.Next())
480 theSet.Add (anIter.Value());
484 //=============================================================================
485 //function : Descendants
487 //=============================================================================
488 void Graphic3d_Structure::Descendants (Graphic3d_MapOfStructure& theSet) const
490 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
492 theSet.Add (anIter.Value());
496 //=============================================================================
497 //function : AppendAncestor
499 //=============================================================================
500 Standard_Boolean Graphic3d_Structure::AppendAncestor (Graphic3d_Structure* theAncestor)
502 const Standard_Integer aSize = myAncestors.Size();
504 return myAncestors.Add (theAncestor) > aSize; // new object
507 //=============================================================================
508 //function : AppendDescendant
510 //=============================================================================
511 Standard_Boolean Graphic3d_Structure::AppendDescendant (Graphic3d_Structure* theDescendant)
513 const Standard_Integer aSize = myDescendants.Size();
515 return myDescendants.Add (theDescendant) > aSize; // new object
518 //=============================================================================
519 //function : RemoveAncestor
521 //=============================================================================
522 Standard_Boolean Graphic3d_Structure::RemoveAncestor (Graphic3d_Structure* theAncestor)
524 const Standard_Integer anIndex = myAncestors.FindIndex (theAncestor);
528 myAncestors.Swap (anIndex, myAncestors.Size());
529 myAncestors.RemoveLast();
532 return anIndex != 0; // object was found
535 //=============================================================================
536 //function : RemoveDescendant
538 //=============================================================================
539 Standard_Boolean Graphic3d_Structure::RemoveDescendant (Graphic3d_Structure* theDescendant)
541 const Standard_Integer anIndex = myDescendants.FindIndex (theDescendant);
545 myDescendants.Swap (anIndex, myDescendants.Size());
546 myDescendants.RemoveLast();
549 return anIndex != 0; // object was found
552 //=============================================================================
555 //=============================================================================
556 void Graphic3d_Structure::Connect (Graphic3d_Structure* theStructure,
557 Graphic3d_TypeOfConnection theType,
558 Standard_Boolean theWithCheck)
567 && !Graphic3d_Structure::AcceptConnection (this, theStructure, theType))
572 if (theType == Graphic3d_TOC_DESCENDANT)
574 if (!AppendDescendant (theStructure))
580 theStructure->Connect (this, Graphic3d_TOC_ANCESTOR);
582 GraphicConnect (theStructure);
583 myStructureManager->Connect (this, theStructure);
587 else // Graphic3d_TOC_ANCESTOR
589 if (!AppendAncestor (theStructure))
595 theStructure->Connect (this, Graphic3d_TOC_DESCENDANT);
597 // myStructureManager->Connect is called in case if connection between parent and child
601 //=============================================================================
602 //function : Disconnect
604 //=============================================================================
605 void Graphic3d_Structure::Disconnect (Graphic3d_Structure* theStructure)
612 if (RemoveDescendant (theStructure))
614 theStructure->Disconnect (this);
616 GraphicDisconnect (theStructure);
617 myStructureManager->Disconnect (this, theStructure);
622 else if (RemoveAncestor (theStructure))
624 theStructure->Disconnect (this);
627 // no call of myStructureManager->Disconnect in case of an ancestor
631 //=============================================================================
632 //function : DisconnectAll
634 //=============================================================================
635 void Graphic3d_Structure::DisconnectAll (const Graphic3d_TypeOfConnection theType)
637 if (IsDeleted()) return;
641 case Graphic3d_TOC_DESCENDANT:
643 for (Standard_Integer anIdx = 1, aLength = myDescendants.Size(); anIdx <= aLength; ++anIdx)
645 // Value (1) instead of Value (i) as myDescendants
647 // Graphic3d_Structure::Disconnect (AStructure)
648 // that takes AStructure from myDescendants
649 myDescendants.FindKey (1)->Disconnect (this);
653 case Graphic3d_TOC_ANCESTOR:
655 for (Standard_Integer anIdx = 1, aLength = myAncestors.Size(); anIdx <= aLength; ++anIdx)
657 // Value (1) instead of Value (i) as myAncestors
659 // Graphic3d_Structure::Disconnect (AStructure)
660 // that takes AStructure from myAncestors
661 myAncestors.FindKey (1)->Disconnect (this);
668 //=============================================================================
669 //function : SetTransform
671 //=============================================================================
672 void Graphic3d_Structure::SetTransformation (const Handle(Geom_Transformation)& theTrsf)
674 if (IsDeleted()) return;
676 const Standard_Boolean wasTransformed = IsTransformed();
678 if (!theTrsf.IsNull()
679 && theTrsf->Trsf().Form() == gp_Identity)
681 myCStructure->SetTransformation (Handle(Geom_Transformation)());
685 myCStructure->SetTransformation (theTrsf);
688 // If transformation, no validation of hidden already calculated parts
689 if (IsTransformed() || (!IsTransformed() && wasTransformed))
694 myStructureManager->SetTransform (this, theTrsf);
699 //=============================================================================
700 //function : MinMaxValues
702 //=============================================================================
703 Bnd_Box Graphic3d_Structure::MinMaxValues (const Standard_Boolean theToIgnoreInfiniteFlag) const
705 Graphic3d_BndBox3d aBox;
706 addTransformed (aBox, theToIgnoreInfiniteFlag);
713 aResult.Update (aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
714 aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
716 Standard_Real aLimMin = ShortRealFirst() + 1.0;
717 Standard_Real aLimMax = ShortRealLast() - 1.0;
718 gp_Pnt aMin = aResult.CornerMin();
719 gp_Pnt aMax = aResult.CornerMax();
720 if (aMin.X() < aLimMin && aMin.Y() < aLimMin && aMin.Z() < aLimMin
721 && aMax.X() > aLimMax && aMax.Y() > aLimMax && aMax.Z() > aLimMax)
723 //For structure which infinite in all three dimensions the Whole bounding box will be returned
729 //=============================================================================
730 //function : SetTransformPersistence
732 //=============================================================================
733 void Graphic3d_Structure::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
740 myCStructure->SetTransformPersistence (theTrsfPers);
743 //=============================================================================
746 //=============================================================================
747 void Graphic3d_Structure::Remove (Graphic3d_Structure* thePtr,
748 const Graphic3d_TypeOfConnection theType)
750 if (theType == Graphic3d_TOC_DESCENDANT)
752 RemoveDescendant (thePtr);
756 RemoveAncestor (thePtr);
760 //=============================================================================
761 //function : NewGroup
763 //=============================================================================
764 Handle(Graphic3d_Group) Graphic3d_Structure::NewGroup()
766 return myCStructure->NewGroup (this);
769 //=============================================================================
772 //=============================================================================
773 void Graphic3d_Structure::Remove (const Handle(Graphic3d_Group)& theGroup)
775 if (theGroup.IsNull()
776 || theGroup->myStructure != this)
781 myCStructure->RemoveGroup (theGroup);
782 theGroup->myStructure = NULL;
785 //=============================================================================
786 //function : StructureManager
788 //=============================================================================
789 Handle(Graphic3d_StructureManager) Graphic3d_Structure::StructureManager() const
791 return myStructureManager;
794 //=============================================================================
795 //function : minMaxCoord
797 //=============================================================================
798 Graphic3d_BndBox4f Graphic3d_Structure::minMaxCoord() const
800 Graphic3d_BndBox4f aBnd;
801 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
803 aBnd.Combine (aGroupIter.Value()->BoundingBox());
808 //=============================================================================
809 //function : addTransformed
811 //=============================================================================
812 void Graphic3d_Structure::getBox (Graphic3d_BndBox3d& theBox,
813 const Standard_Boolean theToIgnoreInfiniteFlag) const
815 Graphic3d_BndBox4f aBoxF = minMaxCoord();
818 theBox = Graphic3d_BndBox3d (Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMin().x(),
819 (Standard_Real )aBoxF.CornerMin().y(),
820 (Standard_Real )aBoxF.CornerMin().z()),
821 Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMax().x(),
822 (Standard_Real )aBoxF.CornerMax().y(),
823 (Standard_Real )aBoxF.CornerMax().z()));
825 && !theToIgnoreInfiniteFlag)
827 const Graphic3d_Vec3d aDiagVec = theBox.CornerMax() - theBox.CornerMin();
828 if (aDiagVec.SquareModulus() >= 500000.0 * 500000.0)
830 // bounding borders of infinite line has been calculated as own point in center of this line
831 theBox = Graphic3d_BndBox3d ((theBox.CornerMin() + theBox.CornerMax()) * 0.5);
835 theBox = Graphic3d_BndBox3d (Graphic3d_Vec3d (RealFirst(), RealFirst(), RealFirst()),
836 Graphic3d_Vec3d (RealLast(), RealLast(), RealLast()));
843 //=============================================================================
844 //function : addTransformed
846 //=============================================================================
847 void Graphic3d_Structure::addTransformed (Graphic3d_BndBox3d& theBox,
848 const Standard_Boolean theToIgnoreInfiniteFlag) const
850 Graphic3d_BndBox3d aCombinedBox, aBox;
851 getBox (aCombinedBox, theToIgnoreInfiniteFlag);
853 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
855 const Graphic3d_Structure* aStruct = anIter.Value();
856 aStruct->getBox (aBox, theToIgnoreInfiniteFlag);
857 aCombinedBox.Combine (aBox);
863 if (!myCStructure->Transformation().IsNull())
865 TransformBoundaries (myCStructure->Transformation()->Trsf(),
866 aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
867 aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
870 // if box is still valid after transformation
873 theBox.Combine (aBox);
875 else // it was infinite, return untransformed
877 theBox.Combine (aCombinedBox);
882 //=============================================================================
883 //function : Transforms
885 //=============================================================================
886 void Graphic3d_Structure::Transforms (const gp_Trsf& theTrsf,
887 const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ,
888 Standard_Real& theNewX, Standard_Real& theNewY, Standard_Real& theNewZ)
890 const Standard_Real aRL = RealLast();
891 const Standard_Real aRF = RealFirst();
895 if ((theX == aRF) || (theY == aRF) || (theZ == aRF)
896 || (theX == aRL) || (theY == aRL) || (theZ == aRL))
901 theTrsf.Transforms (theNewX, theNewY, theNewZ);
904 //=============================================================================
905 //function : Transforms
907 //=============================================================================
908 void Graphic3d_Structure::TransformBoundaries (const gp_Trsf& theTrsf,
909 Standard_Real& theXMin,
910 Standard_Real& theYMin,
911 Standard_Real& theZMin,
912 Standard_Real& theXMax,
913 Standard_Real& theYMax,
914 Standard_Real& theZMax)
916 Standard_Real aXMin, aYMin, aZMin, aXMax, aYMax, aZMax, anU, aV, aW;
918 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMin, theZMin, aXMin, aYMin, aZMin);
919 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMax, theZMax, aXMax, aYMax, aZMax);
921 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMin, theZMax, anU, aV, aW);
922 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
923 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
924 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
926 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMin, theZMax, anU, aV, aW);
927 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
928 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
929 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
931 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMin, theZMin, anU, aV, aW);
932 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
933 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
934 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
936 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMax, theZMin, anU, aV, aW);
937 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
938 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
939 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
941 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMax, theZMax, anU, aV, aW);
942 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
943 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
944 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
946 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMax, theZMin, anU, aV, aW);
947 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
948 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
949 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
959 //=============================================================================
962 //=============================================================================
963 void Graphic3d_Structure::Network (Graphic3d_Structure* theStructure,
964 const Graphic3d_TypeOfConnection theType,
965 NCollection_Map<Graphic3d_Structure*>& theSet)
967 theSet.Add (theStructure);
970 case Graphic3d_TOC_DESCENDANT:
972 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (theStructure->myDescendants); anIter.More(); anIter.Next())
974 Graphic3d_Structure::Network (anIter.Value(), theType, theSet);
978 case Graphic3d_TOC_ANCESTOR:
980 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (theStructure->myAncestors); anIter.More(); anIter.Next())
982 Graphic3d_Structure::Network (anIter.Value(), theType, theSet);
989 //=============================================================================
990 //function : PrintNetwork
992 //=============================================================================
993 void Graphic3d_Structure::PrintNetwork (const Handle(Graphic3d_Structure)& theStructure,
994 const Graphic3d_TypeOfConnection theType)
996 NCollection_Map<Graphic3d_Structure*> aSet;
997 Graphic3d_Structure::Network (theStructure.get(), theType, aSet);
998 for (NCollection_Map<Graphic3d_Structure*>::Iterator anIter (aSet); anIter.More(); anIter.Next())
1000 std::cout << "\tIdent " << (anIter.Key())->Identification () << "\n";
1002 std::cout << std::flush;
1005 //=============================================================================
1008 //=============================================================================
1009 void Graphic3d_Structure::Update (const bool theUpdateLayer) const
1016 myStructureManager->Update (theUpdateLayer ? myCStructure->ZLayer() : Graphic3d_ZLayerId_UNKNOWN);
1019 //=======================================================================
1020 //function : SetZLayer
1022 //=======================================================================
1023 void Graphic3d_Structure::SetZLayer (const Graphic3d_ZLayerId theLayerId)
1025 // if the structure is not displayed, unable to change its display layer
1029 myStructureManager->ChangeZLayer (this, theLayerId);
1030 myCStructure->SetZLayer (theLayerId);
1033 //=======================================================================
1034 //function : DumpJson
1036 //=======================================================================
1037 void Graphic3d_Structure::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
1039 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
1041 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myCStructure.get())
1043 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myVisual)
1044 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myComputeVisual)