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 <Quantity_Color.hxx>
30 #include <Standard_Dump.hxx>
34 IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Structure,Standard_Transient)
36 //=============================================================================
37 //function : Graphic3d_Structure
39 //=============================================================================
40 Graphic3d_Structure::Graphic3d_Structure (const Handle(Graphic3d_StructureManager)& theManager,
41 const Handle(Graphic3d_Structure)& theLinkPrs)
42 : myStructureManager(theManager.get()),
44 myVisual (Graphic3d_TOS_ALL),
45 myComputeVisual (Graphic3d_TOS_ALL)
47 if (!theLinkPrs.IsNull())
49 myOwner = theLinkPrs->myOwner;
50 if (theLinkPrs->myVisual != Graphic3d_TOS_COMPUTED)
52 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->SetGroupTransformPersistence (false);
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->Identification();
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 Graphic3d_DisplayPriority thePriority)
168 || thePriority == myCStructure->Priority())
173 Graphic3d_PriorityDefinitionError_Raise_if ((thePriority > Graphic3d_DisplayPriority_Topmost)
174 || (thePriority < Graphic3d_DisplayPriority_Bottom),
175 "Bad value for StructurePriority");
177 myCStructure->SetPreviousPriority (myCStructure->Priority());
178 myCStructure->SetPriority (thePriority);
179 if (myCStructure->Priority() != myCStructure->PreviousPriority())
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 Graphic3d_DisplayPriority aPriority = myCStructure->Priority();
201 myCStructure->SetPriority (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 (Graphic3d_DisplayPriority_Highlight);
239 myCStructure->GraphicHighlight (theStyle);
245 if (myCStructure->stick)
247 myStructureManager->Highlight (this);
253 //=============================================================================
254 //function : SetVisible
256 //=============================================================================
257 void Graphic3d_Structure::SetVisible (const Standard_Boolean theValue)
259 if (IsDeleted()) return;
261 const unsigned isVisible = theValue ? 1 : 0;
262 if (myCStructure->visible == isVisible)
267 myCStructure->visible = isVisible;
268 myCStructure->OnVisibilityChanged();
272 //=============================================================================
273 //function : UnHighlight
275 //=============================================================================
276 void Graphic3d_Structure::UnHighlight()
278 if (IsDeleted()) return;
280 if (myCStructure->highlight)
282 myCStructure->highlight = 0;
284 myCStructure->GraphicUnhighlight();
285 myStructureManager->UnHighlight (this);
287 ResetDisplayPriority();
292 //=============================================================================
295 //=============================================================================
296 Standard_Boolean Graphic3d_Structure::IsEmpty() const
300 return Standard_True;
303 // structure is empty:
304 // - if all these groups are empty
305 // - or if all groups are empty and all their descendants are empty
306 // - or if all its descendants are empty
307 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
309 if (!aGroupIter.Value()->IsEmpty())
311 return Standard_False;
315 // stop at the first non-empty descendant
316 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
318 if (!anIter.Value()->IsEmpty())
320 return Standard_False;
323 return Standard_True;
326 //=============================================================================
327 //function : ReCompute
329 //=============================================================================
330 void Graphic3d_Structure::ReCompute()
332 myStructureManager->ReCompute (this);
335 //=============================================================================
336 //function : ReCompute
338 //=============================================================================
339 void Graphic3d_Structure::ReCompute (const Handle(Graphic3d_DataStructureManager)& theProjector)
341 myStructureManager->ReCompute (this, theProjector);
344 //=============================================================================
345 //function : GraphicClear
347 //=============================================================================
348 void Graphic3d_Structure::GraphicClear (const Standard_Boolean theWithDestruction)
350 if (myCStructure.IsNull())
355 // clean and empty each group
356 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
358 aGroupIter.ChangeValue()->Clear();
360 if (!theWithDestruction)
365 while (!myCStructure->Groups().IsEmpty())
367 Handle(Graphic3d_Group) aGroup = myCStructure->Groups().First();
370 myCStructure->Clear();
373 //=============================================================================
374 //function : SetVisual
376 //=============================================================================
377 void Graphic3d_Structure::SetVisual (const Graphic3d_TypeOfStructure theVisual)
380 || myVisual == theVisual)
385 if (!myCStructure->stick)
387 myVisual = theVisual;
388 SetComputeVisual (theVisual);
393 myVisual = theVisual;
394 SetComputeVisual (theVisual);
399 //=============================================================================
400 //function : SetZoomLimit
402 //=============================================================================
403 void Graphic3d_Structure::SetZoomLimit (const Standard_Real theLimitInf,
404 const Standard_Real theLimitSup)
408 Graphic3d_StructureDefinitionError_Raise_if (theLimitInf <= 0.0,
409 "Bad value for ZoomLimit inf");
410 Graphic3d_StructureDefinitionError_Raise_if (theLimitSup <= 0.0,
411 "Bad value for ZoomLimit sup");
412 Graphic3d_StructureDefinitionError_Raise_if (theLimitSup < theLimitInf,
413 "ZoomLimit sup < ZoomLimit inf");
416 //=============================================================================
417 //function : AcceptConnection
419 //=============================================================================
420 Standard_Boolean Graphic3d_Structure::AcceptConnection (Graphic3d_Structure* theStructure1,
421 Graphic3d_Structure* theStructure2,
422 Graphic3d_TypeOfConnection theType)
425 NCollection_Map<Graphic3d_Structure*> aSet;
426 Graphic3d_Structure::Network (theStructure2, theType, aSet);
427 return !aSet.Contains (theStructure1);
430 //=============================================================================
431 //function : Ancestors
433 //=============================================================================
434 void Graphic3d_Structure::Ancestors (Graphic3d_MapOfStructure& theSet) const
436 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myAncestors); anIter.More(); anIter.Next())
438 theSet.Add (anIter.Value());
442 //=============================================================================
443 //function : Descendants
445 //=============================================================================
446 void Graphic3d_Structure::Descendants (Graphic3d_MapOfStructure& theSet) const
448 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
450 theSet.Add (anIter.Value());
454 //=============================================================================
455 //function : AppendAncestor
457 //=============================================================================
458 Standard_Boolean Graphic3d_Structure::AppendAncestor (Graphic3d_Structure* theAncestor)
460 const Standard_Integer aSize = myAncestors.Size();
462 return myAncestors.Add (theAncestor) > aSize; // new object
465 //=============================================================================
466 //function : AppendDescendant
468 //=============================================================================
469 Standard_Boolean Graphic3d_Structure::AppendDescendant (Graphic3d_Structure* theDescendant)
471 const Standard_Integer aSize = myDescendants.Size();
473 return myDescendants.Add (theDescendant) > aSize; // new object
476 //=============================================================================
477 //function : RemoveAncestor
479 //=============================================================================
480 Standard_Boolean Graphic3d_Structure::RemoveAncestor (Graphic3d_Structure* theAncestor)
482 const Standard_Integer anIndex = myAncestors.FindIndex (theAncestor);
486 myAncestors.Swap (anIndex, myAncestors.Size());
487 myAncestors.RemoveLast();
490 return anIndex != 0; // object was found
493 //=============================================================================
494 //function : RemoveDescendant
496 //=============================================================================
497 Standard_Boolean Graphic3d_Structure::RemoveDescendant (Graphic3d_Structure* theDescendant)
499 const Standard_Integer anIndex = myDescendants.FindIndex (theDescendant);
503 myDescendants.Swap (anIndex, myDescendants.Size());
504 myDescendants.RemoveLast();
507 return anIndex != 0; // object was found
510 //=============================================================================
513 //=============================================================================
514 void Graphic3d_Structure::Connect (Graphic3d_Structure* theStructure,
515 Graphic3d_TypeOfConnection theType,
516 Standard_Boolean theWithCheck)
525 && !Graphic3d_Structure::AcceptConnection (this, theStructure, theType))
530 if (theType == Graphic3d_TOC_DESCENDANT)
532 if (!AppendDescendant (theStructure))
538 theStructure->Connect (this, Graphic3d_TOC_ANCESTOR);
540 GraphicConnect (theStructure);
541 myStructureManager->Connect (this, theStructure);
545 else // Graphic3d_TOC_ANCESTOR
547 if (!AppendAncestor (theStructure))
553 theStructure->Connect (this, Graphic3d_TOC_DESCENDANT);
555 // myStructureManager->Connect is called in case if connection between parent and child
559 //=============================================================================
560 //function : Disconnect
562 //=============================================================================
563 void Graphic3d_Structure::Disconnect (Graphic3d_Structure* theStructure)
570 if (RemoveDescendant (theStructure))
572 theStructure->Disconnect (this);
574 GraphicDisconnect (theStructure);
575 myStructureManager->Disconnect (this, theStructure);
580 else if (RemoveAncestor (theStructure))
582 theStructure->Disconnect (this);
585 // no call of myStructureManager->Disconnect in case of an ancestor
589 //=============================================================================
590 //function : DisconnectAll
592 //=============================================================================
593 void Graphic3d_Structure::DisconnectAll (const Graphic3d_TypeOfConnection theType)
595 if (IsDeleted()) return;
599 case Graphic3d_TOC_DESCENDANT:
601 for (Standard_Integer anIdx = 1, aLength = myDescendants.Size(); anIdx <= aLength; ++anIdx)
603 // Value (1) instead of Value (i) as myDescendants
605 // Graphic3d_Structure::Disconnect (AStructure)
606 // that takes AStructure from myDescendants
607 myDescendants.FindKey (1)->Disconnect (this);
611 case Graphic3d_TOC_ANCESTOR:
613 for (Standard_Integer anIdx = 1, aLength = myAncestors.Size(); anIdx <= aLength; ++anIdx)
615 // Value (1) instead of Value (i) as myAncestors
617 // Graphic3d_Structure::Disconnect (AStructure)
618 // that takes AStructure from myAncestors
619 myAncestors.FindKey (1)->Disconnect (this);
626 //=============================================================================
627 //function : SetTransform
629 //=============================================================================
630 void Graphic3d_Structure::SetTransformation (const Handle(TopLoc_Datum3D)& theTrsf)
632 if (IsDeleted()) return;
634 const Standard_Boolean wasTransformed = IsTransformed();
636 if (!theTrsf.IsNull()
637 && theTrsf->Trsf().Form() == gp_Identity)
639 myCStructure->SetTransformation (Handle(TopLoc_Datum3D)());
643 myCStructure->SetTransformation (theTrsf);
646 // If transformation, no validation of hidden already calculated parts
647 if (IsTransformed() || (!IsTransformed() && wasTransformed))
652 myStructureManager->SetTransform (this, theTrsf);
657 //=============================================================================
658 //function : MinMaxValues
660 //=============================================================================
661 Bnd_Box Graphic3d_Structure::MinMaxValues (const Standard_Boolean theToIgnoreInfiniteFlag) const
663 Graphic3d_BndBox3d aBox;
664 addTransformed (aBox, theToIgnoreInfiniteFlag);
671 aResult.Update (aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
672 aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
674 Standard_Real aLimMin = ShortRealFirst() + 1.0;
675 Standard_Real aLimMax = ShortRealLast() - 1.0;
676 gp_Pnt aMin = aResult.CornerMin();
677 gp_Pnt aMax = aResult.CornerMax();
678 if (aMin.X() < aLimMin && aMin.Y() < aLimMin && aMin.Z() < aLimMin
679 && aMax.X() > aLimMax && aMax.Y() > aLimMax && aMax.Z() > aLimMax)
681 //For structure which infinite in all three dimensions the Whole bounding box will be returned
687 //=============================================================================
688 //function : SetTransformPersistence
690 //=============================================================================
691 void Graphic3d_Structure::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
698 myCStructure->SetTransformPersistence (theTrsfPers);
701 //=============================================================================
704 //=============================================================================
705 void Graphic3d_Structure::Remove (Graphic3d_Structure* thePtr,
706 const Graphic3d_TypeOfConnection theType)
708 if (theType == Graphic3d_TOC_DESCENDANT)
710 RemoveDescendant (thePtr);
714 RemoveAncestor (thePtr);
718 //=============================================================================
719 //function : NewGroup
721 //=============================================================================
722 Handle(Graphic3d_Group) Graphic3d_Structure::NewGroup()
724 return myCStructure->NewGroup (this);
727 //=============================================================================
730 //=============================================================================
731 void Graphic3d_Structure::Remove (const Handle(Graphic3d_Group)& theGroup)
733 if (theGroup.IsNull()
734 || theGroup->myStructure != this)
739 myCStructure->RemoveGroup (theGroup);
740 theGroup->myStructure = NULL;
743 //=============================================================================
744 //function : StructureManager
746 //=============================================================================
747 Handle(Graphic3d_StructureManager) Graphic3d_Structure::StructureManager() const
749 return myStructureManager;
752 //=============================================================================
753 //function : minMaxCoord
755 //=============================================================================
756 Graphic3d_BndBox4f Graphic3d_Structure::minMaxCoord() const
758 Graphic3d_BndBox4f aBnd;
759 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
761 if (!aGroupIter.Value()->TransformPersistence().IsNull())
763 continue; // should be translated to current view orientation to make sense
766 aBnd.Combine (aGroupIter.Value()->BoundingBox());
771 //=============================================================================
772 //function : addTransformed
774 //=============================================================================
775 void Graphic3d_Structure::getBox (Graphic3d_BndBox3d& theBox,
776 const Standard_Boolean theToIgnoreInfiniteFlag) const
778 Graphic3d_BndBox4f aBoxF = minMaxCoord();
781 theBox = Graphic3d_BndBox3d (Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMin().x(),
782 (Standard_Real )aBoxF.CornerMin().y(),
783 (Standard_Real )aBoxF.CornerMin().z()),
784 Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMax().x(),
785 (Standard_Real )aBoxF.CornerMax().y(),
786 (Standard_Real )aBoxF.CornerMax().z()));
788 && !theToIgnoreInfiniteFlag)
790 const Graphic3d_Vec3d aDiagVec = theBox.CornerMax() - theBox.CornerMin();
791 if (aDiagVec.SquareModulus() >= 500000.0 * 500000.0)
793 // bounding borders of infinite line has been calculated as own point in center of this line
794 theBox = Graphic3d_BndBox3d ((theBox.CornerMin() + theBox.CornerMax()) * 0.5);
798 theBox = Graphic3d_BndBox3d (Graphic3d_Vec3d (RealFirst(), RealFirst(), RealFirst()),
799 Graphic3d_Vec3d (RealLast(), RealLast(), RealLast()));
806 //=============================================================================
807 //function : addTransformed
809 //=============================================================================
810 void Graphic3d_Structure::addTransformed (Graphic3d_BndBox3d& theBox,
811 const Standard_Boolean theToIgnoreInfiniteFlag) const
813 Graphic3d_BndBox3d aCombinedBox, aBox;
814 getBox (aCombinedBox, theToIgnoreInfiniteFlag);
816 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
818 const Graphic3d_Structure* aStruct = anIter.Value();
819 aStruct->getBox (aBox, theToIgnoreInfiniteFlag);
820 aCombinedBox.Combine (aBox);
826 if (!myCStructure->Transformation().IsNull())
828 TransformBoundaries (myCStructure->Transformation()->Trsf(),
829 aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
830 aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
833 // if box is still valid after transformation
836 theBox.Combine (aBox);
838 else // it was infinite, return untransformed
840 theBox.Combine (aCombinedBox);
845 //=============================================================================
846 //function : Transforms
848 //=============================================================================
849 void Graphic3d_Structure::Transforms (const gp_Trsf& theTrsf,
850 const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ,
851 Standard_Real& theNewX, Standard_Real& theNewY, Standard_Real& theNewZ)
853 const Standard_Real aRL = RealLast();
854 const Standard_Real aRF = RealFirst();
858 if ((theX == aRF) || (theY == aRF) || (theZ == aRF)
859 || (theX == aRL) || (theY == aRL) || (theZ == aRL))
864 theTrsf.Transforms (theNewX, theNewY, theNewZ);
867 //=============================================================================
868 //function : Transforms
870 //=============================================================================
871 void Graphic3d_Structure::TransformBoundaries (const gp_Trsf& theTrsf,
872 Standard_Real& theXMin,
873 Standard_Real& theYMin,
874 Standard_Real& theZMin,
875 Standard_Real& theXMax,
876 Standard_Real& theYMax,
877 Standard_Real& theZMax)
879 Standard_Real aXMin, aYMin, aZMin, aXMax, aYMax, aZMax, anU, aV, aW;
881 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMin, theZMin, aXMin, aYMin, aZMin);
882 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMax, theZMax, aXMax, aYMax, aZMax);
884 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMin, theZMax, anU, aV, aW);
885 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
886 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
887 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
889 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMin, theZMax, anU, aV, aW);
890 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
891 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
892 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
894 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMin, theZMin, anU, aV, aW);
895 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
896 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
897 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
899 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMax, theZMin, anU, aV, aW);
900 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
901 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
902 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
904 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMax, theZMax, anU, aV, aW);
905 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
906 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
907 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
909 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMax, theZMin, anU, aV, aW);
910 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
911 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
912 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
922 //=============================================================================
925 //=============================================================================
926 void Graphic3d_Structure::Network (Graphic3d_Structure* theStructure,
927 const Graphic3d_TypeOfConnection theType,
928 NCollection_Map<Graphic3d_Structure*>& theSet)
930 theSet.Add (theStructure);
933 case Graphic3d_TOC_DESCENDANT:
935 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (theStructure->myDescendants); anIter.More(); anIter.Next())
937 Graphic3d_Structure::Network (anIter.Value(), theType, theSet);
941 case Graphic3d_TOC_ANCESTOR:
943 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (theStructure->myAncestors); anIter.More(); anIter.Next())
945 Graphic3d_Structure::Network (anIter.Value(), theType, theSet);
952 //=============================================================================
953 //function : PrintNetwork
955 //=============================================================================
956 void Graphic3d_Structure::PrintNetwork (const Handle(Graphic3d_Structure)& theStructure,
957 const Graphic3d_TypeOfConnection theType)
959 NCollection_Map<Graphic3d_Structure*> aSet;
960 Graphic3d_Structure::Network (theStructure.get(), theType, aSet);
961 for (NCollection_Map<Graphic3d_Structure*>::Iterator anIter (aSet); anIter.More(); anIter.Next())
963 std::cout << "\tIdent " << (anIter.Key())->Identification () << "\n";
965 std::cout << std::flush;
968 //=============================================================================
971 //=============================================================================
972 void Graphic3d_Structure::Update (const bool theUpdateLayer) const
979 myStructureManager->Update (theUpdateLayer ? myCStructure->ZLayer() : Graphic3d_ZLayerId_UNKNOWN);
982 //=======================================================================
983 //function : SetZLayer
985 //=======================================================================
986 void Graphic3d_Structure::SetZLayer (const Graphic3d_ZLayerId theLayerId)
988 // if the structure is not displayed, unable to change its display layer
992 myStructureManager->ChangeZLayer (this, theLayerId);
993 myCStructure->SetZLayer (theLayerId);
996 //=======================================================================
997 //function : DumpJson
999 //=======================================================================
1000 void Graphic3d_Structure::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
1002 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
1004 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStructureManager)
1005 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myCStructure.get())
1007 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myAncestors); anIter.More(); anIter.Next())
1009 Graphic3d_Structure* anAncestor = anIter.Value();
1010 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, anAncestor)
1013 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
1015 Graphic3d_Structure* aDescendant = anIter.Value();
1016 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, aDescendant)
1019 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myOwner)
1020 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myVisual)
1021 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myComputeVisual)