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 if (theLinkPrs->myVisual != Graphic3d_TOS_COMPUTED)
55 myVisual = theLinkPrs->myVisual;
57 myComputeVisual = theLinkPrs->myComputeVisual;
58 myCStructure = theLinkPrs->myCStructure->ShadowLink (theManager);
62 myCStructure = theManager->GraphicDriver()->CreateStructure (theManager);
66 //=============================================================================
67 //function : ~Graphic3d_Structure
69 //=============================================================================
70 Graphic3d_Structure::~Graphic3d_Structure()
72 // as myStructureManager can be already destroyed,
73 // avoid attempts to access it
74 myStructureManager = NULL;
78 //=============================================================================
81 //=============================================================================
82 void Graphic3d_Structure::clear (const Standard_Boolean theWithDestruction)
84 if (IsDeleted()) return;
86 // clean groups in graphics driver at first
87 GraphicClear (theWithDestruction);
89 myCStructure->ContainsFacet = 0;
90 myStructureManager->Clear (this, theWithDestruction);
95 //=======================================================================
96 //function : CalculateBoundBox
97 //purpose : Calculates AABB of a structure.
98 //=======================================================================
99 void Graphic3d_Structure::CalculateBoundBox()
101 Graphic3d_BndBox3d aBox;
102 addTransformed (aBox, Standard_True);
103 myCStructure->ChangeBoundingBox() = aBox;
106 //=============================================================================
109 //=============================================================================
110 void Graphic3d_Structure::Remove()
112 if (IsDeleted()) return;
114 // clean groups in graphics driver at first; this is also should be done
115 // to avoid unwanted group cleaning in group's destructor
116 // Pass Standard_False to Clear(..) method to avoid updating in
117 // structure manager, it isn't necessary, besides of it structure manager
118 // could be already destroyed and invalid pointers used in structure;
119 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
121 aGroupIter.ChangeValue()->Clear (Standard_False);
124 // It is necessary to remove the eventual pointer on the structure that can be destroyed, in the list of descendants
125 // of ancestors of this structure and in the list of ancestors of descendants of the same structure.
126 for (Standard_Integer aStructIdx = 1, aNbDesc = myDescendants.Size(); aStructIdx <= aNbDesc; ++aStructIdx)
128 myDescendants.FindKey (aStructIdx)->Remove (this, Graphic3d_TOC_ANCESTOR);
131 for (Standard_Integer aStructIdx = 1, aNbAnces = myAncestors.Size(); aStructIdx <= aNbAnces; ++aStructIdx)
133 myAncestors.FindKey (aStructIdx)->Remove (this, Graphic3d_TOC_DESCENDANT);
136 // Destruction of me in the graphic library
137 const Standard_Integer aStructId = myCStructure->Id;
138 myCStructure->GraphicDriver()->RemoveIdentification(aStructId);
139 myCStructure->GraphicDriver()->RemoveStructure (myCStructure);
140 myCStructure.Nullify();
143 //=============================================================================
146 //=============================================================================
147 void Graphic3d_Structure::Display()
149 if (IsDeleted()) return;
151 if (!myCStructure->stick)
153 myCStructure->stick = 1;
154 myStructureManager->Display (this);
157 if (myCStructure->visible != 1)
159 myCStructure->visible = 1;
160 myCStructure->OnVisibilityChanged();
164 //=============================================================================
165 //function : SetDisplayPriority
167 //=============================================================================
168 void Graphic3d_Structure::SetDisplayPriority (const Standard_Integer thePriority)
171 || thePriority == myCStructure->Priority)
176 myCStructure->PreviousPriority = myCStructure->Priority;
177 myCStructure->Priority = thePriority;
179 if (myCStructure->Priority != myCStructure->PreviousPriority)
181 Graphic3d_PriorityDefinitionError_Raise_if ((myCStructure->Priority > Structure_MAX_PRIORITY)
182 || (myCStructure->Priority < Structure_MIN_PRIORITY),
183 "Bad value for StructurePriority");
184 if (myCStructure->stick)
186 myStructureManager->ChangeDisplayPriority (this, myCStructure->PreviousPriority, myCStructure->Priority);
191 //=============================================================================
192 //function : ResetDisplayPriority
194 //=============================================================================
195 void Graphic3d_Structure::ResetDisplayPriority()
198 || myCStructure->Priority == myCStructure->PreviousPriority)
203 const Standard_Integer aPriority = myCStructure->Priority;
204 myCStructure->Priority = myCStructure->PreviousPriority;
205 if (myCStructure->stick)
207 myStructureManager->ChangeDisplayPriority (this, aPriority, myCStructure->Priority);
211 //=============================================================================
214 //=============================================================================
215 void Graphic3d_Structure::erase()
222 if (myCStructure->stick)
224 myCStructure->stick = 0;
225 myStructureManager->Erase (this);
229 //=============================================================================
230 //function : Highlight
232 //=============================================================================
233 void Graphic3d_Structure::Highlight (const Handle(Graphic3d_PresentationAttributes)& theStyle,
234 const Standard_Boolean theToUpdateMgr)
241 SetDisplayPriority (Structure_MAX_PRIORITY - 1);
243 myCStructure->GraphicHighlight (theStyle);
250 if (myCStructure->stick)
252 myStructureManager->Highlight (this);
258 //=============================================================================
259 //function : SetVisible
261 //=============================================================================
262 void Graphic3d_Structure::SetVisible (const Standard_Boolean theValue)
264 if (IsDeleted()) return;
266 const unsigned isVisible = theValue ? 1 : 0;
267 if (myCStructure->visible == isVisible)
272 myCStructure->visible = isVisible;
273 myCStructure->OnVisibilityChanged();
277 //=============================================================================
278 //function : UnHighlight
280 //=============================================================================
281 void Graphic3d_Structure::UnHighlight()
283 if (IsDeleted()) return;
285 if (myCStructure->highlight)
287 myCStructure->highlight = 0;
289 myCStructure->GraphicUnhighlight();
290 myStructureManager->UnHighlight (this);
292 ResetDisplayPriority();
297 //=============================================================================
298 //function : ContainsFacet
300 //=============================================================================
301 Standard_Boolean Graphic3d_Structure::ContainsFacet() const
305 return Standard_False;
307 else if (myCStructure->ContainsFacet > 0)
309 // if one of groups contains at least one facet, the structure contains it too
310 return Standard_True;
313 // stop at the first descendant containing at least one facet
314 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
316 if (anIter.Value()->ContainsFacet())
318 return Standard_True;
321 return Standard_False;
324 //=============================================================================
327 //=============================================================================
328 Standard_Boolean Graphic3d_Structure::IsEmpty() const
332 return Standard_True;
335 // structure is empty:
336 // - if all these groups are empty
337 // - or if all groups are empty and all their descendants are empty
338 // - or if all its descendants are empty
339 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
341 if (!aGroupIter.Value()->IsEmpty())
343 return Standard_False;
347 // stop at the first non-empty descendant
348 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
350 if (!anIter.Value()->IsEmpty())
352 return Standard_False;
355 return Standard_True;
358 //=============================================================================
359 //function : GroupsWithFacet
361 //=============================================================================
362 void Graphic3d_Structure::GroupsWithFacet (const Standard_Integer theDelta)
364 myCStructure->ContainsFacet = myCStructure->ContainsFacet + theDelta;
365 if (myCStructure->ContainsFacet < 0)
367 myCStructure->ContainsFacet = 0;
371 //=============================================================================
372 //function : ReCompute
374 //=============================================================================
375 void Graphic3d_Structure::ReCompute()
377 myStructureManager->ReCompute (this);
380 //=============================================================================
381 //function : ReCompute
383 //=============================================================================
384 void Graphic3d_Structure::ReCompute (const Handle(Graphic3d_DataStructureManager)& theProjector)
386 myStructureManager->ReCompute (this, theProjector);
389 //=============================================================================
390 //function : GraphicClear
392 //=============================================================================
393 void Graphic3d_Structure::GraphicClear (const Standard_Boolean theWithDestruction)
395 if (myCStructure.IsNull())
400 // clean and empty each group
401 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
403 aGroupIter.ChangeValue()->Clear();
405 if (!theWithDestruction)
410 while (!myCStructure->Groups().IsEmpty())
412 Handle(Graphic3d_Group) aGroup = myCStructure->Groups().First();
415 myCStructure->Clear();
418 //=============================================================================
419 //function : SetVisual
421 //=============================================================================
422 void Graphic3d_Structure::SetVisual (const Graphic3d_TypeOfStructure theVisual)
425 || myVisual == theVisual)
430 if (!myCStructure->stick)
432 myVisual = theVisual;
433 SetComputeVisual (theVisual);
438 myVisual = theVisual;
439 SetComputeVisual (theVisual);
444 //=============================================================================
445 //function : SetZoomLimit
447 //=============================================================================
448 void Graphic3d_Structure::SetZoomLimit (const Standard_Real theLimitInf,
449 const Standard_Real theLimitSup)
453 Graphic3d_StructureDefinitionError_Raise_if (theLimitInf <= 0.0,
454 "Bad value for ZoomLimit inf");
455 Graphic3d_StructureDefinitionError_Raise_if (theLimitSup <= 0.0,
456 "Bad value for ZoomLimit sup");
457 Graphic3d_StructureDefinitionError_Raise_if (theLimitSup < theLimitInf,
458 "ZoomLimit sup < ZoomLimit inf");
461 //=============================================================================
462 //function : AcceptConnection
464 //=============================================================================
465 Standard_Boolean Graphic3d_Structure::AcceptConnection (Graphic3d_Structure* theStructure1,
466 Graphic3d_Structure* theStructure2,
467 Graphic3d_TypeOfConnection theType)
470 NCollection_Map<Graphic3d_Structure*> aSet;
471 Graphic3d_Structure::Network (theStructure2, theType, aSet);
472 return !aSet.Contains (theStructure1);
475 //=============================================================================
476 //function : Ancestors
478 //=============================================================================
479 void Graphic3d_Structure::Ancestors (Graphic3d_MapOfStructure& theSet) const
481 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myAncestors); anIter.More(); anIter.Next())
483 theSet.Add (anIter.Value());
487 //=============================================================================
488 //function : Descendants
490 //=============================================================================
491 void Graphic3d_Structure::Descendants (Graphic3d_MapOfStructure& theSet) const
493 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
495 theSet.Add (anIter.Value());
499 //=============================================================================
500 //function : AppendAncestor
502 //=============================================================================
503 Standard_Boolean Graphic3d_Structure::AppendAncestor (Graphic3d_Structure* theAncestor)
505 const Standard_Integer aSize = myAncestors.Size();
507 return myAncestors.Add (theAncestor) > aSize; // new object
510 //=============================================================================
511 //function : AppendDescendant
513 //=============================================================================
514 Standard_Boolean Graphic3d_Structure::AppendDescendant (Graphic3d_Structure* theDescendant)
516 const Standard_Integer aSize = myDescendants.Size();
518 return myDescendants.Add (theDescendant) > aSize; // new object
521 //=============================================================================
522 //function : RemoveAncestor
524 //=============================================================================
525 Standard_Boolean Graphic3d_Structure::RemoveAncestor (Graphic3d_Structure* theAncestor)
527 const Standard_Integer anIndex = myAncestors.FindIndex (theAncestor);
531 myAncestors.Swap (anIndex, myAncestors.Size());
532 myAncestors.RemoveLast();
535 return anIndex != 0; // object was found
538 //=============================================================================
539 //function : RemoveDescendant
541 //=============================================================================
542 Standard_Boolean Graphic3d_Structure::RemoveDescendant (Graphic3d_Structure* theDescendant)
544 const Standard_Integer anIndex = myDescendants.FindIndex (theDescendant);
548 myDescendants.Swap (anIndex, myDescendants.Size());
549 myDescendants.RemoveLast();
552 return anIndex != 0; // object was found
555 //=============================================================================
558 //=============================================================================
559 void Graphic3d_Structure::Connect (Graphic3d_Structure* theStructure,
560 Graphic3d_TypeOfConnection theType,
561 Standard_Boolean theWithCheck)
570 && !Graphic3d_Structure::AcceptConnection (this, theStructure, theType))
575 if (theType == Graphic3d_TOC_DESCENDANT)
577 if (!AppendDescendant (theStructure))
583 theStructure->Connect (this, Graphic3d_TOC_ANCESTOR);
585 GraphicConnect (theStructure);
586 myStructureManager->Connect (this, theStructure);
590 else // Graphic3d_TOC_ANCESTOR
592 if (!AppendAncestor (theStructure))
598 theStructure->Connect (this, Graphic3d_TOC_DESCENDANT);
600 // myStructureManager->Connect is called in case if connection between parent and child
604 //=============================================================================
605 //function : Disconnect
607 //=============================================================================
608 void Graphic3d_Structure::Disconnect (Graphic3d_Structure* theStructure)
615 if (RemoveDescendant (theStructure))
617 theStructure->Disconnect (this);
619 GraphicDisconnect (theStructure);
620 myStructureManager->Disconnect (this, theStructure);
625 else if (RemoveAncestor (theStructure))
627 theStructure->Disconnect (this);
630 // no call of myStructureManager->Disconnect in case of an ancestor
634 //=============================================================================
635 //function : DisconnectAll
637 //=============================================================================
638 void Graphic3d_Structure::DisconnectAll (const Graphic3d_TypeOfConnection theType)
640 if (IsDeleted()) return;
644 case Graphic3d_TOC_DESCENDANT:
646 for (Standard_Integer anIdx = 1, aLength = myDescendants.Size(); anIdx <= aLength; ++anIdx)
648 // Value (1) instead of Value (i) as myDescendants
650 // Graphic3d_Structure::Disconnect (AStructure)
651 // that takes AStructure from myDescendants
652 myDescendants.FindKey (1)->Disconnect (this);
656 case Graphic3d_TOC_ANCESTOR:
658 for (Standard_Integer anIdx = 1, aLength = myAncestors.Size(); anIdx <= aLength; ++anIdx)
660 // Value (1) instead of Value (i) as myAncestors
662 // Graphic3d_Structure::Disconnect (AStructure)
663 // that takes AStructure from myAncestors
664 myAncestors.FindKey (1)->Disconnect (this);
671 //=============================================================================
672 //function : SetTransform
674 //=============================================================================
675 void Graphic3d_Structure::SetTransformation (const Handle(TopLoc_Datum3D)& theTrsf)
677 if (IsDeleted()) return;
679 const Standard_Boolean wasTransformed = IsTransformed();
681 if (!theTrsf.IsNull()
682 && theTrsf->Trsf().Form() == gp_Identity)
684 myCStructure->SetTransformation (Handle(TopLoc_Datum3D)());
688 myCStructure->SetTransformation (theTrsf);
691 // If transformation, no validation of hidden already calculated parts
692 if (IsTransformed() || (!IsTransformed() && wasTransformed))
697 myStructureManager->SetTransform (this, theTrsf);
702 //=============================================================================
703 //function : MinMaxValues
705 //=============================================================================
706 Bnd_Box Graphic3d_Structure::MinMaxValues (const Standard_Boolean theToIgnoreInfiniteFlag) const
708 Graphic3d_BndBox3d aBox;
709 addTransformed (aBox, theToIgnoreInfiniteFlag);
716 aResult.Update (aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
717 aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
719 Standard_Real aLimMin = ShortRealFirst() + 1.0;
720 Standard_Real aLimMax = ShortRealLast() - 1.0;
721 gp_Pnt aMin = aResult.CornerMin();
722 gp_Pnt aMax = aResult.CornerMax();
723 if (aMin.X() < aLimMin && aMin.Y() < aLimMin && aMin.Z() < aLimMin
724 && aMax.X() > aLimMax && aMax.Y() > aLimMax && aMax.Z() > aLimMax)
726 //For structure which infinite in all three dimensions the Whole bounding box will be returned
732 //=============================================================================
733 //function : SetTransformPersistence
735 //=============================================================================
736 void Graphic3d_Structure::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
743 myCStructure->SetTransformPersistence (theTrsfPers);
746 //=============================================================================
749 //=============================================================================
750 void Graphic3d_Structure::Remove (Graphic3d_Structure* thePtr,
751 const Graphic3d_TypeOfConnection theType)
753 if (theType == Graphic3d_TOC_DESCENDANT)
755 RemoveDescendant (thePtr);
759 RemoveAncestor (thePtr);
763 //=============================================================================
764 //function : NewGroup
766 //=============================================================================
767 Handle(Graphic3d_Group) Graphic3d_Structure::NewGroup()
769 return myCStructure->NewGroup (this);
772 //=============================================================================
775 //=============================================================================
776 void Graphic3d_Structure::Remove (const Handle(Graphic3d_Group)& theGroup)
778 if (theGroup.IsNull()
779 || theGroup->myStructure != this)
784 myCStructure->RemoveGroup (theGroup);
785 theGroup->myStructure = NULL;
788 //=============================================================================
789 //function : StructureManager
791 //=============================================================================
792 Handle(Graphic3d_StructureManager) Graphic3d_Structure::StructureManager() const
794 return myStructureManager;
797 //=============================================================================
798 //function : minMaxCoord
800 //=============================================================================
801 Graphic3d_BndBox4f Graphic3d_Structure::minMaxCoord() const
803 Graphic3d_BndBox4f aBnd;
804 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
806 aBnd.Combine (aGroupIter.Value()->BoundingBox());
811 //=============================================================================
812 //function : addTransformed
814 //=============================================================================
815 void Graphic3d_Structure::getBox (Graphic3d_BndBox3d& theBox,
816 const Standard_Boolean theToIgnoreInfiniteFlag) const
818 Graphic3d_BndBox4f aBoxF = minMaxCoord();
821 theBox = Graphic3d_BndBox3d (Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMin().x(),
822 (Standard_Real )aBoxF.CornerMin().y(),
823 (Standard_Real )aBoxF.CornerMin().z()),
824 Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMax().x(),
825 (Standard_Real )aBoxF.CornerMax().y(),
826 (Standard_Real )aBoxF.CornerMax().z()));
828 && !theToIgnoreInfiniteFlag)
830 const Graphic3d_Vec3d aDiagVec = theBox.CornerMax() - theBox.CornerMin();
831 if (aDiagVec.SquareModulus() >= 500000.0 * 500000.0)
833 // bounding borders of infinite line has been calculated as own point in center of this line
834 theBox = Graphic3d_BndBox3d ((theBox.CornerMin() + theBox.CornerMax()) * 0.5);
838 theBox = Graphic3d_BndBox3d (Graphic3d_Vec3d (RealFirst(), RealFirst(), RealFirst()),
839 Graphic3d_Vec3d (RealLast(), RealLast(), RealLast()));
846 //=============================================================================
847 //function : addTransformed
849 //=============================================================================
850 void Graphic3d_Structure::addTransformed (Graphic3d_BndBox3d& theBox,
851 const Standard_Boolean theToIgnoreInfiniteFlag) const
853 Graphic3d_BndBox3d aCombinedBox, aBox;
854 getBox (aCombinedBox, theToIgnoreInfiniteFlag);
856 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
858 const Graphic3d_Structure* aStruct = anIter.Value();
859 aStruct->getBox (aBox, theToIgnoreInfiniteFlag);
860 aCombinedBox.Combine (aBox);
866 if (!myCStructure->Transformation().IsNull())
868 TransformBoundaries (myCStructure->Transformation()->Trsf(),
869 aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
870 aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
873 // if box is still valid after transformation
876 theBox.Combine (aBox);
878 else // it was infinite, return untransformed
880 theBox.Combine (aCombinedBox);
885 //=============================================================================
886 //function : Transforms
888 //=============================================================================
889 void Graphic3d_Structure::Transforms (const gp_Trsf& theTrsf,
890 const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ,
891 Standard_Real& theNewX, Standard_Real& theNewY, Standard_Real& theNewZ)
893 const Standard_Real aRL = RealLast();
894 const Standard_Real aRF = RealFirst();
898 if ((theX == aRF) || (theY == aRF) || (theZ == aRF)
899 || (theX == aRL) || (theY == aRL) || (theZ == aRL))
904 theTrsf.Transforms (theNewX, theNewY, theNewZ);
907 //=============================================================================
908 //function : Transforms
910 //=============================================================================
911 void Graphic3d_Structure::TransformBoundaries (const gp_Trsf& theTrsf,
912 Standard_Real& theXMin,
913 Standard_Real& theYMin,
914 Standard_Real& theZMin,
915 Standard_Real& theXMax,
916 Standard_Real& theYMax,
917 Standard_Real& theZMax)
919 Standard_Real aXMin, aYMin, aZMin, aXMax, aYMax, aZMax, anU, aV, aW;
921 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMin, theZMin, aXMin, aYMin, aZMin);
922 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMax, theZMax, aXMax, aYMax, aZMax);
924 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMin, theZMax, anU, aV, aW);
925 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
926 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
927 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
929 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMin, theZMax, anU, aV, aW);
930 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
931 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
932 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
934 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMin, theZMin, anU, aV, aW);
935 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
936 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
937 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
939 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMax, theZMin, anU, aV, aW);
940 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
941 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
942 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
944 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMax, theZMax, anU, aV, aW);
945 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
946 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
947 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
949 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMax, theZMin, anU, aV, aW);
950 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
951 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
952 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
962 //=============================================================================
965 //=============================================================================
966 void Graphic3d_Structure::Network (Graphic3d_Structure* theStructure,
967 const Graphic3d_TypeOfConnection theType,
968 NCollection_Map<Graphic3d_Structure*>& theSet)
970 theSet.Add (theStructure);
973 case Graphic3d_TOC_DESCENDANT:
975 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (theStructure->myDescendants); anIter.More(); anIter.Next())
977 Graphic3d_Structure::Network (anIter.Value(), theType, theSet);
981 case Graphic3d_TOC_ANCESTOR:
983 for (NCollection_IndexedMap<Graphic3d_Structure*>::Iterator anIter (theStructure->myAncestors); anIter.More(); anIter.Next())
985 Graphic3d_Structure::Network (anIter.Value(), theType, theSet);
992 //=============================================================================
993 //function : PrintNetwork
995 //=============================================================================
996 void Graphic3d_Structure::PrintNetwork (const Handle(Graphic3d_Structure)& theStructure,
997 const Graphic3d_TypeOfConnection theType)
999 NCollection_Map<Graphic3d_Structure*> aSet;
1000 Graphic3d_Structure::Network (theStructure.get(), theType, aSet);
1001 for (NCollection_Map<Graphic3d_Structure*>::Iterator anIter (aSet); anIter.More(); anIter.Next())
1003 std::cout << "\tIdent " << (anIter.Key())->Identification () << "\n";
1005 std::cout << std::flush;
1008 //=============================================================================
1011 //=============================================================================
1012 void Graphic3d_Structure::Update (const bool theUpdateLayer) const
1019 myStructureManager->Update (theUpdateLayer ? myCStructure->ZLayer() : Graphic3d_ZLayerId_UNKNOWN);
1022 //=======================================================================
1023 //function : SetZLayer
1025 //=======================================================================
1026 void Graphic3d_Structure::SetZLayer (const Graphic3d_ZLayerId theLayerId)
1028 // if the structure is not displayed, unable to change its display layer
1032 myStructureManager->ChangeZLayer (this, theLayerId);
1033 myCStructure->SetZLayer (theLayerId);
1036 //=======================================================================
1037 //function : DumpJson
1039 //=======================================================================
1040 void Graphic3d_Structure::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
1042 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
1044 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myCStructure.get())
1046 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myVisual)
1047 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myComputeVisual)