0025695: Visualization, AIS_InteractiveContext - define default HilightMode
[occt.git] / src / Graphic3d / Graphic3d_Structure.cxx
CommitLineData
b311480e 1// Created by: NW,JPB,CAL
2// Copyright (c) 1991-1999 Matra Datavision
973c2be1 3// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
2831708b 16#include <Graphic3d_Structure.hxx>
7fd59977 17
42cf5bc1 18#include <Bnd_Box.hxx>
19#include <gp_Pnt.hxx>
42cf5bc1 20#include <Graphic3d_DataStructureManager.hxx>
7fd59977 21#include <Graphic3d_GraphicDriver.hxx>
42cf5bc1 22#include <Graphic3d_Group.hxx>
7fd59977 23#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
42cf5bc1 24#include <Graphic3d_MapOfStructure.hxx>
42cf5bc1 25#include <Graphic3d_PriorityDefinitionError.hxx>
42cf5bc1 26#include <Graphic3d_StructureDefinitionError.hxx>
27#include <Graphic3d_StructureManager.hxx>
42cf5bc1 28#include <Graphic3d_TransformError.hxx>
29#include <Graphic3d_Vector.hxx>
7fd59977 30#include <Quantity_Color.hxx>
42cf5bc1 31#include <Standard_Type.hxx>
7fd59977 32
2831708b 33#include "Graphic3d_Structure.pxx"
34
63bcc448 35#include <stdio.h>
2831708b 36
92efcf78 37IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Structure,MMgt_TShared)
38
63bcc448 39//=============================================================================
40//function : Graphic3d_Structure
41//purpose :
42//=============================================================================
43Graphic3d_Structure::Graphic3d_Structure (const Handle(Graphic3d_StructureManager)& theManager)
44: myStructureManager (theManager.operator->()),
45 myFirstStructureManager (theManager.operator->()),
46 myComputeVisual (Graphic3d_TOS_ALL),
63bcc448 47 myOwner (NULL),
48 myVisual (Graphic3d_TOS_ALL)
7fd59977 49{
c357e426 50 myCStructure = theManager->GraphicDriver()->CreateStructure (theManager);
7fd59977 51}
52
63bcc448 53//=============================================================================
679ecdee 54//function : Graphic3d_Structure
55//purpose :
56//=============================================================================
57Graphic3d_Structure::Graphic3d_Structure (const Handle(Graphic3d_StructureManager)& theManager,
58 const Handle(Graphic3d_Structure)& thePrs)
59: myStructureManager (theManager.operator->()),
60 myFirstStructureManager (theManager.operator->()),
61 myComputeVisual (thePrs->myComputeVisual),
679ecdee 62 myOwner (thePrs->myOwner),
63 myVisual (thePrs->myVisual)
64{
65 myCStructure = thePrs->myCStructure->ShadowLink (theManager);
679ecdee 66}
67
68//=============================================================================
e6f550da 69//function : ~Graphic3d_Structure
63bcc448 70//purpose :
71//=============================================================================
e6f550da 72Graphic3d_Structure::~Graphic3d_Structure()
63bcc448 73{
74 // as myFirstStructureManager can be already destroyed,
bbf32d01 75 // avoid attempts to access it
63bcc448 76 myFirstStructureManager = NULL;
77 Remove();
7fd59977 78}
79
63bcc448 80//=============================================================================
81//function : Clear
82//purpose :
83//=============================================================================
84void Graphic3d_Structure::Clear (const Standard_Boolean theWithDestruction)
98178592
A
85{
86 if (IsDeleted()) return;
7fd59977 87
98178592 88 // clean groups in graphics driver at first
63bcc448 89 GraphicClear (theWithDestruction);
7fd59977 90
b64d84be 91 myCStructure->ContainsFacet = 0;
63bcc448 92 myStructureManager->Clear (this, theWithDestruction);
7fd59977 93
50d06d8f 94 Update (true);
7fd59977 95}
96
b7cd4ba7 97//=======================================================================
98//function : CalculateBoundBox
99//purpose : Calculates AABB of a structure.
100//=======================================================================
101void Graphic3d_Structure::CalculateBoundBox()
102{
7c3ef2f7 103 Graphic3d_BndBox3d aBox;
b7cd4ba7 104 addTransformed (aBox, Standard_True);
7c3ef2f7 105 myCStructure->ChangeBoundingBox() = aBox;
b7cd4ba7 106}
107
63bcc448 108//=============================================================================
109//function : Remove
110//purpose :
111//=============================================================================
112void Graphic3d_Structure::Remove()
113{
114 if (IsDeleted()) return;
98178592 115
6c8126b5
A
116 // clean groups in graphics driver at first; this is also should be done
117 // to avoid unwanted group cleaning in group's destructor
118 // Pass Standard_False to Clear(..) method to avoid updating in
119 // structure manager, it isn't necessary, besides of it structure manager
120 // could be already destroyed and invalid pointers used in structure;
b64d84be 121 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
122 {
123 aGroupIter.ChangeValue()->Clear (Standard_False);
124 }
98178592 125
7fd59977 126 Standard_Address APtr = (void *) this;
81bba717 127 // It is necessary to remove the eventual pointer on the structure
128 // that can be destroyed, in the list of descendants
b64d84be 129 // of ancestors of this structure and in the list of ancestors
81bba717 130 // of descendants of the same structure.
7fd59977 131
602d1ead 132 for (Standard_Integer aStructIdx = 1, aNbDesc = myDescendants.Size(); aStructIdx <= aNbDesc; ++aStructIdx)
63bcc448 133 {
602d1ead 134 ((Graphic3d_Structure *)myDescendants.FindKey (aStructIdx))->Remove (APtr, Graphic3d_TOC_ANCESTOR);
63bcc448 135 }
7fd59977 136
602d1ead 137 for (Standard_Integer aStructIdx = 1, aNbAnces = myAncestors.Size(); aStructIdx <= aNbAnces; ++aStructIdx)
63bcc448 138 {
602d1ead 139 ((Graphic3d_Structure *)myAncestors.FindKey (aStructIdx))->Remove (APtr, Graphic3d_TOC_DESCENDANT);
63bcc448 140 }
7fd59977 141
81bba717 142 // Destruction of me in the graphic library
63bcc448 143 const Standard_Integer aStructId = myCStructure->Id;
016e5959 144 myCStructure->GraphicDriver()->RemoveIdentification(aStructId);
63bcc448 145 myCStructure->GraphicDriver()->RemoveStructure (myCStructure);
146 myCStructure.Nullify();
7fd59977 147}
148
63bcc448 149//=============================================================================
150//function : Display
151//purpose :
152//=============================================================================
153void Graphic3d_Structure::Display()
154{
155 if (IsDeleted()) return;
7fd59977 156
63bcc448 157 if (!myCStructure->stick)
158 {
159 myCStructure->stick = 1;
160 myStructureManager->Display (this);
7fd59977 161 }
162
a1954302 163 if (myCStructure->visible != 1)
164 {
165 myCStructure->visible = 1;
166 myCStructure->OnVisibilityChanged();
167 }
7fd59977 168}
169
63bcc448 170//=============================================================================
b7cd4ba7 171//function : SetIsForHighlight
172//purpose :
173//=============================================================================
174void Graphic3d_Structure::SetIsForHighlight (const Standard_Boolean isForHighlight)
175{
176 myCStructure->IsForHighlight = isForHighlight;
177}
178
179//=============================================================================
63bcc448 180//function : SetDisplayPriority
181//purpose :
182//=============================================================================
183void Graphic3d_Structure::SetDisplayPriority (const Standard_Integer thePriority)
184{
185 if (IsDeleted()
186 || thePriority == myCStructure->Priority)
187 {
188 return;
189 }
7fd59977 190
63bcc448 191 myCStructure->PreviousPriority = myCStructure->Priority;
192 myCStructure->Priority = thePriority;
7fd59977 193
63bcc448 194 if (myCStructure->Priority != myCStructure->PreviousPriority)
195 {
196 Graphic3d_PriorityDefinitionError_Raise_if ((myCStructure->Priority > Structure_MAX_PRIORITY)
197 || (myCStructure->Priority < Structure_MIN_PRIORITY),
198 "Bad value for StructurePriority");
199 if (myCStructure->stick)
200 {
201 myStructureManager->ChangeDisplayPriority (this, myCStructure->PreviousPriority, myCStructure->Priority);
202 }
7fd59977 203 }
7fd59977 204}
205
63bcc448 206//=============================================================================
207//function : ResetDisplayPriority
208//purpose :
209//=============================================================================
210void Graphic3d_Structure::ResetDisplayPriority()
211{
212 if (IsDeleted()
213 || myCStructure->Priority == myCStructure->PreviousPriority)
214 {
215 return;
7fd59977 216 }
217
63bcc448 218 const Standard_Integer aPriority = myCStructure->Priority;
219 myCStructure->Priority = myCStructure->PreviousPriority;
220 if (myCStructure->stick)
221 {
222 myStructureManager->ChangeDisplayPriority (this, aPriority, myCStructure->Priority);
223 }
7fd59977 224}
7fd59977 225
63bcc448 226//=============================================================================
227//function : DisplayPriority
228//purpose :
229//=============================================================================
230Standard_Integer Graphic3d_Structure::DisplayPriority() const
231{
232 return myCStructure->Priority;
7fd59977 233}
234
63bcc448 235//=============================================================================
236//function : Erase
237//purpose :
238//=============================================================================
239void Graphic3d_Structure::Erase()
240{
241 if (IsDeleted())
242 {
243 return;
7fd59977 244 }
245
63bcc448 246 if (myCStructure->stick)
247 {
248 myCStructure->stick = 0;
249 myStructureManager->Erase (this);
250 }
7fd59977 251}
252
63bcc448 253//=============================================================================
254//function : Highlight
255//purpose :
256//=============================================================================
f838dac4 257void Graphic3d_Structure::Highlight (const Handle(Graphic3d_PresentationAttributes)& theStyle,
258 const Standard_Boolean theToUpdateMgr)
63bcc448 259{
260 if (IsDeleted())
261 {
262 return;
263 }
7fd59977 264
63bcc448 265 SetDisplayPriority (Structure_MAX_PRIORITY - 1);
7fd59977 266
8e5fb5ea 267 myCStructure->GraphicHighlight (theStyle, this);
7fd59977 268
a1954302 269 if (!theToUpdateMgr)
63bcc448 270 {
271 return;
272 }
7fd59977 273
a1954302 274 if (myCStructure->stick)
63bcc448 275 {
8e5fb5ea 276 myStructureManager->Highlight (this);
7fd59977 277 }
278
a1954302 279 Update();
7fd59977 280}
281
63bcc448 282//=============================================================================
283//function : SetVisible
284//purpose :
285//=============================================================================
286void Graphic3d_Structure::SetVisible (const Standard_Boolean theValue)
287{
288 if (IsDeleted()) return;
7fd59977 289
a1954302 290 const unsigned isVisible = theValue ? 1 : 0;
291 if (myCStructure->visible == isVisible)
63bcc448 292 {
a1954302 293 return;
63bcc448 294 }
a1954302 295
296 myCStructure->visible = isVisible;
297 myCStructure->OnVisibilityChanged();
50d06d8f 298 Update (true);
7fd59977 299}
300
63bcc448 301//=============================================================================
302//function : UnHighlight
303//purpose :
304//=============================================================================
305void Graphic3d_Structure::UnHighlight()
306{
307 if (IsDeleted()) return;
7fd59977 308
63bcc448 309 if (myCStructure->highlight)
310 {
311 myCStructure->highlight = 0;
7fd59977 312
8e5fb5ea 313 myCStructure->GraphicUnhighlight();
63bcc448 314 myStructureManager->UnHighlight (this);
7fd59977 315
7fd59977 316 ResetDisplayPriority();
63bcc448 317 Update();
7fd59977 318 }
7fd59977 319}
320
63bcc448 321//=============================================================================
8e5fb5ea 322//function : HighlightStyle
63bcc448 323//purpose :
324//=============================================================================
f838dac4 325const Handle(Graphic3d_PresentationAttributes)& Graphic3d_Structure::HighlightStyle() const
63bcc448 326{
8e5fb5ea 327 return myCStructure->HighlightStyle();
7fd59977 328}
329
63bcc448 330//=============================================================================
331//function : IsDisplayed
332//purpose :
333//=============================================================================
334Standard_Boolean Graphic3d_Structure::IsDisplayed() const
335{
336 return myCStructure->stick ? Standard_True : Standard_False;
7fd59977 337}
338
63bcc448 339//=============================================================================
340//function : IsDeleted
341//purpose :
342//=============================================================================
343Standard_Boolean Graphic3d_Structure::IsDeleted() const
344{
345 return myCStructure.IsNull();
7fd59977 346}
347
63bcc448 348//=============================================================================
349//function : IsHighlighted
350//purpose :
351//=============================================================================
352Standard_Boolean Graphic3d_Structure::IsHighlighted() const
353{
354 return myCStructure->highlight ? Standard_True : Standard_False;
7fd59977 355}
356
63bcc448 357//=============================================================================
63bcc448 358//function : IsVisible
359//purpose :
360//=============================================================================
361Standard_Boolean Graphic3d_Structure::IsVisible() const
362{
363 return myCStructure->visible ? Standard_True : Standard_False;
7fd59977 364}
365
63bcc448 366//=============================================================================
63bcc448 367//function : IsTransformed
368//purpose :
369//=============================================================================
370Standard_Boolean Graphic3d_Structure::IsTransformed() const
371{
1f7f5a90 372 return !myCStructure->Transformation().IsNull()
373 && myCStructure->Transformation()->Form() != gp_Identity;
7fd59977 374}
375
63bcc448 376//=============================================================================
377//function : ContainsFacet
378//purpose :
379//=============================================================================
380Standard_Boolean Graphic3d_Structure::ContainsFacet() const
381{
382 if (IsDeleted())
383 {
384 return Standard_False;
385 }
386 else if (myCStructure->ContainsFacet > 0)
387 {
388 // if one of groups contains at least one facet, the structure contains it too
389 return Standard_True;
390 }
7fd59977 391
63bcc448 392 // stop at the first descendant containing at least one facet
602d1ead 393 for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
63bcc448 394 {
602d1ead 395 if (((const Graphic3d_Structure *)anIter.Value())->ContainsFacet())
63bcc448 396 {
397 return Standard_True;
398 }
399 }
400 return Standard_False;
7fd59977 401}
402
63bcc448 403//=============================================================================
404//function : IsEmpty
405//purpose :
406//=============================================================================
407Standard_Boolean Graphic3d_Structure::IsEmpty() const
408{
409 if (IsDeleted())
410 {
411 return Standard_True;
412 }
7fd59977 413
63bcc448 414 // structure is empty:
415 // - if all these groups are empty
416 // - or if all groups are empty and all their descendants are empty
417 // - or if all its descendants are empty
b64d84be 418 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
63bcc448 419 {
b64d84be 420 if (!aGroupIter.Value()->IsEmpty())
63bcc448 421 {
422 return Standard_False;
423 }
424 }
7fd59977 425
63bcc448 426 // stop at the first non-empty descendant
602d1ead 427 for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
63bcc448 428 {
602d1ead 429 if (!((const Graphic3d_Structure* )anIter.Value())->IsEmpty())
63bcc448 430 {
431 return Standard_False;
432 }
433 }
434 return Standard_True;
7fd59977 435}
436
63bcc448 437//=============================================================================
63bcc448 438//function : GroupsWithFacet
439//purpose :
440//=============================================================================
441void Graphic3d_Structure::GroupsWithFacet (const Standard_Integer theDelta)
442{
443 myCStructure->ContainsFacet = myCStructure->ContainsFacet + theDelta;
444 if (myCStructure->ContainsFacet < 0)
445 {
446 myCStructure->ContainsFacet = 0;
447 }
7fd59977 448}
449
63bcc448 450//=============================================================================
451//function : Compute
452//purpose :
453//=============================================================================
eb4320f2 454void Graphic3d_Structure::Compute()
455{
456 // Implemented by Presentation
457}
458
63bcc448 459//=============================================================================
460//function : Compute
461//purpose :
462//=============================================================================
463Handle(Graphic3d_Structure) Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& )
464{
7fd59977 465 // Implemented by Presentation
466 return this;
467}
468
63bcc448 469//=============================================================================
470//function : Compute
471//purpose :
472//=============================================================================
473Handle(Graphic3d_Structure) Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& ,
1f7f5a90 474 const Handle(Geom_Transformation)& )
63bcc448 475{
7fd59977 476 // Implemented by Presentation
477 return this;
478}
479
63bcc448 480//=============================================================================
481//function : Compute
482//purpose :
483//=============================================================================
484void Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& ,
485 Handle(Graphic3d_Structure)& )
486{
7fd59977 487 // Implemented by Presentation
488}
489
63bcc448 490//=============================================================================
491//function : Compute
492//purpose :
493//=============================================================================
494void Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& ,
1f7f5a90 495 const Handle(Geom_Transformation)& ,
63bcc448 496 Handle(Graphic3d_Structure)& )
497{
7fd59977 498 // Implemented by Presentation
499}
500
63bcc448 501//=============================================================================
502//function : ReCompute
503//purpose :
504//=============================================================================
505void Graphic3d_Structure::ReCompute()
506{
507 myStructureManager->ReCompute (this);
7fd59977 508}
509
63bcc448 510//=============================================================================
511//function : ReCompute
512//purpose :
513//=============================================================================
514void Graphic3d_Structure::ReCompute (const Handle(Graphic3d_DataStructureManager)& theProjector)
515{
516 myStructureManager->ReCompute (this, theProjector);
7fd59977 517}
518
197ac94e 519//=============================================================================
520//function : SetInfiniteState
521//purpose :
522//=============================================================================
523void Graphic3d_Structure::SetInfiniteState (const Standard_Boolean theToSet)
524{
63bcc448 525 myCStructure->IsInfinite = theToSet ? 1 : 0;
7fd59977 526}
527
63bcc448 528//=============================================================================
529//function : IsInfinite
530//purpose :
531//=============================================================================
532Standard_Boolean Graphic3d_Structure::IsInfinite() const
533{
534 return IsDeleted()
535 || myCStructure->IsInfinite;
7fd59977 536}
537
63bcc448 538//=============================================================================
539//function : GraphicClear
540//purpose :
541//=============================================================================
542void Graphic3d_Structure::GraphicClear (const Standard_Boolean theWithDestruction)
5e27df78 543{
b64d84be 544 if (myCStructure.IsNull())
5e27df78 545 {
b64d84be 546 return;
5e27df78 547 }
7fd59977 548
b64d84be 549 // clean and empty each group
550 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
5e27df78 551 {
b64d84be 552 aGroupIter.ChangeValue()->Clear();
553 }
554 if (!theWithDestruction)
555 {
556 return;
557 }
7fd59977 558
b64d84be 559 while (!myCStructure->Groups().IsEmpty())
560 {
561 Handle(Graphic3d_Group) aGroup = myCStructure->Groups().First();
562 aGroup->Remove();
7fd59977 563 }
b64d84be 564 myCStructure->Clear();
7fd59977 565}
566
63bcc448 567//=============================================================================
568//function : GraphicConnect
569//purpose :
570//=============================================================================
bf75be98 571void Graphic3d_Structure::GraphicConnect (const Handle(Graphic3d_Structure)& theDaughter)
572{
63bcc448 573 myCStructure->Connect (*theDaughter->myCStructure);
7fd59977 574}
575
63bcc448 576//=============================================================================
577//function : GraphicDisconnect
578//purpose :
579//=============================================================================
bf75be98 580void Graphic3d_Structure::GraphicDisconnect (const Handle(Graphic3d_Structure)& theDaughter)
581{
63bcc448 582 myCStructure->Disconnect (*theDaughter->myCStructure);
7fd59977 583}
584
63bcc448 585//=============================================================================
63bcc448 586//function : Groups
587//purpose :
588//=============================================================================
589const Graphic3d_SequenceOfGroup& Graphic3d_Structure::Groups() const
590{
b64d84be 591 return myCStructure->Groups();
7fd59977 592}
593
63bcc448 594//=============================================================================
595//function : NumberOfGroups
596//purpose :
597//=============================================================================
598Standard_Integer Graphic3d_Structure::NumberOfGroups() const
599{
b64d84be 600 return myCStructure->Groups().Length();
7fd59977 601}
602
63bcc448 603//=============================================================================
63bcc448 604//function : SetVisual
605//purpose :
606//=============================================================================
607void Graphic3d_Structure::SetVisual (const Graphic3d_TypeOfStructure theVisual)
608{
609 if (IsDeleted()
610 || myVisual == theVisual)
611 {
612 return;
7fd59977 613 }
7fd59977 614
63bcc448 615 if (!myCStructure->stick)
616 {
617 myVisual = theVisual;
618 SetComputeVisual (theVisual);
619 }
620 else
621 {
622 Aspect_TypeOfUpdate anUpdateMode = myStructureManager->UpdateMode();
623 if (anUpdateMode == Aspect_TOU_WAIT)
624 {
625 Erase();
626 myVisual = theVisual;
627 SetComputeVisual (theVisual);
628 Display();
7fd59977 629 }
630 else {
81bba717 631 // To avoid calling method : Update ()
632 // Not useful and can be costly.
63bcc448 633 myStructureManager->SetUpdateMode (Aspect_TOU_WAIT);
634 Erase();
635 myVisual = theVisual;
636 SetComputeVisual (theVisual);
637 myStructureManager->SetUpdateMode (anUpdateMode);
638 Display();
7fd59977 639 }
640 }
7fd59977 641}
642
63bcc448 643//=============================================================================
644//function : SetZoomLimit
645//purpose :
646//=============================================================================
647void Graphic3d_Structure::SetZoomLimit (const Standard_Real theLimitInf,
648 const Standard_Real theLimitSup)
649{
650 (void )theLimitInf;
651 (void )theLimitSup;
652 Graphic3d_StructureDefinitionError_Raise_if (theLimitInf <= 0.0,
653 "Bad value for ZoomLimit inf");
654 Graphic3d_StructureDefinitionError_Raise_if (theLimitSup <= 0.0,
655 "Bad value for ZoomLimit sup");
656 Graphic3d_StructureDefinitionError_Raise_if (theLimitSup < theLimitInf,
657 "ZoomLimit sup < ZoomLimit inf");
7fd59977 658}
659
63bcc448 660//=============================================================================
661//function : Visual
662//purpose :
663//=============================================================================
664Graphic3d_TypeOfStructure Graphic3d_Structure::Visual() const
665{
666 return myVisual;
7fd59977 667}
668
63bcc448 669//=============================================================================
670//function : AcceptConnection
671//purpose :
672//=============================================================================
673Standard_Boolean Graphic3d_Structure::AcceptConnection (const Handle(Graphic3d_Structure)& theStructure1,
674 const Handle(Graphic3d_Structure)& theStructure2,
675 const Graphic3d_TypeOfConnection theType)
676{
7fd59977 677 // cycle detection
63bcc448 678 Graphic3d_MapOfStructure aSet;
679 Graphic3d_Structure::Network (theStructure2, theType, aSet);
680 return !aSet.Contains (theStructure1);
7fd59977 681}
682
63bcc448 683//=============================================================================
684//function : Ancestors
685//purpose :
686//=============================================================================
687void Graphic3d_Structure::Ancestors (Graphic3d_MapOfStructure& theSet) const
688{
602d1ead 689 for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myAncestors); anIter.More(); anIter.Next())
63bcc448 690 {
602d1ead 691 theSet.Add ((Graphic3d_Structure* )anIter.Value());
63bcc448 692 }
7fd59977 693}
694
63bcc448 695//=============================================================================
696//function : SetOwner
697//purpose :
698//=============================================================================
699void Graphic3d_Structure::SetOwner (const Standard_Address theOwner)
700{
701 myOwner = theOwner;
7fd59977 702}
703
63bcc448 704//=============================================================================
705//function : Owner
706//purpose :
707//=============================================================================
708Standard_Address Graphic3d_Structure::Owner() const
709{
710 return myOwner;
7fd59977 711}
712
63bcc448 713//=============================================================================
714//function : Descendants
715//purpose :
716//=============================================================================
717void Graphic3d_Structure::Descendants (Graphic3d_MapOfStructure& theSet) const
718{
602d1ead 719 for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
63bcc448 720 {
602d1ead 721 theSet.Add ((Graphic3d_Structure* )anIter.Value());
63bcc448 722 }
7fd59977 723}
724
63bcc448 725//=============================================================================
602d1ead 726//function : AppendAncestor
d4aaad5b 727//purpose :
728//=============================================================================
602d1ead 729Standard_Boolean Graphic3d_Structure::AppendAncestor (const Standard_Address theAncestor)
d4aaad5b 730{
602d1ead 731 const Standard_Integer aSize = myAncestors.Size();
d4aaad5b 732
602d1ead 733 return myAncestors.Add (theAncestor) > aSize; // new object
d4aaad5b 734}
735
736//=============================================================================
602d1ead 737//function : AppendDescendant
d4aaad5b 738//purpose :
739//=============================================================================
602d1ead 740Standard_Boolean Graphic3d_Structure::AppendDescendant (const Standard_Address theDescendant)
d4aaad5b 741{
602d1ead 742 const Standard_Integer aSize = myDescendants.Size();
d4aaad5b 743
602d1ead 744 return myDescendants.Add (theDescendant) > aSize; // new object
d4aaad5b 745}
746
747//=============================================================================
602d1ead 748//function : RemoveAncestor
d4aaad5b 749//purpose :
750//=============================================================================
602d1ead 751Standard_Boolean Graphic3d_Structure::RemoveAncestor (const Standard_Address theAncestor)
d4aaad5b 752{
602d1ead 753 const Standard_Integer anIndex = myAncestors.FindIndex (theAncestor);
754
755 if (anIndex != 0)
d4aaad5b 756 {
602d1ead 757 myAncestors.Swap (anIndex, myAncestors.Size());
758 myAncestors.RemoveLast();
d4aaad5b 759 }
760
602d1ead 761 return anIndex != 0; // object was found
d4aaad5b 762}
763
764//=============================================================================
602d1ead 765//function : RemoveDescendant
d4aaad5b 766//purpose :
767//=============================================================================
602d1ead 768Standard_Boolean Graphic3d_Structure::RemoveDescendant (const Standard_Address theDescendant)
d4aaad5b 769{
602d1ead 770 const Standard_Integer anIndex = myDescendants.FindIndex (theDescendant);
d4aaad5b 771
602d1ead 772 if (anIndex != 0)
d4aaad5b 773 {
602d1ead 774 myDescendants.Swap (anIndex, myDescendants.Size());
775 myDescendants.RemoveLast();
d4aaad5b 776 }
777
602d1ead 778 return anIndex != 0; // object was found
d4aaad5b 779}
780
781//=============================================================================
63bcc448 782//function : Connect
783//purpose :
784//=============================================================================
785void Graphic3d_Structure::Connect (const Handle(Graphic3d_Structure)& theStructure,
786 const Graphic3d_TypeOfConnection theType,
787 const Standard_Boolean theWithCheck)
788{
d4aaad5b 789 if (IsDeleted())
790 {
791 return;
792 }
7fd59977 793
63bcc448 794 // cycle detection
795 if (theWithCheck
796 && !Graphic3d_Structure::AcceptConnection (this, theStructure, theType))
7fd59977 797 {
63bcc448 798 return;
799 }
7fd59977 800
d4aaad5b 801 const Standard_Address aStructure = theStructure.operator->();
802
803 if (theType == Graphic3d_TOC_DESCENDANT)
63bcc448 804 {
d4aaad5b 805 if (!AppendDescendant (aStructure))
7fd59977 806 {
d4aaad5b 807 return;
808 }
7fd59977 809
d4aaad5b 810 CalculateBoundBox();
811 theStructure->Connect (this, Graphic3d_TOC_ANCESTOR);
7fd59977 812
d4aaad5b 813 GraphicConnect (theStructure);
814 myStructureManager->Connect (this, theStructure);
7fd59977 815
50d06d8f 816 Update (true);
d4aaad5b 817 }
818 else // Graphic3d_TOC_ANCESTOR
819 {
820 if (!AppendAncestor (aStructure))
821 {
63bcc448 822 return;
7fd59977 823 }
63bcc448 824
d4aaad5b 825 CalculateBoundBox();
826 theStructure->Connect (this, Graphic3d_TOC_DESCENDANT);
63bcc448 827
d4aaad5b 828 // myStructureManager->Connect is called in case if connection between parent and child
7fd59977 829 }
7fd59977 830}
831
63bcc448 832//=============================================================================
833//function : Disconnect
834//purpose :
835//=============================================================================
836void Graphic3d_Structure::Disconnect (const Handle(Graphic3d_Structure)& theStructure)
837{
d4aaad5b 838 if (IsDeleted())
63bcc448 839 {
d4aaad5b 840 return;
841 }
7fd59977 842
d4aaad5b 843 const Standard_Address aStructure = theStructure.operator->();
7fd59977 844
d4aaad5b 845 if (RemoveDescendant (aStructure))
846 {
847 theStructure->Disconnect (this);
b7cd4ba7 848
d4aaad5b 849 GraphicDisconnect (theStructure);
850 myStructureManager->Disconnect (this, theStructure);
7fd59977 851
d4aaad5b 852 CalculateBoundBox();
50d06d8f 853 Update (true);
d4aaad5b 854 }
855 else if (RemoveAncestor (aStructure))
63bcc448 856 {
d4aaad5b 857 theStructure->Disconnect (this);
858 CalculateBoundBox();
859
860 // no call of myStructureManager->Disconnect in case of an ancestor
7fd59977 861 }
7fd59977 862}
863
63bcc448 864//=============================================================================
865//function : DisconnectAll
866//purpose :
867//=============================================================================
868void Graphic3d_Structure::DisconnectAll (const Graphic3d_TypeOfConnection theType)
869{
870 if (IsDeleted()) return;
7fd59977 871
63bcc448 872 switch (theType)
7fd59977 873 {
63bcc448 874 case Graphic3d_TOC_DESCENDANT:
875 {
602d1ead 876 for (Standard_Integer anIdx = 1, aLength = myDescendants.Size(); anIdx <= aLength; ++anIdx)
63bcc448 877 {
878 // Value (1) instead of Value (i) as myDescendants
879 // is modified by :
880 // Graphic3d_Structure::Disconnect (AStructure)
881 // that takes AStructure from myDescendants
602d1ead 882 ((Graphic3d_Structure* )(myDescendants.FindKey (1)))->Disconnect (this);
63bcc448 883 }
884 break;
885 }
886 case Graphic3d_TOC_ANCESTOR:
887 {
602d1ead 888 for (Standard_Integer anIdx = 1, aLength = myAncestors.Size(); anIdx <= aLength; ++anIdx)
63bcc448 889 {
890 // Value (1) instead of Value (i) as myAncestors
891 // is modified by :
892 // Graphic3d_Structure::Disconnect (AStructure)
893 // that takes AStructure from myAncestors
602d1ead 894 ((Graphic3d_Structure* )(myAncestors.FindKey (1)))->Disconnect (this);
63bcc448 895 }
896 break;
897 }
7fd59977 898 }
7fd59977 899}
900
63bcc448 901//=============================================================================
63bcc448 902//function : SetTransform
903//purpose :
904//=============================================================================
1f7f5a90 905void Graphic3d_Structure::SetTransformation (const Handle(Geom_Transformation)& theTrsf)
63bcc448 906{
907 if (IsDeleted()) return;
7fd59977 908
1f7f5a90 909 const Standard_Boolean wasTransformed = IsTransformed();
910
911 if (!theTrsf.IsNull()
912 && theTrsf->Trsf().Form() == gp_Identity)
63bcc448 913 {
1f7f5a90 914 myCStructure->SetTransformation (Handle(Geom_Transformation)());
7fd59977 915 }
1f7f5a90 916 else
63bcc448 917 {
1f7f5a90 918 myCStructure->SetTransformation (theTrsf);
7fd59977 919 }
920
63bcc448 921 // If transformation, no validation of hidden already calculated parts
6bd94e0d 922 if (IsTransformed() || (!IsTransformed() && wasTransformed))
63bcc448 923 {
924 ReCompute();
925 }
7fd59977 926
1f7f5a90 927 myStructureManager->SetTransform (this, theTrsf);
7fd59977 928
50d06d8f 929 Update (true);
7fd59977 930}
931
63bcc448 932//=============================================================================
197ac94e 933//function : MinMaxValues
934//purpose :
935//=============================================================================
ed063270 936Bnd_Box Graphic3d_Structure::MinMaxValues (const Standard_Boolean theToIgnoreInfiniteFlag) const
197ac94e 937{
7c3ef2f7 938 Graphic3d_BndBox3d aBox;
b7cd4ba7 939 addTransformed (aBox, theToIgnoreInfiniteFlag);
7c3ef2f7 940 if (!aBox.IsValid())
197ac94e 941 {
7c3ef2f7 942 return Bnd_Box();
943 }
944
945 Bnd_Box aResult;
946 aResult.Update (aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
947 aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
948
949 Standard_Real aLimMin = ShortRealFirst() + 1.0;
950 Standard_Real aLimMax = ShortRealLast() - 1.0;
951 gp_Pnt aMin = aResult.CornerMin();
952 gp_Pnt aMax = aResult.CornerMax();
953 if (aMin.X() < aLimMin && aMin.Y() < aLimMin && aMin.Z() < aLimMin
954 && aMax.X() > aLimMax && aMax.Y() > aLimMax && aMax.Z() > aLimMax)
955 {
956 //For structure which infinite in all three dimensions the Whole bounding box will be returned
957 aResult.SetWhole();
197ac94e 958 }
ed063270 959 return aResult;
7fd59977 960}
961
63bcc448 962//=============================================================================
963//function : Identification
964//purpose :
965//=============================================================================
966Standard_Integer Graphic3d_Structure::Identification() const
967{
968 return myCStructure->Id;
7fd59977 969}
970
63bcc448 971//=============================================================================
972//function : SetTransformPersistence
973//purpose :
974//=============================================================================
778cd667 975void Graphic3d_Structure::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
7fd59977 976{
778cd667 977 if (IsDeleted())
978 {
979 return;
980 }
7fd59977 981
778cd667 982 myCStructure->SetTransformPersistence (theTrsfPers);
7fd59977 983}
984
63bcc448 985//=============================================================================
63bcc448 986//function : Remove
987//purpose :
988//=============================================================================
989void Graphic3d_Structure::Remove (const Standard_Address thePtr,
990 const Graphic3d_TypeOfConnection theType)
991{
d4aaad5b 992 if (theType == Graphic3d_TOC_DESCENDANT)
7fd59977 993 {
d4aaad5b 994 RemoveDescendant (thePtr);
995 }
996 else
997 {
998 RemoveAncestor (thePtr);
7fd59977 999 }
7fd59977 1000}
1001
63bcc448 1002//=============================================================================
b64d84be 1003//function : NewGroup
1004//purpose :
1005//=============================================================================
1006Handle(Graphic3d_Group) Graphic3d_Structure::NewGroup()
1007{
1008 return myCStructure->NewGroup (this);
1009}
1010
1011//=============================================================================
63bcc448 1012//function : Remove
1013//purpose :
1014//=============================================================================
1015void Graphic3d_Structure::Remove (const Handle(Graphic3d_Group)& theGroup)
1016{
b64d84be 1017 if (theGroup.IsNull()
1018 || theGroup->myStructure != this)
63bcc448 1019 {
b64d84be 1020 return;
63bcc448 1021 }
b64d84be 1022
1023 myCStructure->RemoveGroup (theGroup);
1024 theGroup->myStructure = NULL;
7fd59977 1025}
1026
63bcc448 1027//=============================================================================
1028//function : StructureManager
1029//purpose :
1030//=============================================================================
1031Handle(Graphic3d_StructureManager) Graphic3d_Structure::StructureManager() const
1032{
1033 return myStructureManager;
7fd59977 1034}
1035
197ac94e 1036//=============================================================================
b7cd4ba7 1037//function : minMaxCoord
197ac94e 1038//purpose :
1039//=============================================================================
8d3aa19e 1040Graphic3d_BndBox4f Graphic3d_Structure::minMaxCoord() const
197ac94e 1041{
b7cd4ba7 1042 Graphic3d_BndBox4f aBnd;
b64d84be 1043 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
197ac94e 1044 {
8d3aa19e 1045 aBnd.Combine (aGroupIter.Value()->BoundingBox());
197ac94e 1046 }
b7cd4ba7 1047 return aBnd;
197ac94e 1048}
1049
1050//=============================================================================
b7cd4ba7 1051//function : addTransformed
197ac94e 1052//purpose :
1053//=============================================================================
7c3ef2f7 1054void Graphic3d_Structure::getBox (Graphic3d_BndBox3d& theBox,
0717ddc1 1055 const Standard_Boolean theToIgnoreInfiniteFlag) const
197ac94e 1056{
8d3aa19e 1057 Graphic3d_BndBox4f aBoxF = minMaxCoord();
b7cd4ba7 1058 if (aBoxF.IsValid())
197ac94e 1059 {
7c3ef2f7 1060 theBox = Graphic3d_BndBox3d (Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMin().x(),
0717ddc1 1061 (Standard_Real )aBoxF.CornerMin().y(),
7c3ef2f7 1062 (Standard_Real )aBoxF.CornerMin().z()),
1063 Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMax().x(),
0717ddc1 1064 (Standard_Real )aBoxF.CornerMax().y(),
7c3ef2f7 1065 (Standard_Real )aBoxF.CornerMax().z()));
b7cd4ba7 1066 if (IsInfinite()
1067 && !theToIgnoreInfiniteFlag)
197ac94e 1068 {
7c3ef2f7 1069 const Graphic3d_Vec3d aDiagVec = theBox.CornerMax() - theBox.CornerMin();
1070 if (aDiagVec.SquareModulus() >= 500000.0 * 500000.0)
b7cd4ba7 1071 {
1072 // bounding borders of infinite line has been calculated as own point in center of this line
7c3ef2f7 1073 theBox = Graphic3d_BndBox3d ((theBox.CornerMin() + theBox.CornerMax()) * 0.5);
b7cd4ba7 1074 }
1075 else
1076 {
7c3ef2f7 1077 theBox = Graphic3d_BndBox3d (Graphic3d_Vec3d (RealFirst(), RealFirst(), RealFirst()),
1078 Graphic3d_Vec3d (RealLast(), RealLast(), RealLast()));
b7cd4ba7 1079 return;
1080 }
197ac94e 1081 }
197ac94e 1082 }
0717ddc1 1083}
1084
1085//=============================================================================
1086//function : addTransformed
1087//purpose :
1088//=============================================================================
7c3ef2f7 1089void Graphic3d_Structure::addTransformed (Graphic3d_BndBox3d& theBox,
0717ddc1 1090 const Standard_Boolean theToIgnoreInfiniteFlag) const
1091{
7c3ef2f7 1092 Graphic3d_BndBox3d aCombinedBox, aBox;
0717ddc1 1093 getBox (aCombinedBox, theToIgnoreInfiniteFlag);
7fd59977 1094
602d1ead 1095 for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
197ac94e 1096 {
602d1ead 1097 const Graphic3d_Structure* aStruct = (const Graphic3d_Structure* )anIter.Value();
0717ddc1 1098 aStruct->getBox (aBox, theToIgnoreInfiniteFlag);
1099 aCombinedBox.Combine (aBox);
197ac94e 1100 }
7fd59977 1101
0717ddc1 1102 aBox = aCombinedBox;
b7cd4ba7 1103 if (aBox.IsValid())
197ac94e 1104 {
1f7f5a90 1105 if (!myCStructure->Transformation().IsNull())
1106 {
1107 TransformBoundaries (myCStructure->Transformation()->Trsf(),
1108 aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
1109 aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
1110 }
0717ddc1 1111
1112 // if box is still valid after transformation
1113 if (aBox.IsValid())
1114 {
1115 theBox.Combine (aBox);
1116 }
1117 else // it was infinite, return untransformed
1118 {
1119 theBox.Combine (aCombinedBox);
1120 }
7fd59977 1121 }
7fd59977 1122}
1123
63bcc448 1124//=============================================================================
1125//function : Transforms
1126//purpose :
1127//=============================================================================
1f7f5a90 1128void Graphic3d_Structure::Transforms (const gp_Trsf& theTrsf,
63bcc448 1129 const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ,
1130 Standard_Real& theNewX, Standard_Real& theNewY, Standard_Real& theNewZ)
1131{
1132 const Standard_Real aRL = RealLast();
1133 const Standard_Real aRF = RealFirst();
1f7f5a90 1134 theNewX = theX;
1135 theNewY = theY;
1136 theNewZ = theZ;
63bcc448 1137 if ((theX == aRF) || (theY == aRF) || (theZ == aRF)
1138 || (theX == aRL) || (theY == aRL) || (theZ == aRL))
1139 {
1f7f5a90 1140 return;
7fd59977 1141 }
7fd59977 1142
1f7f5a90 1143 theTrsf.Transforms (theNewX, theNewY, theNewZ);
7fd59977 1144}
1145
197ac94e 1146//=============================================================================
1147//function : Transforms
1148//purpose :
1149//=============================================================================
1f7f5a90 1150void Graphic3d_Structure::TransformBoundaries (const gp_Trsf& theTrsf,
197ac94e 1151 Standard_Real& theXMin,
1152 Standard_Real& theYMin,
1153 Standard_Real& theZMin,
1154 Standard_Real& theXMax,
1155 Standard_Real& theYMax,
1156 Standard_Real& theZMax)
1157{
1158 Standard_Real aXMin, aYMin, aZMin, aXMax, aYMax, aZMax, anU, aV, aW;
1159
1160 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMin, theZMin, aXMin, aYMin, aZMin);
1161 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMax, theZMax, aXMax, aYMax, aZMax);
1162
1163 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMin, theZMax, anU, aV, aW);
1164 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
1165 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
1166 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
1167
1168 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMin, theZMax, anU, aV, aW);
1169 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
1170 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
1171 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
1172
1173 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMin, theZMin, anU, aV, aW);
1174 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
1175 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
1176 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
1177
1178 Graphic3d_Structure::Transforms (theTrsf, theXMax, theYMax, theZMin, anU, aV, aW);
1179 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
1180 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
1181 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
1182
1183 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMax, theZMax, anU, aV, aW);
1184 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
1185 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
1186 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
1187
1188 Graphic3d_Structure::Transforms (theTrsf, theXMin, theYMax, theZMin, anU, aV, aW);
1189 aXMin = Min (anU, aXMin); aXMax = Max (anU, aXMax);
1190 aYMin = Min (aV, aYMin); aYMax = Max (aV, aYMax);
1191 aZMin = Min (aW, aZMin); aZMax = Max (aW, aZMax);
1192
1193 theXMin = aXMin;
1194 theYMin = aYMin;
1195 theZMin = aZMin;
1196 theXMax = aXMax;
1197 theYMax = aYMax;
1198 theZMax = aZMax;
1199}
1200
63bcc448 1201//=============================================================================
1202//function : Network
1203//purpose :
1204//=============================================================================
1205void Graphic3d_Structure::Network (const Handle(Graphic3d_Structure)& theStructure,
1206 const Graphic3d_TypeOfConnection theType,
1207 Graphic3d_MapOfStructure& theSet)
1208{
1209 Graphic3d_MapOfStructure aSetD, aSetA;
1210 theStructure->Descendants (aSetD);
1211 theStructure->Ancestors (aSetA);
1212 theSet.Add (theStructure);
1213 switch (theType)
7fd59977 1214 {
63bcc448 1215 case Graphic3d_TOC_DESCENDANT:
1216 for (Graphic3d_MapIteratorOfMapOfStructure anIter (aSetD); anIter.More(); anIter.Next())
1217 {
1218 Graphic3d_Structure::Network (anIter.Key(), theType, theSet);
1219 }
1220 break;
1221 case Graphic3d_TOC_ANCESTOR:
1222 for (Graphic3d_MapIteratorOfMapOfStructure anIter (aSetA); anIter.More(); anIter.Next())
1223 {
1224 Graphic3d_Structure::Network (anIter.Key (), theType, theSet);
1225 }
1226 break;
7fd59977 1227 }
7fd59977 1228}
1229
63bcc448 1230//=============================================================================
1231//function : PrintNetwork
1232//purpose :
1233//=============================================================================
1234void Graphic3d_Structure::PrintNetwork (const Handle(Graphic3d_Structure)& theStructure,
1235 const Graphic3d_TypeOfConnection theType)
7fd59977 1236{
63bcc448 1237 Graphic3d_MapOfStructure aSet;
1238 Graphic3d_Structure::Network (theStructure, theType, aSet);
1239 for (Graphic3d_MapIteratorOfMapOfStructure anIter (aSet); anIter.More(); anIter.Next())
1240 {
1241 std::cout << "\tIdent " << (anIter.Key())->Identification () << "\n";
7fd59977 1242 }
63bcc448 1243 std::cout << std::flush;
7fd59977 1244}
1245
63bcc448 1246//=============================================================================
1247//function : Update
1248//purpose :
1249//=============================================================================
50d06d8f 1250void Graphic3d_Structure::Update (const bool theUpdateLayer) const
7fd59977 1251{
63bcc448 1252 if (IsDeleted())
1253 {
1254 return;
1255 }
7fd59977 1256
50d06d8f 1257 myStructureManager->Update (myStructureManager->UpdateMode(),
1258 theUpdateLayer ? myCStructure->ZLayer() : Graphic3d_ZLayerId_UNKNOWN);
63bcc448 1259}
7fd59977 1260
63bcc448 1261//=============================================================================
63bcc448 1262//function : GraphicTransform
1263//purpose :
1264//=============================================================================
1f7f5a90 1265void Graphic3d_Structure::GraphicTransform (const Handle(Geom_Transformation)& theTrsf)
63bcc448 1266{
1f7f5a90 1267 myCStructure->SetTransformation (theTrsf);
7fd59977 1268}
1269
63bcc448 1270//=============================================================================
63bcc448 1271//function : ComputeVisual
1272//purpose :
1273//=============================================================================
1274Graphic3d_TypeOfStructure Graphic3d_Structure::ComputeVisual() const
1275{
1276 return myComputeVisual;
7fd59977 1277}
1278
63bcc448 1279//=============================================================================
1280//function : SetComputeVisual
1281//purpose :
1282//=============================================================================
1283void Graphic3d_Structure::SetComputeVisual (const Graphic3d_TypeOfStructure theVisual)
35e08fe8 1284{
63bcc448 1285 // The ComputeVisual is saved only if the structure is declared TOS_ALL, TOS_WIREFRAME or TOS_SHADING.
1286 // This declaration permits to calculate proper representation of the structure calculated by Compute instead of passage to TOS_COMPUTED.
1287 if (theVisual != Graphic3d_TOS_COMPUTED)
1288 {
1289 myComputeVisual = theVisual;
7fd59977 1290 }
7fd59977 1291}
1292
63bcc448 1293//=============================================================================
63bcc448 1294//function : SetHLRValidation
1295//purpose :
1296//=============================================================================
1297void Graphic3d_Structure::SetHLRValidation (const Standard_Boolean theFlag)
1298{
1299 myCStructure->HLRValidation = theFlag ? 1 : 0;
1300}
7fd59977 1301
63bcc448 1302//=============================================================================
1303//function : HLRValidation
1304//purpose :
1305//=============================================================================
1306Standard_Boolean Graphic3d_Structure::HLRValidation() const
1307{
81bba717 1308 // Hidden parts stored in <me> are valid if :
1309 // 1/ the owner is defined.
1310 // 2/ they are not invalid.
63bcc448 1311 return myOwner != NULL
1312 && myCStructure->HLRValidation != 0;
7fd59977 1313}
1314
bf75be98 1315//=======================================================================
59f45b7c 1316//function : SetZLayer
1317//purpose :
1318//=======================================================================
a1954302 1319void Graphic3d_Structure::SetZLayer (const Graphic3d_ZLayerId theLayerId)
59f45b7c 1320{
1321 // if the structure is not displayed, unable to change its display layer
1322 if (IsDeleted ())
1323 return;
1324
63bcc448 1325 myStructureManager->ChangeZLayer (this, theLayerId);
a1954302 1326 myCStructure->SetZLayer (theLayerId);
59f45b7c 1327}
1328
1329//=======================================================================
1330//function : GetZLayer
1331//purpose :
1332//=======================================================================
a1954302 1333Graphic3d_ZLayerId Graphic3d_Structure::GetZLayer() const
59f45b7c 1334{
a1954302 1335 return myCStructure->ZLayer();
59f45b7c 1336}
4269bd1b 1337
1338//=======================================================================
1339//function : SetClipPlanes
1340//purpose :
1341//=======================================================================
3202bf1e 1342void Graphic3d_Structure::SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes)
4269bd1b 1343{
63bcc448 1344 myCStructure->SetClipPlanes (thePlanes);
4269bd1b 1345}
1346
1347//=======================================================================
1348//function : GetClipPlanes
1349//purpose :
1350//=======================================================================
3202bf1e 1351const Handle(Graphic3d_SequenceOfHClipPlane)& Graphic3d_Structure::ClipPlanes() const
4269bd1b 1352{
63bcc448 1353 return myCStructure->ClipPlanes();
4269bd1b 1354}
b7cd4ba7 1355
1356//=======================================================================
1357//function : SetMutable
1358//purpose :
1359//=======================================================================
1360void Graphic3d_Structure::SetMutable (const Standard_Boolean theIsMutable)
1361{
1362 myCStructure->IsMutable = theIsMutable;
1363}
1364
1365//=======================================================================
1366//function : IsMutable
1367//purpose :
1368//=======================================================================
1369Standard_Boolean Graphic3d_Structure::IsMutable() const
1370{
1371 return myCStructure->IsMutable;
1372}