0022600: TBB has to be disabled in BRepMesh due to data races BRepMesh_FastDiscret...
[occt.git] / src / Graphic3d / Graphic3d_Structure.cxx
CommitLineData
7fd59977 1// File Graphic3d_Structure.cxx
2// Created Mars 1992
3// Author NW,JPB,CAL
4// Modified 1/08/97 ; PCT : ajout texture mapping
5// 20/08/97 ; PCT : ajout transparence pour texture
6// 11/97 ; CAL : gestion du GraphicClear
7// 11/97 ; CAL : ajout pointer StructPtr
8// 11/97 ; CAL : amelioration de l'effacement SetManager
9// CAL : 15 janvier 1998
10// Ajout de la methode IsTransformed dans une Structure.
11// (Permet la transmission de cette Trsf vers
12// la structure COMPUTED si necessaire)
13//
14// Ajout de la methode IsRotated dans une Structure.
15// (Permet de connaitre le type de transformation
16// pour declencher le calcul des parties cachees
17// de maniere plus sioux)
18//
19// Ajout de 3 nouvelles methodes Compute virtual dans Structure.
20// (Permet des Compute un peu plus specialises)
21//
22// Ajout des 2 methodes sur Owner dans Structure.
23// (evite de calculer 2 fois les parties cachees
24// pour 2 representations differentes affichees
25// d'un meme Presentable Object (Owner))
26//
27// Ajout des 2 methodes sur HLRValidation dans Structure.
28// (permet de valider ou d'invalider le calcul des
29// parties cachees sur certaines representations)
30//
31// Ajout de la transmission de la transformation d'une structure
32// vers sa COMPUTED.
33// 24/2/98 ; CAL : Modification de la gestion des champs
34// CAL : 26 mars 1998
35// Patch, erreur dans la gestion du nombre de Group avec
36// facettes dans Graphic3d_Structure avec une operation
37// de Clear. (PRO12795)
38// FGU : 30 Avril 1998
39// Ajout emission
40// CAL : 20 mai 1998
41// Perfs. Connection entre structures COMPUTED.
bbf32d01
K
42// 30/11/98 ; FMN : S4069. Textes always visible.
43// 22/03/04 ; SAN : OCC4895 High-level interface for controlling polygon offsets
7fd59977 44
45#define G003 //EUG 26/01/00 Degeneration management
46
bbf32d01 47#define BUC60918 //GG 31/05/01 A transparente structure priority must have the
7fd59977 48// MAX_PRIORITY value so, the highlighted structure must have
bbf32d01 49// MAX_PRIORITY-1 value.
7fd59977 50// Add ResetDisplayPriority() method.
51
52#define OCC1174 // SAV 08/01/03 Added back face interior color controling
53
54
bbf32d01 55//
7fd59977 56//-Copyright MatraDatavision 1991,1992,1993,1994,1995
57
bbf32d01 58//-Version
7fd59977 59
81bba717 60//-Design Declaration of variables specific to graphic structures
7fd59977 61
81bba717 62//-Warning A structure is defined in a manager
63// This is a sequence of groups of primitives
7fd59977 64
bbf32d01 65//-References
7fd59977 66
67//-Language C++ 2.0
68
69//-Declarations
70
71// for the class
72
73#define XDOWNCAST
74#define XDESTROY
75#define XDEBUG
76#define XTRACE
77#define XTRACE_ISTRSF
78
79#include <stdio.h>
80
81#include <Graphic3d_Structure.ixx>
82#include <Graphic3d_Structure.pxx>
83
84#include <Graphic3d_GraphicDevice.hxx>
85#include <Graphic3d_GraphicDriver.hxx>
86#include <Graphic3d_MaterialAspect.hxx>
87
88#include <Graphic3d_MapOfStructure.hxx>
89#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
90
91#include <Quantity_Color.hxx>
92#include <TColStd_Array2OfReal.hxx>
93#include <Graphic3d_TextureMap.hxx>
94
bbf32d01 95// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
7fd59977 96#include <Aspect_PolygonOffsetMode.hxx>
bbf32d01 97// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
7fd59977 98
99//-Aliases
100
101//-Global data definitions
102
103//-Constructors
104
105Graphic3d_Structure::Graphic3d_Structure (const Handle(Graphic3d_StructureManager)& AManager):
106MyGroupGenId (Group_IDMIN, Group_IDMAX),
107MyAncestors (),
108MyDescendants (),
109MyGroups (),
110MyHighlightColor (Quantity_NOC_WHITE)
111{
112
113 Standard_Integer i, j;
114
115 MyOwner = NULL;
116
117 Handle(Graphic3d_AspectLine3d) aAspectLine3d =
118 new Graphic3d_AspectLine3d ();
119 Handle(Graphic3d_AspectText3d) aAspectText3d =
120 new Graphic3d_AspectText3d ();
121 Handle(Graphic3d_AspectMarker3d) aAspectMarker3d =
122 new Graphic3d_AspectMarker3d ();
123 Handle(Graphic3d_AspectFillArea3d) aAspectFillArea3d =
124 new Graphic3d_AspectFillArea3d ();
125
81bba717 126 // Return default values
7fd59977 127 AManager->PrimitivesAspect (aAspectLine3d, aAspectText3d,
128 aAspectMarker3d, aAspectFillArea3d);
129
bbf32d01 130 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
7fd59977 131 // It is necessary to set default polygon offsets for a new presentation
132 aAspectFillArea3d->SetPolygonOffsets( Aspect_POM_Fill, 1., 0. );
bbf32d01 133 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
7fd59977 134
81bba717 135 // Update the associated CStructure
7fd59977 136 UpdateStructure (aAspectLine3d, aAspectText3d,
137 aAspectMarker3d, aAspectFillArea3d);
138
139 MyFirstPtrStructureManager = MyPtrStructureManager =
140 (void *) AManager.operator->();
141 MyCStructure.Id = int (AManager->NewIdentification ());
142
143 MyCStructure.IsOpen = 0;
144 MyCStructure.IsDeleted = 0;
145
146 MyCStructure.Composition = 0; /* Graphic3d_TOC_REPLACE */
147
148 for (i=0; i<=3; i++)
149 for (j=0; j<=3; j++)
150 if (i == j)
151 MyCStructure.Transformation[i][j] = float (1.0);
152 else
153 MyCStructure.Transformation[i][j] = float (0.0);
154
155 MyCStructure.Priority = int (Structure_MAX_PRIORITY / 2);
156 MyCStructure.PreviousPriority = MyCStructure.Priority;
157 MyCStructure.stick = 0,
158 MyCStructure.highlight = 0,
159 MyCStructure.visible = 1,
160 MyCStructure.pick = 1;
161 MyCStructure.ContainsFacet = 0,
162 MyCStructure.IsInfinite = 0,
163 MyCStructure.HLRValidation = 0;
164
165 MyCStructure.GroupBegin = Structure_GROUPBEGIN;
166 MyCStructure.GroupEnd = Structure_GROUPEND;
167
168 MyCStructure.ContextLine.IsDef = 1,
169 MyCStructure.ContextFillArea.IsDef = 1,
170 MyCStructure.ContextMarker.IsDef = 1,
171 MyCStructure.ContextText.IsDef = 1;
172
173 MyCStructure.ContextLine.IsSet = 0,
174 MyCStructure.ContextFillArea.IsSet = 0,
175 MyCStructure.ContextMarker.IsSet = 0,
176 MyCStructure.ContextText.IsSet = 0;
177
178 MyVisual = Graphic3d_TOS_ALL;
179 MyComputeVisual = Graphic3d_TOS_ALL;
180
181 /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
182 /*MyCStructure.TransformPersistence.IsDef = 1;*/
183 MyCStructure.TransformPersistence.IsSet = 0;
184 MyCStructure.TransformPersistence.Flag = Graphic3d_TMF_None;
185 MyCStructure.TransformPersistence.Point.x = 0.0;
186 MyCStructure.TransformPersistence.Point.y = 0.0;
187 MyCStructure.TransformPersistence.Point.z = 0.0;
188 /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
189 Handle(Aspect_GraphicDriver) agd =
190 (AManager->GraphicDevice ())->GraphicDriver ();
191
192 MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
193
194 MyGraphicDriver->Structure (MyCStructure);
195
196#ifdef TRACE
197 cout << "Graphic3d_Structure::Create (" << MyCStructure.Id << ")\n";
198#endif
199
200}
201
202//-Destructors
203
204void Graphic3d_Structure::Destroy () {
205
206#ifdef DESTROY
207 cout << "Graphic3d_Structure::Destroy (" << MyCStructure.Id << ")\n";
208#endif
209
210 // as MyFirstPtrStructureManager can be already destroyed,
bbf32d01 211 // avoid attempts to access it
7fd59977 212 MyFirstPtrStructureManager = 0;
213 Remove ();
214
215}
216
217//-Methods, in order
218
98178592
A
219void Graphic3d_Structure::Clear (const Standard_Boolean WithDestruction)
220{
221 if (IsDeleted()) return;
7fd59977 222
98178592 223 MyCStructure.ContainsFacet = 0;
7fd59977 224
98178592
A
225 // clean groups in graphics driver at first
226 if (WithDestruction)
227 {
228 // clean and empty each group
229 Standard_Integer Length = MyGroups.Length();
230 for (Standard_Integer aGrId = 1; aGrId <= Length; ++aGrId)
231 MyGroups.ChangeValue (aGrId)->Clear();
7fd59977 232 }
98178592 233 GraphicClear (WithDestruction);
7fd59977 234
98178592
A
235 // only then remove group references
236 if (WithDestruction)
237 {
238 MyGroupGenId.Free();
239 MyGroups.Clear();
240 }
7fd59977 241
7fd59977 242 MyStructureManager->Clear (this, WithDestruction);
243
98178592 244 Update();
7fd59977 245}
246
247void Graphic3d_Structure::Remove () {
248
249 if (IsDeleted ()) return;
250
251#ifdef DESTROY
252 if (MyDescendants.Length () != 0) {
253 cout << "The structure " << MyCStructure.Id << " have "
254 << MyDescendants.Length () << " descendants.\n" << flush;
255 }
256 if (MyAncestors.Length () != 0) {
257 cout << "The structure " << MyCStructure.Id << " have "
258 << MyAncestors.Length () << " ancestors.\n" << flush;
259 }
260#endif
261
262 Standard_Integer i, Length;
98178592
A
263
264 // clean groups in graphics driver at first
265 Length = MyGroups.Length();
266 for (Standard_Integer aGrId = 1; aGrId <= Length; ++aGrId)
267 MyGroups.ChangeValue (aGrId)->Clear();
268
7fd59977 269 // Standard_Address APtr = (void *) This ().operator->();
270 Standard_Address APtr = (void *) this;
81bba717 271 // It is necessary to remove the eventual pointer on the structure
272 // that can be destroyed, in the list of descendants
273 // of ancesters of this structure and in the list of ancesters
274 // of descendants of the same structure.
7fd59977 275
276 Length = MyDescendants.Length ();
277 for (i=1; i<=Length; i++)
278 ((Graphic3d_Structure *)
279 (MyDescendants.Value (i)))->Remove (APtr, Graphic3d_TOC_ANCESTOR);
280
281 Length = MyAncestors.Length ();
282 for (i=1; i<=Length; i++)
283 ((Graphic3d_Structure *)
284 (MyAncestors.Value (i)))->Remove (APtr, Graphic3d_TOC_DESCENDANT);
285
286 MyCStructure.ContainsFacet = 0;
287 MyCStructure.IsDeleted = 1;
288
81bba717 289 // Destruction of me in the graphic library
7fd59977 290 MyGraphicDriver->RemoveStructure (MyCStructure);
291
bbf32d01 292 // Liberation of the identification if the destroyed structure
81bba717 293 // in the first manager that performs creation of the structure.
7fd59977 294 if ( MyFirstPtrStructureManager )
295 MyFirstStructureManager->Remove (Standard_Integer (MyCStructure.Id));
296
297}
298
299void Graphic3d_Structure::Display () {
300
301 if (IsDeleted ()) return;
302
303 if (! MyCStructure.stick) {
304 MyCStructure.stick = 1;
305 MyStructureManager->Display (this);
306 }
307
308}
309
310void Graphic3d_Structure::Display (const Standard_Integer Priority) {
311
312 if (IsDeleted ()) return;
313
314 SetDisplayPriority (Priority);
315
316 if (! MyCStructure.stick) {
317 MyCStructure.stick = 1;
318 MyStructureManager->Display (this);
319 }
320
321}
322
323void Graphic3d_Structure::SetDisplayPriority (const Standard_Integer Priority) {
324
325 if (IsDeleted ()) return;
326
327#ifdef BUC60918
328 if( Priority == MyCStructure.Priority ) return;
329#endif
330
331 MyCStructure.PreviousPriority = MyCStructure.Priority;
332 MyCStructure.Priority = int (Priority);
333
334 if (MyCStructure.Priority != MyCStructure.PreviousPriority) {
335 if ( (MyCStructure.Priority > Structure_MAX_PRIORITY) ||
336 (MyCStructure.Priority < Structure_MIN_PRIORITY) )
337 Graphic3d_PriorityDefinitionError::Raise
338 ("Bad value for StructurePriority");
339
340 if (MyCStructure.stick)
341 MyStructureManager->ChangeDisplayPriority (this,
342 Standard_Integer (MyCStructure.PreviousPriority),
343 Standard_Integer (MyCStructure.Priority));
344 }
345
346}
347
348#ifdef BUC60918
349void Graphic3d_Structure::ResetDisplayPriority () {
350
351 if (IsDeleted ()) return;
352
353 if (MyCStructure.Priority != MyCStructure.PreviousPriority) {
354 Standard_Integer priority = MyCStructure.Priority;
355 MyCStructure.Priority = MyCStructure.PreviousPriority;
356
357 if (MyCStructure.stick)
358 MyStructureManager->ChangeDisplayPriority (this,
359 priority,
360 Standard_Integer (MyCStructure.Priority));
361 }
362
363}
364#endif
365
366Standard_Integer Graphic3d_Structure::DisplayPriority () const {
367
368 return Standard_Integer (MyCStructure.Priority);
369
370}
371
372void Graphic3d_Structure::Erase () {
373
374 if (IsDeleted ()) return;
375
376 if (MyCStructure.stick) {
377 MyCStructure.stick = 0;
378 MyStructureManager->Erase (this);
379 }
380
381}
382
383void Graphic3d_Structure::Highlight (const Aspect_TypeOfHighlightMethod AMethod) {
384
385 if (IsDeleted ()) return;
386
81bba717 387 // Highlight on already Highlighted structure.
7fd59977 388 if (MyCStructure.highlight) {
389
390 Aspect_TypeOfUpdate UpdateMode = MyStructureManager->UpdateMode ();
391 if (UpdateMode == Aspect_TOU_WAIT)
392 UnHighlight ();
393 else {
81bba717 394 // To avoid call of method : Update ()
395 // Not useful and can be costly.
7fd59977 396 MyStructureManager->SetUpdateMode (Aspect_TOU_WAIT);
397 UnHighlight ();
398 MyStructureManager->SetUpdateMode (UpdateMode);
399 }
400 }
401
402#ifdef BUC60918
403 SetDisplayPriority (Standard_Integer (Structure_MAX_PRIORITY)-1);
404#else
405 SetDisplayPriority (Standard_Integer (Structure_MAX_PRIORITY));
406#endif
407
408 GraphicHighlight (AMethod);
409 MyStructureManager->Highlight (this, AMethod);
410
411 Update ();
412
413}
414
415void Graphic3d_Structure::SetHighlightColor (const Quantity_Color& AColor) {
416
417 if (IsDeleted ()) return;
418
419 if (! MyCStructure.highlight)
420 MyHighlightColor = AColor;
421 else {
81bba717 422 // Change highlight color on already Highlighted structure.
7fd59977 423
424 Aspect_TypeOfUpdate UpdateMode = MyStructureManager->UpdateMode ();
425 if (UpdateMode == Aspect_TOU_WAIT)
426 UnHighlight ();
427 else {
81bba717 428 // To avoid call of method : Update ()
429 // Not useful and can be costly.
7fd59977 430 MyStructureManager->SetUpdateMode (Aspect_TOU_WAIT);
431 UnHighlight ();
432 MyStructureManager->SetUpdateMode (UpdateMode);
433 }
434 MyHighlightColor = AColor;
435 Highlight (MyHighlightMethod);
436 }
437
438}
439
440void Graphic3d_Structure::SetVisible (const Standard_Boolean AValue) {
441
442 if (IsDeleted ()) return;
443
444 MyCStructure.visible = AValue ? 1:0;
445
446 MyGraphicDriver->NameSetStructure (MyCStructure);
447
448 if (AValue)
449 MyStructureManager->Visible (this);
450 else
451 MyStructureManager->Invisible (this);
452
453 Update ();
454
455}
456
457void Graphic3d_Structure::SetPick (const Standard_Boolean AValue) {
458
459 if (IsDeleted ()) return;
460
461 MyCStructure.pick = AValue ? 1:0;
462
463 MyGraphicDriver->NameSetStructure (MyCStructure);
464
465 if (AValue)
466 MyStructureManager->Detectable (this);
467 else
468 MyStructureManager->Undetectable (this);
469
470 Update ();
471
472}
473
474void Graphic3d_Structure::UnHighlight () {
475
476 if (IsDeleted ()) return;
477
478 if (MyCStructure.highlight) {
479 MyCStructure.highlight = 0;
480
481 GraphicUnHighlight ();
482 MyStructureManager->UnHighlight (this);
483#ifdef BUC60918
484 ResetDisplayPriority();
485#else
486 SetDisplayPriority
487 (Standard_Integer (MyCStructure.PreviousPriority));
488#endif
489 Update ();
490 }
491
492}
493
494Quantity_Color Graphic3d_Structure::HighlightColor () const {
495
496 return (MyHighlightColor);
497
498}
499
500Standard_Boolean Graphic3d_Structure::IsDisplayed () const {
501
502 if (MyCStructure.stick)
503 return (Standard_True);
504 else
505 return (Standard_False);
506
507}
508
509Standard_Boolean Graphic3d_Structure::IsDeleted () const {
510
511 if (MyCStructure.IsDeleted)
512 return (Standard_True);
513 else
514 return (Standard_False);
515
516}
517
518Standard_Boolean Graphic3d_Structure::IsHighlighted () const {
519
520 if (MyCStructure.highlight)
521 return (Standard_True);
522 else
523 return (Standard_False);
524
525}
526
527Standard_Boolean Graphic3d_Structure::IsSelectable () const {
528
529 if (MyCStructure.pick)
530 return (Standard_True);
531 else
532 return (Standard_False);
533
534}
535
536Standard_Boolean Graphic3d_Structure::IsVisible () const {
537
538 if (MyCStructure.visible)
539 return (Standard_True);
540 else
541 return (Standard_False);
542
543}
544
545Standard_Boolean Graphic3d_Structure::IsRotated () const {
546
81bba717 547 // A somewhat light test !
7fd59977 548 return ( MyCStructure.Transformation[0][1] != 0.
549 || MyCStructure.Transformation[0][2] != 0.
550 || MyCStructure.Transformation[1][0] != 0.
551 || MyCStructure.Transformation[1][2] != 0.
552 || MyCStructure.Transformation[2][0] != 0.
553 || MyCStructure.Transformation[2][1] != 0. );
554
555}
556
557Standard_Boolean Graphic3d_Structure::IsTransformed () const {
558
559 Standard_Boolean Result = Standard_False;
560 Standard_Integer i, j;
561
562 for (i=0; i<=3 && ! Result; i++)
563 for (j=0; j<=3 && ! Result; j++)
564 if (i == j)
565 Result = MyCStructure.Transformation[i][j] != 1.;
566 else
567 Result = MyCStructure.Transformation[i][j] != 0.;
568
569#ifdef TRACE_ISTRSF
81bba717 570 cout << "Structure " << Identification ();
7fd59977 571 if (Result)
81bba717 572 cout << " is transformed\n" << flush;
7fd59977 573 else
81bba717 574 cout << " is not transformed\n" << flush;
7fd59977 575#endif
576
577 return Result;
578
579}
580
581Standard_Boolean Graphic3d_Structure::ContainsFacet () const {
582
583 if (IsDeleted ()) return (Standard_False);
584
81bba717 585 // A structure contains at least one facet :
586 // if one of these groups contains at least one facet.
7fd59977 587
588 Standard_Boolean Result1 = Standard_False;
589 Standard_Boolean Result2 = Standard_False;
590 Standard_Integer i, Length;
591
592 Result1 = (MyCStructure.ContainsFacet > 0);
593
81bba717 594 // If one of groups contains at least one facet, the structure contains it too.
7fd59977 595 if (Result1) return (Result1);
596
597 Length = MyDescendants.Length ();
598
81bba717 599 // Stop at the first descendant containing at least one facet.
7fd59977 600 for (i=1; i<=Length && ! Result2; i++)
601 Result2 = ((Graphic3d_Structure *)
602 (MyDescendants.Value (i)))->ContainsFacet ();
603
604 return (Result2);
605
606}
607
608Standard_Boolean Graphic3d_Structure::IsEmpty () const {
609
610 if (IsDeleted ()) return (Standard_True);
611
81bba717 612 // A structure is empty :
bbf32d01 613 // if all these groups are empty or if all
81bba717 614 // groups are empty and all their descendants
615 // are empty or if all its descendants are empty.
7fd59977 616
617 Standard_Boolean Result1 = Standard_True;
618 Standard_Integer i, Length = MyGroups.Length ();
619
81bba717 620 // Stop at the first non-empty group
7fd59977 621 for (i=1; i<=Length && Result1; i++)
622 Result1 = (MyGroups.Value (i))->IsEmpty ();
623
81bba717 624 // If a group is non-empty the structure is also non-empty.
7fd59977 625 if (! Result1) return (Standard_False);
626
627 Standard_Boolean Result2 = Standard_True;
628
629 Length = MyDescendants.Length ();
630
bbf32d01 631 // Stop at the first non-empty descendant
7fd59977 632 for (i=1; i<=Length && Result2; i++)
633 Result2 = ((Graphic3d_Structure *)
634 (MyDescendants.Value (i)))->IsEmpty ();
635
636 return (Result2);
637
638}
639
640void Graphic3d_Structure::PrimitivesAspect (Handle(Graphic3d_AspectLine3d)& CTXL, Handle(Graphic3d_AspectText3d)& CTXT, Handle(Graphic3d_AspectMarker3d)& CTXM, Handle(Graphic3d_AspectFillArea3d)& CTXF) const {
641
642 CTXL = Line3dAspect ();
643 CTXT = Text3dAspect ();
644 CTXM = Marker3dAspect ();
645 CTXF = FillArea3dAspect ();
646
647}
648
649void Graphic3d_Structure::GroupsWithFacet (const Standard_Integer ADelta) {
650
651 MyCStructure.ContainsFacet = MyCStructure.ContainsFacet + ADelta;
652 if (MyCStructure.ContainsFacet < 0) MyCStructure.ContainsFacet = 0;
653
654#ifdef DEBUG
655 cout << "MyCStructure.ContainsFacet " << MyCStructure.ContainsFacet;
656 cout << endl << flush;
657#endif
658
659}
660
661Handle(Graphic3d_Structure) Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& ) {
662
663 // Implemented by Presentation
664 return this;
665}
666
667Handle(Graphic3d_Structure) Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& , const TColStd_Array2OfReal& ) {
668
669 // Implemented by Presentation
670 return this;
671}
672
673void Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& , Handle(Graphic3d_Structure)& ) {
674
675 // Implemented by Presentation
676}
677
678void Graphic3d_Structure::Compute (const Handle(Graphic3d_DataStructureManager)& , const TColStd_Array2OfReal& , Handle(Graphic3d_Structure)& ) {
679
680 // Implemented by Presentation
681}
682
683void Graphic3d_Structure::ReCompute () {
684
685 MyStructureManager->ReCompute (this);
686
687}
688
689void Graphic3d_Structure::ReCompute (const Handle(Graphic3d_DataStructureManager)& aProjector) {
690
691 MyStructureManager->ReCompute (this, aProjector);
692
693}
694
695void Graphic3d_Structure::SetInfiniteState (const Standard_Boolean AValue) {
696
697 MyCStructure.IsInfinite = AValue ? 1:0;
698
699}
700
701Standard_Boolean Graphic3d_Structure::IsInfinite () const {
702
703 if (IsDeleted ()) return (Standard_True);
704
705 if (MyCStructure.IsInfinite)
706 return (Standard_True);
707 else
708 return (Standard_False);
709
710}
711
712void Graphic3d_Structure::GraphicClear (const Standard_Boolean WithDestruction) {
713
714 if (WithDestruction)
715 /*
716 * Dans ce cas l'appelant dans faire :
717 * void Prs3d_Presentation::Clear () {
718 * Graphic3d_Structure::Clear ();
719 * myCurrentGroup = new Graphic3d_Group (this);
720 * }
721 */
722 MyGraphicDriver->ClearStructure (MyCStructure);
723 else {
724 /*
725 * Dans ce cas l'appelant dans faire :
726 * void Prs3d_Presentation::Clear () {
727 * Graphic3d_Structure::Clear ();
728 * // myCurrentGroup = new Graphic3d_Group (this);
729 * }
730 */
731 Standard_Integer Length = MyGroups.Length ();
732
733 for (Standard_Integer i=1; i<=Length; i++)
734 (MyGroups.Value (i))->Clear ();
735 }
736
737}
738
739void Graphic3d_Structure::GraphicConnect (const Handle(Graphic3d_Structure)& ADaughter) {
740
741 MyGraphicDriver->Connect
742 (MyCStructure, *((CALL_DEF_STRUCTURE *)ADaughter->CStructure()));
743
744}
745
746void Graphic3d_Structure::GraphicDisconnect (const Handle(Graphic3d_Structure)& ADaughter) {
747
748 MyGraphicDriver->Disconnect
749 (MyCStructure, *((CALL_DEF_STRUCTURE *)ADaughter->CStructure()));
750
751}
752
753Handle(Graphic3d_AspectLine3d) Graphic3d_Structure::Line3dAspect () const {
754
755 Standard_Real R, G, B;
756 Standard_Real AWidth;
757 Quantity_Color AColor;
758 Aspect_TypeOfLine ALType;
759
760 // ContextLine
761 R = Standard_Real (MyCStructure.ContextLine.Color.r);
762 G = Standard_Real (MyCStructure.ContextLine.Color.g);
763 B = Standard_Real (MyCStructure.ContextLine.Color.b);
764 AColor.SetValues (R, G, B, Quantity_TOC_RGB);
765 ALType = Aspect_TypeOfLine (MyCStructure.ContextLine.LineType);
766 AWidth = Standard_Real (MyCStructure.ContextLine.Width);
767
768 Handle(Graphic3d_AspectLine3d) CTXL =
769 new Graphic3d_AspectLine3d (AColor, ALType, AWidth);
770
771 return CTXL;
772
773}
774
775Handle(Graphic3d_AspectText3d) Graphic3d_Structure::Text3dAspect () const {
776
777 Standard_Real R, G, B;
778 Standard_CString AFont;
779 Standard_Real ASpace;
780 Standard_Real AnExpansion;
781 Quantity_Color AColor;
782 Aspect_TypeOfStyleText AStyle;
783 Aspect_TypeOfDisplayText ADisplayType;
784
785 // ContextText
786 R = Standard_Real (MyCStructure.ContextText.Color.r);
787 G = Standard_Real (MyCStructure.ContextText.Color.g);
788 B = Standard_Real (MyCStructure.ContextText.Color.b);
789 AColor.SetValues (R, G, B, Quantity_TOC_RGB);
790 AFont = Standard_CString (MyCStructure.ContextText.Font);
791 AnExpansion = Standard_Real (MyCStructure.ContextText.Expan);
792 ASpace = Standard_Real (MyCStructure.ContextText.Space);
793 AStyle = Aspect_TypeOfStyleText (MyCStructure.ContextText.Style);
794 ADisplayType = Aspect_TypeOfDisplayText (MyCStructure.ContextText.DisplayType);
795
796 Handle(Graphic3d_AspectText3d) CTXT =
797 new Graphic3d_AspectText3d (AColor, AFont, AnExpansion, ASpace,AStyle,ADisplayType);
798
799 return CTXT;
800
801}
802
803Handle(Graphic3d_AspectMarker3d) Graphic3d_Structure::Marker3dAspect () const {
804
805 Standard_Real R, G, B;
806 Standard_Real AScale;
807 Quantity_Color AColor;
808 Aspect_TypeOfMarker AMType;
809
810 // ContextMarker
811 R = Standard_Real (MyCStructure.ContextMarker.Color.r);
812 G = Standard_Real (MyCStructure.ContextMarker.Color.g);
813 B = Standard_Real (MyCStructure.ContextMarker.Color.b);
814 AColor.SetValues (R, G, B, Quantity_TOC_RGB);
815 AMType = Aspect_TypeOfMarker (MyCStructure.ContextMarker.MarkerType);
816 AScale = Standard_Real (MyCStructure.ContextMarker.Scale);
817
818 Handle(Graphic3d_AspectMarker3d) CTXM =
819 new Graphic3d_AspectMarker3d (AMType, AColor, AScale);
820
821 return CTXM;
822
823}
824
825Handle(Graphic3d_AspectFillArea3d) Graphic3d_Structure::FillArea3dAspect () const {
826
827 Standard_Real R, G, B;
828 Standard_Real AWidth;
829 Quantity_Color AColor;
830 Quantity_Color AnIntColor;
831 Quantity_Color AnEdgeColor;
832 Aspect_TypeOfLine ALType;
833 Aspect_InteriorStyle AStyle;
834 Standard_Boolean EdgeOn = Standard_False;
835 Graphic3d_MaterialAspect Front;
836 Graphic3d_MaterialAspect Back;
837
838 // ContextFillArea
839 AStyle = Aspect_InteriorStyle (MyCStructure.ContextFillArea.Style);
840 R = Standard_Real (MyCStructure.ContextFillArea.IntColor.r);
841 G = Standard_Real (MyCStructure.ContextFillArea.IntColor.g);
842 B = Standard_Real (MyCStructure.ContextFillArea.IntColor.b);
843 AnIntColor.SetValues (R, G, B, Quantity_TOC_RGB);
844 // Edges
845 if (MyCStructure.ContextFillArea.Edge == 1) EdgeOn = Standard_True;
846 R = Standard_Real (MyCStructure.ContextFillArea.EdgeColor.r);
847 G = Standard_Real (MyCStructure.ContextFillArea.EdgeColor.g);
848 B = Standard_Real (MyCStructure.ContextFillArea.EdgeColor.b);
849 AnEdgeColor.SetValues (R, G, B, Quantity_TOC_RGB);
850 ALType = Aspect_TypeOfLine (MyCStructure.ContextFillArea.LineType);
851 AWidth = Standard_Real (MyCStructure.ContextFillArea.Width);
852 // Back Material
853 Back.SetShininess (
854 Standard_Real (MyCStructure.ContextFillArea.Back.Shininess));
855 Back.SetAmbient (
856 Standard_Real (MyCStructure.ContextFillArea.Back.Ambient));
857 Back.SetDiffuse (
858 Standard_Real (MyCStructure.ContextFillArea.Back.Diffuse));
859 Back.SetSpecular (
860 Standard_Real (MyCStructure.ContextFillArea.Back.Specular));
861 Back.SetTransparency (
862 Standard_Real (MyCStructure.ContextFillArea.Back.Transparency));
863 Back.SetEmissive (
864 Standard_Real (MyCStructure.ContextFillArea.Back.Emission));
865 if (MyCStructure.ContextFillArea.Back.IsAmbient == 1)
866 Back.SetReflectionModeOn (Graphic3d_TOR_AMBIENT);
867 else
868 Back.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
869 if (MyCStructure.ContextFillArea.Back.IsDiffuse == 1)
870 Back.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE);
871 else
872 Back.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
873 if (MyCStructure.ContextFillArea.Back.IsSpecular == 1)
874 Back.SetReflectionModeOn (Graphic3d_TOR_SPECULAR);
875 else
876 Back.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
877 if (MyCStructure.ContextFillArea.Back.IsEmission == 1)
878 Back.SetReflectionModeOn (Graphic3d_TOR_EMISSION);
879 else
880 Back.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
881
882 R = Standard_Real (MyCStructure.ContextFillArea.Back.ColorSpec.r);
883 G = Standard_Real (MyCStructure.ContextFillArea.Back.ColorSpec.g);
884 B = Standard_Real (MyCStructure.ContextFillArea.Back.ColorSpec.b);
885 AColor.SetValues (R, G, B, Quantity_TOC_RGB);
886 Back.SetSpecularColor (AColor);
887
888 R = Standard_Real (MyCStructure.ContextFillArea.Back.ColorAmb.r);
889 G = Standard_Real (MyCStructure.ContextFillArea.Back.ColorAmb.g);
890 B = Standard_Real (MyCStructure.ContextFillArea.Back.ColorAmb.b);
891 AColor.SetValues (R, G, B, Quantity_TOC_RGB);
892 Back.SetAmbientColor (AColor);
893
894 R = Standard_Real (MyCStructure.ContextFillArea.Back.ColorDif.r);
895 G = Standard_Real (MyCStructure.ContextFillArea.Back.ColorDif.g);
896 B = Standard_Real (MyCStructure.ContextFillArea.Back.ColorDif.b);
897 AColor.SetValues (R, G, B, Quantity_TOC_RGB);
898 Back.SetDiffuseColor (AColor);
899
900 R = Standard_Real (MyCStructure.ContextFillArea.Back.ColorEms.r);
901 G = Standard_Real (MyCStructure.ContextFillArea.Back.ColorEms.g);
902 B = Standard_Real (MyCStructure.ContextFillArea.Back.ColorEms.b);
903 AColor.SetValues (R, G, B, Quantity_TOC_RGB);
904 Back.SetEmissiveColor (AColor);
905
906 Back.SetEnvReflexion (MyCStructure.ContextFillArea.Back.EnvReflexion);
907
bbf32d01
K
908 Graphic3d_TypeOfMaterial mType =
909 MyCStructure.ContextFillArea.Back.IsPhysic ?
7fd59977 910Graphic3d_MATERIAL_PHYSIC : Graphic3d_MATERIAL_ASPECT;
911 Back.SetMaterialType(mType);
912
913 // Front Material
914 Front.SetShininess (
915 Standard_Real (MyCStructure.ContextFillArea.Front.Shininess));
916 Front.SetAmbient (
917 Standard_Real (MyCStructure.ContextFillArea.Front.Ambient));
918 Front.SetDiffuse (
919 Standard_Real (MyCStructure.ContextFillArea.Front.Diffuse));
920 Front.SetSpecular (
921 Standard_Real (MyCStructure.ContextFillArea.Front.Specular));
922 Front.SetTransparency (
923 Standard_Real (MyCStructure.ContextFillArea.Front.Transparency));
924 Front.SetEmissive (
925 Standard_Real (MyCStructure.ContextFillArea.Front.Emission));
926 if (MyCStructure.ContextFillArea.Front.IsAmbient == 1)
927 Front.SetReflectionModeOn (Graphic3d_TOR_AMBIENT);
928 else
929 Front.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
930 if (MyCStructure.ContextFillArea.Front.IsDiffuse == 1)
931 Front.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE);
932 else
933 Front.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
934 if (MyCStructure.ContextFillArea.Front.IsSpecular == 1)
935 Front.SetReflectionModeOn (Graphic3d_TOR_SPECULAR);
936 else
937 Front.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
938 if (MyCStructure.ContextFillArea.Front.Emission == 1)
939 Front.SetReflectionModeOn (Graphic3d_TOR_EMISSION);
940 else
941 Front.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
942
943 R = Standard_Real (MyCStructure.ContextFillArea.Front.ColorSpec.r);
944 G = Standard_Real (MyCStructure.ContextFillArea.Front.ColorSpec.g);
945 B = Standard_Real (MyCStructure.ContextFillArea.Front.ColorSpec.b);
946 AColor.SetValues (R, G, B, Quantity_TOC_RGB);
947 Front.SetSpecularColor (AColor);
948
949 R = Standard_Real (MyCStructure.ContextFillArea.Front.ColorAmb.r);
950 G = Standard_Real (MyCStructure.ContextFillArea.Front.ColorAmb.g);
951 B = Standard_Real (MyCStructure.ContextFillArea.Front.ColorAmb.b);
952 AColor.SetValues (R, G, B, Quantity_TOC_RGB);
953 Front.SetAmbientColor (AColor);
954
955 R = Standard_Real (MyCStructure.ContextFillArea.Front.ColorDif.r);
956 G = Standard_Real (MyCStructure.ContextFillArea.Front.ColorDif.g);
957 B = Standard_Real (MyCStructure.ContextFillArea.Front.ColorDif.b);
958 AColor.SetValues (R, G, B, Quantity_TOC_RGB);
959 Front.SetDiffuseColor (AColor);
960
961 R = Standard_Real (MyCStructure.ContextFillArea.Front.ColorEms.r);
962 G = Standard_Real (MyCStructure.ContextFillArea.Front.ColorEms.g);
963 B = Standard_Real (MyCStructure.ContextFillArea.Front.ColorEms.b);
964 AColor.SetValues (R, G, B, Quantity_TOC_RGB);
965 Front.SetEmissiveColor (AColor);
966
967 Front.SetEnvReflexion (MyCStructure.ContextFillArea.Front.EnvReflexion);
968
969 mType = MyCStructure.ContextFillArea.Front.IsPhysic ? Graphic3d_MATERIAL_PHYSIC : Graphic3d_MATERIAL_ASPECT;
970 Front.SetMaterialType(mType);
971
972 Handle(Graphic3d_AspectFillArea3d) CTXF =
973 new Graphic3d_AspectFillArea3d (AStyle, AnIntColor, AnEdgeColor, ALType, AWidth, Front, Back);
974
975 // Edges
976 if (EdgeOn)
977 CTXF->SetEdgeOn ();
978 else
979 CTXF->SetEdgeOff ();
980 // Hatch
981 CTXF->SetHatchStyle(Aspect_HatchStyle (MyCStructure.ContextFillArea.Hatch));
982 // Materials
983 // Front and Back face
984 if (MyCStructure.ContextFillArea.Distinguish == 1)
985 CTXF->SetDistinguishOn ();
986 else
987 CTXF->SetDistinguishOff ();
988 if (MyCStructure.ContextFillArea.BackFace == 1)
989 CTXF->SuppressBackFace ();
990 else
991 CTXF->AllowBackFace ();
992 // Texture
993 // Pb sur les textures
994 //if (MyCStructure.ContextFillArea.Texture.TexId == -1)
995 //else
996 if (MyCStructure.ContextFillArea.Texture.doTextureMap == 1)
997 CTXF->SetTextureMapOn ();
998 else
999 CTXF->SetTextureMapOff ();
1000#ifdef G003
1001 Aspect_TypeOfDegenerateModel dMode = Aspect_TypeOfDegenerateModel(
bbf32d01 1002 MyCStructure.ContextFillArea.DegenerationMode);
7fd59977 1003 Quantity_Ratio dRatio =
1004 MyCStructure.ContextFillArea.SkipRatio;
1005 CTXF->SetDegenerateModel(dMode,dRatio);
1006#endif // G003
1007
bbf32d01
K
1008 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
1009 CTXF->SetPolygonOffsets(MyCStructure.ContextFillArea.PolygonOffsetMode,
7fd59977 1010 MyCStructure.ContextFillArea.PolygonOffsetFactor,
1011 MyCStructure.ContextFillArea.PolygonOffsetUnits);
bbf32d01 1012 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
7fd59977 1013
1014 return CTXF;
1015
1016}
1017
bbf32d01
K
1018const Graphic3d_SequenceOfGroup& Graphic3d_Structure::Groups() const {
1019 return MyGroups;
7fd59977 1020}
1021
1022Standard_Integer Graphic3d_Structure::NumberOfGroups () const {
7fd59977 1023 return (MyGroups.Length ());
7fd59977 1024}
1025
1026void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTX) {
1027
1028 if (IsDeleted ()) return;
1029
1030 Standard_Real R, G, B;
1031 Standard_Real AWidth;
1032 Quantity_Color AColor;
1033 Aspect_TypeOfLine ALType;
1034
1035 CTX->Values (AColor, ALType, AWidth);
1036 AColor.Values (R, G, B, Quantity_TOC_RGB);
1037
1038 MyCStructure.ContextLine.Color.r = float (R);
1039 MyCStructure.ContextLine.Color.g = float (G);
1040 MyCStructure.ContextLine.Color.b = float (B);
1041 MyCStructure.ContextLine.LineType = int (ALType);
1042 MyCStructure.ContextLine.Width = float (AWidth);
1043 MyCStructure.ContextLine.IsDef = 1;
1044
1045 MyGraphicDriver->ContextStructure (MyCStructure);
1046
1047 // CAL 14/04/95
bbf32d01
K
1048 // Attributes are "IsSet" during the first update
1049 // of context (line, marker...)
7fd59977 1050 MyCStructure.ContextLine.IsSet = 1;
1051 MyCStructure.ContextFillArea.IsSet = 1;
1052 MyCStructure.ContextMarker.IsSet = 1;
1053 MyCStructure.ContextText.IsSet = 1;
1054
1055 Update ();
1056
1057}
1058
1059void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& CTX) {
1060
1061 if (IsDeleted ()) return;
1062
1063 Standard_Real R, G, B;
1064 Standard_Real AWidth;
1065 Quantity_Color AnIntColor;
1066 Quantity_Color BackIntColor;
1067 Quantity_Color AnEdgeColor;
1068 Aspect_TypeOfLine ALType;
1069 Aspect_InteriorStyle AStyle;
1070
1071 CTX->Values (AStyle, AnIntColor, BackIntColor, AnEdgeColor, ALType, AWidth);
1072 AnIntColor.Values (R, G, B, Quantity_TOC_RGB);
1073
1074 MyCStructure.ContextFillArea.Style = int (AStyle);
1075 MyCStructure.ContextFillArea.IntColor.r = float (R);
1076 MyCStructure.ContextFillArea.IntColor.g = float (G);
1077 MyCStructure.ContextFillArea.IntColor.b = float (B);
1078
1079#ifdef OCC1174
1080 if ( CTX->Distinguish() )
1081 BackIntColor.Values( R, G, B, Quantity_TOC_RGB );
1082#endif
1083 MyCStructure.ContextFillArea.BackIntColor.r = float( R );
1084 MyCStructure.ContextFillArea.BackIntColor.g = float( G );
1085 MyCStructure.ContextFillArea.BackIntColor.b = float( B );
1086
1087
1088 // Edges
1089 MyCStructure.ContextFillArea.Edge = CTX->Edge () ? 1:0;
1090 AnEdgeColor.Values (R, G, B, Quantity_TOC_RGB);
1091 MyCStructure.ContextFillArea.EdgeColor.r = float (R);
1092 MyCStructure.ContextFillArea.EdgeColor.g = float (G);
1093 MyCStructure.ContextFillArea.EdgeColor.b = float (B);
1094 MyCStructure.ContextFillArea.LineType = int (ALType);
1095 MyCStructure.ContextFillArea.Width = float (AWidth);
1096 MyCStructure.ContextFillArea.Hatch = int (CTX->HatchStyle ());
1097#ifdef G003
1098 Quantity_Ratio ratio;
bbf32d01 1099 MyCStructure.ContextFillArea.DegenerationMode =
7fd59977 1100 int (CTX->DegenerateModel(ratio));
1101 MyCStructure.ContextFillArea.SkipRatio = float (ratio);
1102#endif // G003
1103
1104 /*** Front and Back face ***/
1105 MyCStructure.ContextFillArea.Distinguish = CTX->Distinguish () ? 1:0;
1106 MyCStructure.ContextFillArea.BackFace = CTX->BackFace () ? 1:0;
1107
1108 /*** Back Material ***/
1109 // Light specificity
1110 MyCStructure.ContextFillArea.Back.Shininess =
1111 float ((CTX->BackMaterial ()).Shininess ());
1112 MyCStructure.ContextFillArea.Back.Ambient =
1113 float ((CTX->BackMaterial ()).Ambient ());
1114 MyCStructure.ContextFillArea.Back.Diffuse =
1115 float ((CTX->BackMaterial ()).Diffuse ());
1116 MyCStructure.ContextFillArea.Back.Specular =
1117 float ((CTX->BackMaterial ()).Specular ());
1118 MyCStructure.ContextFillArea.Back.Transparency =
1119 float ((CTX->BackMaterial ()).Transparency ());
1120 MyCStructure.ContextFillArea.Back.Emission =
1121 float ((CTX->BackMaterial ()).Emissive ());
1122
1123 // Reflection mode
1124 MyCStructure.ContextFillArea.Back.IsAmbient =
1125 ( (CTX->BackMaterial ()).ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0 );
1126 MyCStructure.ContextFillArea.Back.IsDiffuse =
1127 ( (CTX->BackMaterial ()).ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0 );
1128 MyCStructure.ContextFillArea.Back.IsSpecular =
1129 ( (CTX->BackMaterial ()).ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0 );
1130 MyCStructure.ContextFillArea.Back.IsEmission =
1131 ( (CTX->BackMaterial ()).ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0 );
1132
1133 // Material type
1134 //JR/Hp
1135 const Graphic3d_MaterialAspect ama = CTX->BackMaterial () ;
1136 Standard_Boolean amt = ama.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
1137 MyCStructure.ContextFillArea.Back.IsPhysic = ( amt ? 1 : 0 );
1138
bbf32d01 1139 // Specular Color
7fd59977 1140 MyCStructure.ContextFillArea.Back.ColorSpec.r =
1141 float (((CTX->BackMaterial ()).SpecularColor ()).Red ());
1142 MyCStructure.ContextFillArea.Back.ColorSpec.g =
1143 float (((CTX->BackMaterial ()).SpecularColor ()).Green ());
1144 MyCStructure.ContextFillArea.Back.ColorSpec.b =
1145 float (((CTX->BackMaterial ()).SpecularColor ()).Blue ());
1146
1147 // Ambient color
1148 MyCStructure.ContextFillArea.Back.ColorAmb.r =
1149 float (((CTX->BackMaterial ()).AmbientColor ()).Red ());
1150 MyCStructure.ContextFillArea.Back.ColorAmb.g =
1151 float (((CTX->BackMaterial ()).AmbientColor ()).Green ());
1152 MyCStructure.ContextFillArea.Back.ColorAmb.b =
1153 float (((CTX->BackMaterial ()).AmbientColor ()).Blue ());
1154
1155 // Diffuse color
1156 MyCStructure.ContextFillArea.Back.ColorDif.r =
1157 float (((CTX->BackMaterial ()).DiffuseColor ()).Red ());
1158 MyCStructure.ContextFillArea.Back.ColorDif.g =
1159 float (((CTX->BackMaterial ()).DiffuseColor ()).Green ());
1160 MyCStructure.ContextFillArea.Back.ColorDif.b =
1161 float (((CTX->BackMaterial ()).DiffuseColor ()).Blue ());
1162
1163 // Emissive color
1164 MyCStructure.ContextFillArea.Back.ColorEms.r =
1165 float (((CTX->BackMaterial ()).EmissiveColor ()).Red ());
1166 MyCStructure.ContextFillArea.Back.ColorEms.g =
1167 float (((CTX->BackMaterial ()).EmissiveColor ()).Green ());
1168 MyCStructure.ContextFillArea.Back.ColorEms.b =
1169 float (((CTX->BackMaterial ()).EmissiveColor ()).Blue ());
1170
bbf32d01 1171 MyCStructure.ContextFillArea.Back.EnvReflexion =
7fd59977 1172 float ((CTX->BackMaterial ()).EnvReflexion());
1173
1174 /*** Front Material ***/
1175 // Light specificity
1176 MyCStructure.ContextFillArea.Front.Shininess =
1177 float ((CTX->FrontMaterial ()).Shininess ());
1178 MyCStructure.ContextFillArea.Front.Ambient =
1179 float ((CTX->FrontMaterial ()).Ambient ());
1180 MyCStructure.ContextFillArea.Front.Diffuse =
1181 float ((CTX->FrontMaterial ()).Diffuse ());
1182 MyCStructure.ContextFillArea.Front.Specular =
1183 float ((CTX->FrontMaterial ()).Specular ());
1184 MyCStructure.ContextFillArea.Front.Transparency =
1185 float ((CTX->FrontMaterial ()).Transparency ());
1186 MyCStructure.ContextFillArea.Front.Emission =
1187 float ((CTX->FrontMaterial ()).Emissive ());
1188
1189 // Reflection mode
1190 MyCStructure.ContextFillArea.Front.IsAmbient =
1191 ( (CTX->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0 );
1192 MyCStructure.ContextFillArea.Front.IsDiffuse =
1193 ( (CTX->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0 );
1194 MyCStructure.ContextFillArea.Front.IsSpecular =
1195 ( (CTX->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0 );
1196 MyCStructure.ContextFillArea.Front.IsEmission =
1197 ( (CTX->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0 );
1198
1199 // Materail type
1200 //JR/Hp
1201 const Graphic3d_MaterialAspect amas = CTX->FrontMaterial () ;
1202 Standard_Boolean amty = amas.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
1203 MyCStructure.ContextFillArea.Front.IsPhysic = ( amty ? 1 : 0 );
1204
1205 // Specular Color
1206 MyCStructure.ContextFillArea.Front.ColorSpec.r =
1207 float (((CTX->FrontMaterial ()).SpecularColor ()).Red ());
1208 MyCStructure.ContextFillArea.Front.ColorSpec.g =
1209 float (((CTX->FrontMaterial ()).SpecularColor ()).Green ());
1210 MyCStructure.ContextFillArea.Front.ColorSpec.b =
1211 float (((CTX->FrontMaterial ()).SpecularColor ()).Blue ());
1212
1213 // Ambient color
1214 MyCStructure.ContextFillArea.Front.ColorAmb.r =
1215 float (((CTX->FrontMaterial ()).AmbientColor ()).Red ());
1216 MyCStructure.ContextFillArea.Front.ColorAmb.g =
1217 float (((CTX->FrontMaterial ()).AmbientColor ()).Green ());
1218 MyCStructure.ContextFillArea.Front.ColorAmb.b =
1219 float (((CTX->FrontMaterial ()).AmbientColor ()).Blue ());
1220
1221 // Diffuse color
1222 MyCStructure.ContextFillArea.Front.ColorDif.r =
1223 float (((CTX->FrontMaterial ()).DiffuseColor ()).Red ());
1224 MyCStructure.ContextFillArea.Front.ColorDif.g =
1225 float (((CTX->FrontMaterial ()).DiffuseColor ()).Green ());
1226 MyCStructure.ContextFillArea.Front.ColorDif.b =
1227 float (((CTX->FrontMaterial ()).DiffuseColor ()).Blue ());
1228
1229 // Emissive color
1230 MyCStructure.ContextFillArea.Front.ColorEms.r =
1231 float (((CTX->FrontMaterial ()).EmissiveColor ()).Red ());
1232 MyCStructure.ContextFillArea.Front.ColorEms.g =
1233 float (((CTX->FrontMaterial ()).EmissiveColor ()).Green ());
1234 MyCStructure.ContextFillArea.Front.ColorEms.b =
1235 float (((CTX->FrontMaterial ()).EmissiveColor ()).Blue ());
1236
bbf32d01 1237 MyCStructure.ContextFillArea.Front.EnvReflexion =
7fd59977 1238 float ((CTX->FrontMaterial ()).EnvReflexion());
1239
1240 MyCStructure.ContextFillArea.IsDef = 1; // Definition material ok
1241
1242 Handle(Graphic3d_TextureMap) TempTextureMap = CTX->TextureMap();
1243 if (! TempTextureMap.IsNull() )
1244 MyCStructure.ContextFillArea.Texture.TexId = TempTextureMap->TextureId();
1245 else
1246 MyCStructure.ContextFillArea.Texture.TexId = -1;
1247
1248 MyCStructure.ContextFillArea.Texture.doTextureMap = CTX->TextureMapState() ? 1:0;
1249
bbf32d01 1250 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
7fd59977 1251 Standard_Integer aPolyMode;
1252 Standard_Real aPolyFactor, aPolyUnits;
1253 CTX->PolygonOffsets(aPolyMode, aPolyFactor, aPolyUnits);
1254 MyCStructure.ContextFillArea.PolygonOffsetMode = aPolyMode;
1255 MyCStructure.ContextFillArea.PolygonOffsetFactor = aPolyFactor;
1256 MyCStructure.ContextFillArea.PolygonOffsetUnits = aPolyUnits;
bbf32d01 1257 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
7fd59977 1258
1259 MyGraphicDriver->ContextStructure (MyCStructure);
1260#ifdef G003
1261 MyGraphicDriver -> DegenerateStructure (MyCStructure);
1262#endif
1263
1264 // CAL 14/04/95
81bba717 1265 // Attributes are "IsSet" during the first update
1266 // of context (line, marker...)
7fd59977 1267 MyCStructure.ContextLine.IsSet = 1;
1268 MyCStructure.ContextFillArea.IsSet = 1;
1269 MyCStructure.ContextMarker.IsSet = 1;
1270 MyCStructure.ContextText.IsSet = 1;
1271
1272 Update ();
1273
1274}
1275
1276void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& CTX) {
1277
1278 if (IsDeleted ()) return;
1279
1280 Standard_Real R, G, B;
1281 Standard_Real Rs, Gs, Bs;
1282 Standard_CString AFont;
1283 Standard_Real ASpace;
1284 Standard_Real AnExpansion;
1285 Quantity_Color AColor;
1286 Aspect_TypeOfStyleText AStyle;
1287 Aspect_TypeOfDisplayText ADisplayType;
1288 Quantity_Color AColorSubTitle;
1289 Standard_Boolean ATextZoomable;
1290 Standard_Real ATextAngle;
1291 OSD_FontAspect ATextFontAspect;
1292
1293 CTX->Values (AColor, AFont, AnExpansion, ASpace, AStyle, ADisplayType,AColorSubTitle,ATextZoomable,ATextAngle,ATextFontAspect);
1294 AColor.Values (R, G, B, Quantity_TOC_RGB);
1295 AColorSubTitle.Values (Rs, Gs, Bs, Quantity_TOC_RGB);
1296
1297 MyCStructure.ContextText.Color.r = float (R);
1298 MyCStructure.ContextText.Color.g = float (G);
1299 MyCStructure.ContextText.Color.b = float (B);
1300 MyCStructure.ContextText.Font = (char*) (AFont);
1301 MyCStructure.ContextText.Expan = float (AnExpansion);
1302 MyCStructure.ContextText.Space = float (ASpace);
1303 MyCStructure.ContextText.Style = int (AStyle);
1304 MyCStructure.ContextText.DisplayType = int (ADisplayType);
1305 MyCStructure.ContextText.ColorSubTitle.r = float (Rs);
1306 MyCStructure.ContextText.ColorSubTitle.g = float (Gs);
1307 MyCStructure.ContextText.ColorSubTitle.b = float (Bs);
bbf32d01
K
1308 MyCStructure.ContextText.TextZoomable = ATextZoomable;
1309 MyCStructure.ContextText.TextAngle = ATextAngle;
1310 MyCStructure.ContextText.TextFontAspect = (int)ATextFontAspect;
7fd59977 1311
1312 MyCStructure.ContextText.IsDef = 1;
1313
1314 MyGraphicDriver->ContextStructure (MyCStructure);
1315
1316 // CAL 14/04/95
81bba717 1317 // Attributes are "IsSet" during the first update of a context (line, marker...)
7fd59977 1318 MyCStructure.ContextLine.IsSet = 1;
1319 MyCStructure.ContextFillArea.IsSet = 1;
1320 MyCStructure.ContextMarker.IsSet = 1;
1321 MyCStructure.ContextText.IsSet = 1;
1322
1323 Update ();
1324
1325}
1326
1327void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& CTX) {
1328
1329 if (IsDeleted ()) return;
1330
1331 Standard_Real R, G, B;
1332 Standard_Real AScale;
1333 Quantity_Color AColor;
1334 Aspect_TypeOfMarker AMType;
1335
1336 CTX->Values (AColor, AMType, AScale);
1337 AColor.Values (R, G, B, Quantity_TOC_RGB);
1338
1339 MyCStructure.ContextMarker.Color.r = float (R);
1340 MyCStructure.ContextMarker.Color.g = float (G);
1341 MyCStructure.ContextMarker.Color.b = float (B);
1342 MyCStructure.ContextMarker.MarkerType = int (AMType);
1343 MyCStructure.ContextMarker.Scale = float (AScale);
1344 MyCStructure.ContextMarker.IsDef = 1;
1345
1346 MyGraphicDriver->ContextStructure (MyCStructure);
1347
81bba717 1348 // Attributes are "IsSet" during the first update of a context (line, marker...)
7fd59977 1349 MyCStructure.ContextLine.IsSet = 1;
1350 MyCStructure.ContextFillArea.IsSet = 1;
1351 MyCStructure.ContextMarker.IsSet = 1;
1352 MyCStructure.ContextText.IsSet = 1;
1353
1354 Update ();
1355
1356}
1357
1358void Graphic3d_Structure::SetVisual (const Graphic3d_TypeOfStructure AVisual) {
1359
1360 if (IsDeleted ()) return;
1361 if (MyVisual == AVisual) return;
1362
1363 if (! MyCStructure.stick) {
1364 MyVisual = AVisual;
1365 SetComputeVisual (AVisual);
1366 }
1367 else {
1368
1369 Aspect_TypeOfUpdate UpdateMode = MyStructureManager->UpdateMode ();
1370 if (UpdateMode == Aspect_TOU_WAIT) {
1371 Erase ();
1372 MyVisual = AVisual;
1373 SetComputeVisual (AVisual);
1374 Display ();
1375 }
1376 else {
81bba717 1377 // To avoid calling method : Update ()
1378 // Not useful and can be costly.
7fd59977 1379 MyStructureManager->SetUpdateMode (Aspect_TOU_WAIT);
1380 Erase ();
1381 MyVisual = AVisual;
1382 SetComputeVisual (AVisual);
1383 MyStructureManager->SetUpdateMode (UpdateMode);
1384 Display ();
1385 }
1386 }
1387
1388}
1389
1390void Graphic3d_Structure::SetZoomLimit (const Standard_Real LimitInf, const Standard_Real LimitSup) {
1391
1392 if (LimitInf <= 0.0)
1393 Graphic3d_StructureDefinitionError::Raise
1394 ("Bad value for ZoomLimit inf");
1395
1396 if (LimitSup <= 0.0)
1397 Graphic3d_StructureDefinitionError::Raise
1398 ("Bad value for ZoomLimit sup");
1399
1400 if (LimitSup < LimitInf)
1401 Graphic3d_StructureDefinitionError::Raise
1402 ("ZoomLimit sup < ZoomLimit inf");
1403
1404}
1405
1406Graphic3d_TypeOfStructure Graphic3d_Structure::Visual () const {
1407
1408 return (MyVisual);
1409
1410}
1411
1412Standard_Boolean Graphic3d_Structure::AcceptConnection (const Handle(Graphic3d_Structure)& AStructure1, const Handle(Graphic3d_Structure)& AStructure2, const Graphic3d_TypeOfConnection AType) {
1413
1414 Graphic3d_MapOfStructure ASet;
1415
1416 // cycle detection
1417 Graphic3d_Structure::Network (AStructure2, AType, ASet);
1418
1419 return (! ASet.Contains (AStructure1));
1420
1421}
1422
1423void Graphic3d_Structure::Ancestors (Graphic3d_MapOfStructure &SG) const {
1424
1425 Standard_Integer i, Length = MyAncestors.Length ();
1426
1427 for (i=1; i<=Length; i++)
1428 SG.Add ((Graphic3d_Structure *) (MyAncestors.Value (i)));
1429
1430
1431}
1432
1433void Graphic3d_Structure::SetOwner (const Standard_Address Owner) {
1434
1435 MyOwner = Owner;
1436
1437}
1438
1439Standard_Address Graphic3d_Structure::Owner () const {
1440
1441 return MyOwner;
1442
1443}
1444
1445void Graphic3d_Structure::Descendants (Graphic3d_MapOfStructure& SG) const {
1446
1447 Standard_Integer i, Length = MyDescendants.Length ();
1448
1449 for (i=1; i<=Length; i++)
1450 SG.Add ((Graphic3d_Structure *) (MyDescendants.Value (i)));
1451
1452}
1453
1454void Graphic3d_Structure::Connect (const Handle(Graphic3d_Structure)& AStructure, const Graphic3d_TypeOfConnection AType, const Standard_Boolean WithCheck) {
1455
1456 if (IsDeleted ()) return;
1457
1458 if (WithCheck)
1459 // cycle detection
1460 if (! Graphic3d_Structure::AcceptConnection
1461 (this, AStructure, AType))
1462 return;
1463
1464 // connection
1465 Standard_Integer i;
bbf32d01 1466 switch (AType)
7fd59977 1467 {
1468
bbf32d01 1469 case Graphic3d_TOC_DESCENDANT :
7fd59977 1470 {
1471 Standard_Integer indexD = 0;
1472 Standard_Integer LengthD = MyDescendants.Length ();
1473 for (i=1; i<=LengthD && indexD==0; i++)
1474 if ((void *) (MyDescendants.Value (i)) ==
1475 (void *) (AStructure.operator->())) indexD = i;
1476
1477 if (indexD == 0) {
1478 MyDescendants.Append ((void *) AStructure.operator->());
1479 AStructure->Connect (this, Graphic3d_TOC_ANCESTOR);
1480
1481 GraphicConnect (AStructure);
1482 MyStructureManager->Connect (this, AStructure);
1483
1484 Update ();
1485 }
1486 }
1487 break;
1488
bbf32d01 1489 case Graphic3d_TOC_ANCESTOR :
7fd59977 1490 {
1491 Standard_Integer indexA = 0;
1492 Standard_Integer LengthA = MyAncestors.Length ();
1493 for (i=1; i<=LengthA && indexA==0; i++)
1494 if ((void *) (MyAncestors.Value (i)) ==
1495 (void *) (AStructure.operator->())) indexA = i;
1496
1497 if (indexA == 0) {
1498 MyAncestors.Append ((void *) AStructure.operator->());
1499 AStructure->Connect (this, Graphic3d_TOC_DESCENDANT);
1500
81bba717 1501 // MyGraphicDriver->Connect is called in case
1502 // if connection between parent and child
7fd59977 1503 }
1504 }
1505 break;
1506 }
1507
1508}
1509
1510void Graphic3d_Structure::Disconnect (const Handle(Graphic3d_Structure)& AStructure) {
1511
1512 if (IsDeleted ()) return;
1513
1514 Standard_Integer i;
1515
1516 Standard_Integer indexD = 0;
1517 Standard_Integer LengthD = MyDescendants.Length ();
1518 for (i=1; i<=LengthD && indexD==0; i++)
1519 if ((void *) (MyDescendants.Value (i)) ==
1520 (void *) (AStructure.operator->())) indexD = i;
1521
81bba717 1522 // Search in the Descendants
7fd59977 1523 if (indexD != 0) {
1524 MyDescendants.Remove (indexD);
1525 AStructure->Disconnect (this);
1526
1527 GraphicDisconnect (AStructure);
1528 MyStructureManager->Disconnect (this, AStructure);
1529
1530 Update ();
1531 }
1532 else {
1533 Standard_Integer indexA = 0;
1534 Standard_Integer LengthA = MyAncestors.Length ();
1535 for (i=1; i<=LengthA && indexA==0; i++)
1536 if ((void *) (MyAncestors.Value (i)) ==
1537 (void *) (AStructure.operator->())) indexA = i;
1538
81bba717 1539 // Search in the Ancestors
7fd59977 1540 if (indexA != 0) {
1541 MyAncestors.Remove (indexA);
1542 AStructure->Disconnect (this);
1543
81bba717 1544 // No call of MyGraphicDriver->Disconnect
1545 // in case of an ancestor
7fd59977 1546 }
1547 }
1548
1549}
1550
1551void Graphic3d_Structure::DisconnectAll (const Graphic3d_TypeOfConnection AType) {
1552
1553 if (IsDeleted ()) return;
1554
1555 Standard_Integer i, Length;
1556
1557 // disconnection
bbf32d01 1558 switch (AType)
7fd59977 1559 {
1560 case Graphic3d_TOC_DESCENDANT :
1561 Length = MyDescendants.Length ();
1562 for (i=1; i<=Length; i++)
81bba717 1563 // Value (1) instead of Value (i) as MyDescendants
1564 // is modified by :
7fd59977 1565 // Graphic3d_Structure::Disconnect (AStructure)
81bba717 1566 // that takes AStructure from MyDescendants
7fd59977 1567 ((Graphic3d_Structure *)
1568 (MyDescendants.Value (1)))->Disconnect (this);
1569 break;
1570 case Graphic3d_TOC_ANCESTOR :
1571 Length = MyAncestors.Length ();
1572 for (i=1; i<=Length; i++)
bbf32d01 1573 // Value (1) instead of Value (i) as MyAncestors
81bba717 1574 // is modified by :
7fd59977 1575 // Graphic3d_Structure::Disconnect (AStructure)
81bba717 1576 // that takes AStructure from MyAncestors
7fd59977 1577 ((Graphic3d_Structure *)
1578 (MyAncestors.Value (1)))->Disconnect (this);
1579 break;
1580 }
1581
1582}
1583
1584Graphic3d_TypeOfComposition Graphic3d_Structure::Composition () const {
1585
1586 if (MyCStructure.Composition)
1587 return (Graphic3d_TOC_POSTCONCATENATE);
1588 else
1589 return (Graphic3d_TOC_REPLACE);
1590
1591}
1592
1593void Graphic3d_Structure::SetTransform (const TColStd_Array2OfReal& AMatrix, const Graphic3d_TypeOfComposition AType) {
1594
1595 if (IsDeleted ()) return;
1596
1597 Standard_Integer lr, ur, lc, uc;
1598 Standard_Real valuetrsf;
1599 Standard_Real valueoldtrsf;
1600 Standard_Real valuenewtrsf;
1601 Standard_Integer i, j, k;
1602 TColStd_Array2OfReal TheTrsf (0, 3, 0, 3);
1603 TColStd_Array2OfReal NewTrsf (0, 3, 0, 3);
1604 TColStd_Array2OfReal AMatrix44 (0, 3, 0, 3);
1605
1606 // Assign the new transformation in an array [0..3][0..3]
81bba717 1607 // Avoid problemes if the user has defined matrice [1..4][1..4]
bbf32d01 1608 // or [3..6][-1..2] !!
7fd59977 1609 lr = AMatrix.LowerRow ();
1610 ur = AMatrix.UpperRow ();
1611 lc = AMatrix.LowerCol ();
1612 uc = AMatrix.UpperCol ();
1613
1614 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
1615 Graphic3d_TransformError::Raise
1616 ("Transform : not a 4x4 matrix");
1617
1618 if (AType == Graphic3d_TOC_REPLACE) {
1619 MyCStructure.Composition = 0;
81bba717 1620 // Update of CStructure
7fd59977 1621 for (i=0; i<=3; i++)
1622 for (j=0; j<=3; j++) {
1623 MyCStructure.Transformation[i][j] =
1624 float (AMatrix (lr + i, lc + j));
1625 NewTrsf (i, j) = AMatrix (lr + i, lc + j);
1626 }
1627 }
1628
1629 if (AType == Graphic3d_TOC_POSTCONCATENATE) {
1630 MyCStructure.Composition = 1;
81bba717 1631 // To simplify management of indices
7fd59977 1632 for (i=0; i<=3; i++)
1633 for (j=0; j<=3; j++)
1634 AMatrix44 (i, j) = AMatrix (lr + i, lc + j);
81bba717 1635 // Calculation of the product of matrices
7fd59977 1636 for (i=0; i<=3; i++)
1637 for (j=0; j<=3; j++) {
1638 NewTrsf (i, j) = 0.0;
1639 for (k=0; k<=3; k++) {
1640 valueoldtrsf = MyCStructure.Transformation[i][k];
1641 valuetrsf = AMatrix44 (k, j);
1642 valuenewtrsf = NewTrsf (i, j) +
1643 valueoldtrsf * valuetrsf;
1644 NewTrsf (i, j) = valuenewtrsf;
1645 }
1646 }
81bba717 1647 // Update of CStructure
7fd59977 1648 for (i=0; i<=3; i++)
1649 for (j=0; j<=3; j++)
1650 MyCStructure.Transformation[i][j] = float (NewTrsf (i, j));
1651 }
1652
81bba717 1653 // If transformation, no validation of hidden already calculated parts.
7fd59977 1654 if (IsRotated ())
1655 ReCompute ();
1656
1657 GraphicTransform (NewTrsf);
1658 MyStructureManager->SetTransform (this, NewTrsf);
1659
1660 Update ();
1661
1662}
1663
1664void Graphic3d_Structure::Transform (TColStd_Array2OfReal& AMatrix) const {
1665
1666 Standard_Integer lr = AMatrix.LowerRow ();
1667 Standard_Integer ur = AMatrix.UpperRow ();
1668 Standard_Integer lc = AMatrix.LowerCol ();
1669 Standard_Integer uc = AMatrix.UpperCol ();
1670
1671 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
1672 Graphic3d_TransformError::Raise
1673 ("Transform : not a 4x4 matrix");
1674
1675 for (Standard_Integer i=0; i<=3; i++)
1676 for (Standard_Integer j=0; j<=3; j++)
1677 AMatrix (lr + i, lc + j) = MyCStructure.Transformation[i][j];
1678
1679}
1680
1681void Graphic3d_Structure::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
1682
1683 Standard_Real RL = RealLast ();
1684 Standard_Real RF = RealFirst ();
1685
1686 Standard_Real XTMin, YTMin, ZTMin, XTMax, YTMax, ZTMax, U, V, W;
1687
1688 MinMaxCoord (XTMin, YTMin, ZTMin, XTMax, YTMax, ZTMax);
1689 if ((XTMin == RF) && (YTMin == RF) &&
1690 (ZTMin == RF) && (XTMax == RL) &&
1691 (YTMax == RL) && (ZTMax == RL)) {
bbf32d01 1692 // Case impossible as it would mean that
81bba717 1693 // the structure is empty
bbf32d01
K
1694 XMin = RF;
1695 YMin = RF;
7fd59977 1696 ZMin = RF;
bbf32d01 1697
7fd59977 1698 XMax = RL;
1699 YMax = RL;
1700 ZMax = RL;
1701 }
1702 else {
1703 Standard_Integer i, j;
1704 TColStd_Array2OfReal TheTrsf (0, 3, 0, 3);
1705
1706 for (i=0; i<=3; i++)
1707 for (j=0; j<=3; j++)
1708 TheTrsf (i, j) = MyCStructure.Transformation[i][j];
1709
1710 Graphic3d_Structure::Transforms
1711 (TheTrsf, XTMin, YTMin, ZTMin, XMin, YMin, ZMin);
1712 Graphic3d_Structure::Transforms
1713 (TheTrsf, XTMax, YTMax, ZTMax, XMax, YMax, ZMax);
1714 Graphic3d_Structure::Transforms
1715 (TheTrsf, XTMin, YTMin, ZTMax, U, V, W);
1716 XMin = Min(U,XMin) ; XMax = Max(U,XMax) ;
1717 YMin = Min(V,YMin) ; YMax = Max(V,YMax) ;
1718 ZMin = Min(W,ZMin) ; ZMax = Max(W,ZMax) ;
1719 Graphic3d_Structure::Transforms
1720 (TheTrsf, XTMax, YTMin, ZTMax, U, V, W);
1721 XMin = Min(U,XMin) ; XMax = Max(U,XMax) ;
1722 YMin = Min(V,YMin) ; YMax = Max(V,YMax) ;
1723 ZMin = Min(W,ZMin) ; ZMax = Max(W,ZMax) ;
1724 Graphic3d_Structure::Transforms
1725 (TheTrsf, XTMax, YTMin, ZTMin, U, V, W);
1726 XMin = Min(U,XMin) ; XMax = Max(U,XMax) ;
1727 YMin = Min(V,YMin) ; YMax = Max(V,YMax) ;
1728 ZMin = Min(W,ZMin) ; ZMax = Max(W,ZMax) ;
1729 Graphic3d_Structure::Transforms
1730 (TheTrsf, XTMax, YTMax, ZTMin, U, V, W);
1731 XMin = Min(U,XMin) ; XMax = Max(U,XMax) ;
1732 YMin = Min(V,YMin) ; YMax = Max(V,YMax) ;
1733 ZMin = Min(W,ZMin) ; ZMax = Max(W,ZMax) ;
1734 Graphic3d_Structure::Transforms
1735 (TheTrsf, XTMin, YTMax, ZTMax, U, V, W);
1736 XMin = Min(U,XMin) ; XMax = Max(U,XMax) ;
1737 YMin = Min(V,YMin) ; YMax = Max(V,YMax) ;
1738 ZMin = Min(W,ZMin) ; ZMax = Max(W,ZMax) ;
1739 Graphic3d_Structure::Transforms
1740 (TheTrsf, XTMin, YTMax, ZTMin, U, V, W);
1741 XMin = Min(U,XMin) ; XMax = Max(U,XMax) ;
1742 YMin = Min(V,YMin) ; YMax = Max(V,YMax) ;
1743 ZMin = Min(W,ZMin) ; ZMax = Max(W,ZMax) ;
1744 }
1745}
1746
1747void Graphic3d_Structure::GroupLabels (Standard_Integer& LB, Standard_Integer& LE) {
1748
1749 LB = MyGroupGenId.Next ();
1750 LE = MyGroupGenId.Next ();
1751
1752}
1753
1754Standard_Integer Graphic3d_Structure::Identification () const {
1755
1756 Standard_Integer Result = MyCStructure.Id;
1757
1758 return Result;
1759
1760}
1761
1762void Graphic3d_Structure::SetTransformPersistence( const Graphic3d_TransModeFlags& AFlag )
1763{
1764 SetTransformPersistence( AFlag, gp_Pnt( 0, 0, 0 ) );
1765}
1766
1767void Graphic3d_Structure::SetTransformPersistence( const Graphic3d_TransModeFlags& AFlag,
1768 const gp_Pnt& APoint )
1769{
bbf32d01 1770 if (IsDeleted ()) return;
7fd59977 1771
1772 MyCStructure.TransformPersistence.Flag = AFlag;
1773 MyCStructure.TransformPersistence.Point.x = APoint.X();
1774 MyCStructure.TransformPersistence.Point.y = APoint.Y();
1775 MyCStructure.TransformPersistence.Point.z = APoint.Z();
1776 //MyStructureManager->Update ();
1777 //Update();
1778 MyGraphicDriver->ContextStructure( MyCStructure );
1779
1780 MyCStructure.TransformPersistence.IsSet = 1;
1781}
1782
1783Graphic3d_TransModeFlags Graphic3d_Structure::TransformPersistenceMode() const
1784{
1785 return MyCStructure.TransformPersistence.Flag;
1786}
1787
1788gp_Pnt Graphic3d_Structure::TransformPersistencePoint() const
1789{
1790 gp_Pnt aPnt( 0., 0., 0. );
1791 aPnt.SetX( MyCStructure.TransformPersistence.Point.x );
1792 aPnt.SetY( MyCStructure.TransformPersistence.Point.y );
1793 aPnt.SetZ( MyCStructure.TransformPersistence.Point.z );
1794
1795 return aPnt;
1796}
1797
1798void Graphic3d_Structure::Add (const Handle(Graphic3d_Group)& AGroup) {
1799
81bba717 1800 // Method called only by the constructor of Graphic3d_Group
1801 // It is easy to check presence of <AGroup>
1802 // in sequence MyGroups.
7fd59977 1803 MyGroups.Append (AGroup);
1804
1805}
1806
1807void Graphic3d_Structure::Remove (const Standard_Address APtr, const Graphic3d_TypeOfConnection AType) {
1808
1809 Standard_Integer i, index, length;
1810
bbf32d01 1811 switch (AType)
7fd59977 1812 {
1813 case Graphic3d_TOC_DESCENDANT :
1814 index = 0;
1815 length = MyDescendants.Length ();
1816 for (i=1; i<=length && index==0; i++)
1817 if ((void *) (MyDescendants.Value (i)) == APtr)
1818 index = i;
1819 if (index != 0)
1820 MyDescendants.Remove (index);
1821#ifdef TRACE
1822 else
1823 cout << "Error, Graphic3d_Structure::Remove\n";
1824#endif
1825 break;
1826
1827 case Graphic3d_TOC_ANCESTOR :
1828 index = 0;
1829 length = MyAncestors.Length ();
1830 for (i=1; i<=length && index==0; i++)
1831 if ((void *) (MyAncestors.Value (i)) == APtr)
1832 index = i;
1833 if (index != 0)
1834 MyAncestors.Remove (index);
1835#ifdef TRACE
1836 else
1837 cout << "Error, Graphic3d_Structure::Remove\n";
1838#endif
1839 break;
1840 }
1841
1842}
1843
1844void Graphic3d_Structure::Remove (const Handle(Graphic3d_Group)& AGroup) {
1845
1846 Standard_Integer index = 0;
1847 Standard_Integer Length = MyGroups.Length ();
1848 for (Standard_Integer i=1; i<=Length && index==0; i++)
1849 if (MyGroups.Value (i) == AGroup) index = i;
1850
81bba717 1851 // Search in Groups
7fd59977 1852 if (index != 0) {
1853 Standard_Integer GroupLabelBegin, GroupLabelEnd;
1854 AGroup->Labels (GroupLabelBegin, GroupLabelEnd);
1855 MyGroupGenId.Free (GroupLabelBegin);
1856 MyGroupGenId.Free (GroupLabelEnd);
1857 MyGroups.Remove (index);
1858 }
1859
1860}
1861
1862Handle(Graphic3d_StructureManager) Graphic3d_Structure::StructureManager () const {
1863
1864#ifdef DOWNCAST
1865 return
1866 (Handle(Graphic3d_StructureManager)::DownCast(Handle(Standard_Transient)
1867 ((Standard_Transient*) MyPtrStructureManager)));
1868#else
1869 return MyStructureManager;
1870#endif
1871
1872}
1873
1874Graphic3d_TypeOfPrimitive Graphic3d_Structure::Type (const Standard_Integer ElementNumber) const {
1875
1876 if (IsDeleted ()) return (Graphic3d_TOP_UNDEFINED);
1877
1878 Graphic3d_TypeOfPrimitive Result;
1879
1880 Result = MyGraphicDriver->ElementType
1881 (MyCStructure, ElementNumber);
1882
1883 return (Result);
1884
1885}
1886
1887Standard_Boolean Graphic3d_Structure::Exploration (const Standard_Integer ElementNumber, Graphic3d_VertexNC& AVertex, Graphic3d_Vector& AVector) const {
1888
1889 Standard_Boolean Result = Standard_False;
1890
1891 if (IsDeleted ()) return (Result);
1892
1893 Result = MyGraphicDriver->ElementExploration
1894 (MyCStructure, ElementNumber, AVertex, AVector);
1895
1896 return (Result);
1897
1898}
1899
1900void Graphic3d_Structure::Exploration () const {
1901
1902 if (IsDeleted ()) return;
1903
1904 MyGraphicDriver->DumpStructure (MyCStructure);
1905
1906}
1907
1908void Graphic3d_Structure::MinMaxCoord (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
1909
1910 Standard_Real RL = RealLast ();
1911 Standard_Real RF = RealFirst ();
1912
1913 Standard_Real Xm, Ym, Zm, XM, YM, ZM;
1914
1915 //Bounding borders of infinite line has been calculated as own point
1916 //in center of this line
1917 if (IsEmpty () || IsInfinite ()) {
1918 if( IsInfinite ()){
1919 for (int i=1; i<=MyGroups.Length (); i++)
1920 if (! (MyGroups.Value (i))->IsEmpty () ) {
1921 (MyGroups.Value (i))->MinMaxValues(Xm, Ym, Zm, XM, YM, ZM);
1922 Graphic3d_Vertex vertex1(Xm, Ym, Zm);
1923 Graphic3d_Vertex vertex2(XM, YM, ZM);
1924 Standard_Real distance = vertex1.Distance( vertex1,vertex2 );
1925 if( distance >= 500000.0){
1926 XMin = XMax = (Xm+ XM)/2.0;
1927 YMin = YMax = (Ym+ YM)/2.0;
1928 ZMin = ZMax = (Zm+ ZM)/2.0;
1929 return;
bbf32d01 1930 }
7fd59977 1931 }
1932 }
1933 XMin = RF;
1934 YMin = RF;
1935 ZMin = RF;
1936
1937 XMax = RL;
1938 YMax = RL;
1939 ZMax = RL;
1940 }
1941 else {
1942 XMin = RL;
1943 YMin = RL;
1944 ZMin = RL;
1945
1946 XMax = RF;
1947 YMax = RF;
1948 ZMax = RF;
1949 Standard_Integer i, Length;
1950
1951 Length = MyGroups.Length ();
1952 for (i=1; i<=Length; i++)
1953 if (! (MyGroups.Value (i))->IsEmpty () ) {
1954 (MyGroups.Value (i))->MinMaxValues(Xm, Ym, Zm, XM, YM, ZM);
1955 if (Xm < XMin) XMin = Xm;
1956 if (Ym < YMin) YMin = Ym;
1957 if (Zm < ZMin) ZMin = Zm;
1958 if (XM > XMax) XMax = XM;
1959 if (YM > YMax) YMax = YM;
1960 if (ZM > ZMax) ZMax = ZM;
1961 }
1962
1963 Length = MyDescendants.Length ();
1964 for (i=1; i<=Length; i++)
1965 if (! ((Graphic3d_Structure *)
1966 (MyDescendants.Value (i)))->IsEmpty () ) {
1967 ((Graphic3d_Structure *)
1968 (MyDescendants.Value (i)))->MinMaxValues (Xm, Ym, Zm, XM, YM, ZM);
1969
1970 if (Xm < XMin) XMin = Xm;
1971 if (Ym < YMin) YMin = Ym;
1972 if (Zm < ZMin) ZMin = Zm;
1973 if (XM > XMax) XMax = XM;
1974 if (YM > YMax) YMax = YM;
1975 if (ZM > ZMax) ZMax = ZM;
1976 }
1977
1978 if ((XMin == RL) && (YMin == RL) &&
1979 (ZMin == RL) && (XMax == RF) &&
1980 (YMax == RF) && (ZMax == RF)) {
bbf32d01 1981 // Case impossible as it would mean
81bba717 1982 // that the structure is empty
7fd59977 1983 XMin = RF;
1984 YMin = RF;
1985 ZMin = RF;
1986
1987 XMax = RL;
1988 YMax = RL;
1989 ZMax = RL;
1990 }
1991
1992 }
1993
1994}
1995
1996void Graphic3d_Structure::Transforms (const TColStd_Array2OfReal& ATrsf, const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Real& NewX, Standard_Real& NewY, Standard_Real& NewZ) {
1997
1998 Standard_Real A, B, C, D;
1999
2000 Standard_Real RL = RealLast ();
2001 Standard_Real RF = RealFirst ();
2002
2003 if ((X == RF) || (Y == RF) || (Z == RF) ||
2004 (X == RL) || (Y == RL) || (Z == RL)) {
2005 NewX = X;
2006 NewY = Y;
2007 NewZ = Z;
2008 }
2009 else {
2010 A = ATrsf (0, 0);
2011 B = ATrsf (0, 1);
2012 C = ATrsf (0, 2);
2013 D = ATrsf (0, 3);
2014 NewX = A * X + B * Y + C * Z + D;
2015 A = ATrsf (1, 0);
2016 B = ATrsf (1, 1);
2017 C = ATrsf (1, 2);
2018 D = ATrsf (1, 3);
2019 NewY = A * X + B * Y + C * Z + D;
2020 A = ATrsf (2, 0);
2021 B = ATrsf (2, 1);
2022 C = ATrsf (2, 2);
2023 D = ATrsf (2, 3);
2024 NewZ = A * X + B * Y + C * Z + D;
2025 }
2026
2027}
2028
2029Graphic3d_Vector Graphic3d_Structure::Transforms (const TColStd_Array2OfReal& ATrsf, const Graphic3d_Vector& Coord) {
2030
2031 Standard_Real NewX, NewY, NewZ;
2032 Graphic3d_Vector Result;
2033
2034 Graphic3d_Structure::Transforms
2035 (ATrsf, Coord.X (), Coord.Y (), Coord.Z (), NewX, NewY, NewZ);
2036 Result.SetCoord (NewX, NewY, NewZ);
2037
2038 return (Result);
2039
2040}
2041
2042Graphic3d_Vertex Graphic3d_Structure::Transforms (const TColStd_Array2OfReal& ATrsf, const Graphic3d_Vertex& Coord) {
2043
2044 Standard_Real NewX, NewY, NewZ;
2045 Graphic3d_Vertex Result;
2046
2047 Graphic3d_Structure::Transforms
2048 (ATrsf, Coord.X (), Coord.Y (), Coord.Z (), NewX, NewY, NewZ);
2049 Result.SetCoord (NewX, NewY, NewZ);
2050
2051 return (Result);
2052
2053}
2054
2055void Graphic3d_Structure::Network (const Handle(Graphic3d_Structure)& AStructure, const Graphic3d_TypeOfConnection AType, Graphic3d_MapOfStructure& ASet) {
2056
2057
2058 Graphic3d_MapOfStructure h1;
2059 Graphic3d_MapOfStructure h2;
2060 AStructure->Descendants (h1);
2061 AStructure->Ancestors (h2);
2062
2063 Graphic3d_MapIteratorOfMapOfStructure IteratorD (h1);
2064 Graphic3d_MapIteratorOfMapOfStructure IteratorA (h2);
2065
2066 ASet.Add (AStructure);
2067
2068 // exploration
bbf32d01 2069 switch (AType)
7fd59977 2070 {
2071
2072 case Graphic3d_TOC_DESCENDANT :
2073 while (IteratorD.More ()) {
2074 Graphic3d_Structure::Network
2075 (IteratorD.Key (), AType, ASet);
81bba717 2076 // IteratorD.Next () is located on the next structure
7fd59977 2077 IteratorD.Next ();
2078 }
2079 break;
2080
2081 case Graphic3d_TOC_ANCESTOR :
2082 while (IteratorA.More ()) {
2083 Graphic3d_Structure::Network
2084 (IteratorA.Key (), AType, ASet);
bbf32d01
K
2085 // IteratorA.Next () is located on the next structure
2086 IteratorA.Next ();
7fd59977 2087 }
2088 break;
2089 }
2090
2091}
2092
bbf32d01 2093void Graphic3d_Structure::PrintNetwork (const Handle(Graphic3d_Structure)& AStructure, const Graphic3d_TypeOfConnection AType)
7fd59977 2094{
2095
2096 Graphic3d_MapOfStructure ASet;
2097
2098 Graphic3d_MapIteratorOfMapOfStructure IteratorASet (ASet);
2099
2100 Graphic3d_Structure::Network (AStructure, AType, ASet);
2101
2102 while (IteratorASet.More ()) {
2103 cout << "\tIdent "
2104 << (IteratorASet.Key ())->Identification () << "\n";
2105 IteratorASet.Next ();
2106 }
2107 cout << flush;
2108
2109}
2110
bbf32d01 2111void Graphic3d_Structure::Update () const
7fd59977 2112{
2113
2114 if (IsDeleted ()) return;
2115
2116 if (MyStructureManager->UpdateMode () == Aspect_TOU_ASAP)
2117 MyStructureManager->Update ();
2118
2119}
2120
bbf32d01 2121void Graphic3d_Structure::UpdateStructure (const Handle(Graphic3d_AspectLine3d)& CTXL, const Handle(Graphic3d_AspectText3d)& CTXT, const Handle(Graphic3d_AspectMarker3d)& CTXM, const Handle(Graphic3d_AspectFillArea3d)& CTXF)
7fd59977 2122{
2123
2124 Standard_Real R, G, B;
2125 Standard_Real Rs, Gs, Bs;
2126 Standard_CString AFont;
2127 Standard_Real ASpace;
2128 Standard_Real AnExpansion;
2129 Standard_Real AWidth;
2130 Standard_Real AScale;
2131 Quantity_Color AColor;
2132 Quantity_Color AnIntColor;
2133 Quantity_Color BackIntColor;
2134 Quantity_Color AnEdgeColor;
2135 Aspect_TypeOfLine ALType;
2136 Aspect_TypeOfMarker AMType;
2137 Aspect_InteriorStyle AStyle;
2138 Aspect_TypeOfStyleText AStyleT;
2139 Aspect_TypeOfDisplayText ADisplayType;
bbf32d01 2140 Quantity_Color AColorSubTitle;
7fd59977 2141 Standard_Boolean ATextZoomable;
2142 Standard_Real ATextAngle;
2143 OSD_FontAspect ATextFontAspect;
2144
2145
2146 CTXL->Values (AColor, ALType, AWidth);
2147 AColor.Values (R, G, B, Quantity_TOC_RGB);
2148
2149 MyCStructure.ContextLine.Color.r = float (R);
2150 MyCStructure.ContextLine.Color.g = float (G);
2151 MyCStructure.ContextLine.Color.b = float (B);
2152 MyCStructure.ContextLine.LineType = int (ALType);
2153 MyCStructure.ContextLine.Width = float (AWidth);
2154
2155 CTXM->Values (AColor, AMType, AScale);
2156 AColor.Values (R, G, B, Quantity_TOC_RGB);
2157
2158 MyCStructure.ContextMarker.Color.r = float (R);
2159 MyCStructure.ContextMarker.Color.g = float (G);
2160 MyCStructure.ContextMarker.Color.b = float (B);
2161 MyCStructure.ContextMarker.MarkerType = int (AMType);
2162 MyCStructure.ContextMarker.Scale = float (AScale);
2163
2164 CTXT->Values (AColor, AFont, AnExpansion, ASpace,AStyleT,ADisplayType,AColorSubTitle,ATextZoomable,ATextAngle,ATextFontAspect);
2165 AColor.Values (R, G, B, Quantity_TOC_RGB);
2166 AColorSubTitle.Values (Rs, Gs, Bs, Quantity_TOC_RGB);
2167
2168 MyCStructure.ContextText.Color.r = float (R);
2169 MyCStructure.ContextText.Color.g = float (G);
2170 MyCStructure.ContextText.Color.b = float (B);
2171 MyCStructure.ContextText.Font = (char*) (AFont);
2172 MyCStructure.ContextText.Expan = float (AnExpansion);
2173 MyCStructure.ContextText.Style = int (AStyleT);
2174 MyCStructure.ContextText.DisplayType = int (ADisplayType);
2175 MyCStructure.ContextText.Space = float (ASpace);
2176 MyCStructure.ContextText.ColorSubTitle.r = float (Rs);
2177 MyCStructure.ContextText.ColorSubTitle.g = float (Gs);
2178 MyCStructure.ContextText.ColorSubTitle.b = float (Bs);
2179 MyCStructure.ContextText.TextZoomable = ATextZoomable;
2180 MyCStructure.ContextText.TextAngle = ATextAngle;
bbf32d01 2181 MyCStructure.ContextText.TextFontAspect = (int)ATextFontAspect;
7fd59977 2182
2183
2184
2185 CTXF->Values (AStyle, AnIntColor, BackIntColor, AnEdgeColor, ALType, AWidth);
2186 AnIntColor.Values (R, G, B, Quantity_TOC_RGB);
2187
2188 MyCStructure.ContextFillArea.Style = int (AStyle);
2189 MyCStructure.ContextFillArea.IntColor.r = float (R);
2190 MyCStructure.ContextFillArea.IntColor.g = float (G);
2191 MyCStructure.ContextFillArea.IntColor.b = float (B);
2192#ifdef OCC1174
2193 if ( CTXF->Distinguish() )
2194 BackIntColor.Values( R, G, B, Quantity_TOC_RGB );
2195#endif
2196 MyCStructure.ContextFillArea.BackIntColor.r = float( R );
2197 MyCStructure.ContextFillArea.BackIntColor.g = float( G );
2198 MyCStructure.ContextFillArea.BackIntColor.b = float( B );
2199
2200 // Edges
2201 MyCStructure.ContextFillArea.Edge = CTXF->Edge () ? 1:0;
2202 AnEdgeColor.Values (R, G, B, Quantity_TOC_RGB);
2203 MyCStructure.ContextFillArea.EdgeColor.r = float (R);
2204 MyCStructure.ContextFillArea.EdgeColor.g = float (G);
2205 MyCStructure.ContextFillArea.EdgeColor.b = float (B);
2206 MyCStructure.ContextFillArea.LineType = int (ALType);
2207 MyCStructure.ContextFillArea.Width = float (AWidth);
2208 MyCStructure.ContextFillArea.Hatch = int (CTXF->HatchStyle ());
2209#ifdef G003
2210 Quantity_Ratio ratio;
bbf32d01 2211 MyCStructure.ContextFillArea.DegenerationMode =
7fd59977 2212 int (CTXF->DegenerateModel(ratio));
2213 MyCStructure.ContextFillArea.SkipRatio = float (ratio);
2214#endif // G003
2215
2216
2217 /*** Front and Back face ***/
2218 MyCStructure.ContextFillArea.Distinguish = CTXF->Distinguish () ? 1:0;
2219 MyCStructure.ContextFillArea.BackFace = CTXF->BackFace () ? 1:0;
2220 /*** Back Material ***/
2221 // Light specificity
2222 MyCStructure.ContextFillArea.Back.Shininess =
2223 float ((CTXF->BackMaterial ()).Shininess ());
2224 MyCStructure.ContextFillArea.Back.Ambient =
2225 float ((CTXF->BackMaterial ()).Ambient ());
2226 MyCStructure.ContextFillArea.Back.Diffuse =
2227 float ((CTXF->BackMaterial ()).Diffuse ());
2228 MyCStructure.ContextFillArea.Back.Specular =
2229 float ((CTXF->BackMaterial ()).Specular ());
2230 MyCStructure.ContextFillArea.Back.Transparency =
2231 float ((CTXF->BackMaterial ()).Transparency ());
2232 MyCStructure.ContextFillArea.Back.Emission =
2233 float ((CTXF->BackMaterial ()).Emissive ());
2234
2235 // Reflection mode
2236 MyCStructure.ContextFillArea.Back.IsAmbient =
2237 ( (CTXF->BackMaterial ()).ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0 );
2238 MyCStructure.ContextFillArea.Back.IsDiffuse =
2239 ( (CTXF->BackMaterial ()).ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0 );
2240 MyCStructure.ContextFillArea.Back.IsSpecular =
2241 ( (CTXF->BackMaterial ()).ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0 );
2242 MyCStructure.ContextFillArea.Back.IsEmission =
2243 ( (CTXF->BackMaterial ()).ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0 );
2244
2245 // Material type
2246 //JR/Hp
2247 const Graphic3d_MaterialAspect ama = CTXF->BackMaterial () ;
2248 Standard_Boolean amt = ama.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
2249 MyCStructure.ContextFillArea.Back.IsPhysic = ( amt ? 1 : 0 );
2250
2251 // Specular color
2252 MyCStructure.ContextFillArea.Back.ColorSpec.r =
2253 float (((CTXF->BackMaterial ()).SpecularColor ()).Red ());
2254 MyCStructure.ContextFillArea.Back.ColorSpec.g =
2255 float (((CTXF->BackMaterial ()).SpecularColor ()).Green ());
2256 MyCStructure.ContextFillArea.Back.ColorSpec.b =
2257 float (((CTXF->BackMaterial ()).SpecularColor ()).Blue ());
2258
2259 // Ambient color
2260 MyCStructure.ContextFillArea.Back.ColorAmb.r =
2261 float (((CTXF->BackMaterial ()).AmbientColor ()).Red ());
2262 MyCStructure.ContextFillArea.Back.ColorAmb.g =
2263 float (((CTXF->BackMaterial ()).AmbientColor ()).Green ());
2264 MyCStructure.ContextFillArea.Back.ColorAmb.b =
2265 float (((CTXF->BackMaterial ()).AmbientColor ()).Blue ());
2266
2267 // Diffuse color
2268 MyCStructure.ContextFillArea.Back.ColorDif.r =
2269 float (((CTXF->BackMaterial ()).DiffuseColor ()).Red ());
2270 MyCStructure.ContextFillArea.Back.ColorDif.g =
2271 float (((CTXF->BackMaterial ()).DiffuseColor ()).Green ());
2272 MyCStructure.ContextFillArea.Back.ColorDif.b =
2273 float (((CTXF->BackMaterial ()).DiffuseColor ()).Blue ());
2274
2275 // Emissive color
2276 MyCStructure.ContextFillArea.Back.ColorEms.r =
2277 float (((CTXF->BackMaterial ()).EmissiveColor ()).Red ());
2278 MyCStructure.ContextFillArea.Back.ColorEms.g =
2279 float (((CTXF->BackMaterial ()).EmissiveColor ()).Green ());
2280 MyCStructure.ContextFillArea.Back.ColorEms.b =
2281 float (((CTXF->BackMaterial ()).EmissiveColor ()).Blue ());
2282
bbf32d01 2283 MyCStructure.ContextFillArea.Back.EnvReflexion =
7fd59977 2284 float ((CTXF->BackMaterial ()).EnvReflexion());
2285
2286 /*** Front Material ***/
2287 // Light specificity
2288 MyCStructure.ContextFillArea.Front.Shininess =
2289 float ((CTXF->FrontMaterial ()).Shininess ());
2290 MyCStructure.ContextFillArea.Front.Ambient =
2291 float ((CTXF->FrontMaterial ()).Ambient ());
2292 MyCStructure.ContextFillArea.Front.Diffuse =
2293 float ((CTXF->FrontMaterial ()).Diffuse ());
2294 MyCStructure.ContextFillArea.Front.Specular =
2295 float ((CTXF->FrontMaterial ()).Specular ());
2296 MyCStructure.ContextFillArea.Front.Transparency =
2297 float ((CTXF->FrontMaterial ()).Transparency ());
2298 MyCStructure.ContextFillArea.Front.Emission =
2299 float ((CTXF->FrontMaterial ()).Emissive ());
2300
2301 // Reflection mode
2302 MyCStructure.ContextFillArea.Front.IsAmbient =
2303 ( (CTXF->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0 );
2304 MyCStructure.ContextFillArea.Front.IsDiffuse =
2305 ( (CTXF->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0 );
2306 MyCStructure.ContextFillArea.Front.IsSpecular =
2307 ( (CTXF->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0 );
2308 MyCStructure.ContextFillArea.Front.IsEmission =
2309 ( (CTXF->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0 );
2310
2311 // Material type
2312 //JR/Hp
2313 const Graphic3d_MaterialAspect amas = CTXF->FrontMaterial () ;
2314 Standard_Boolean amty = amas.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
2315 MyCStructure.ContextFillArea.Front.IsPhysic = ( amty ? 1 : 0 );
2316
2317 // Specular color
2318 MyCStructure.ContextFillArea.Front.ColorSpec.r =
2319 float (((CTXF->FrontMaterial ()).SpecularColor ()).Red ());
2320 MyCStructure.ContextFillArea.Front.ColorSpec.g =
2321 float (((CTXF->FrontMaterial ()).SpecularColor ()).Green ());
2322 MyCStructure.ContextFillArea.Front.ColorSpec.b =
2323 float (((CTXF->FrontMaterial ()).SpecularColor ()).Blue ());
2324
2325 // Ambient color
2326 MyCStructure.ContextFillArea.Front.ColorAmb.r =
2327 float (((CTXF->FrontMaterial ()).AmbientColor ()).Red ());
2328 MyCStructure.ContextFillArea.Front.ColorAmb.g =
2329 float (((CTXF->FrontMaterial ()).AmbientColor ()).Green ());
2330 MyCStructure.ContextFillArea.Front.ColorAmb.b =
2331 float (((CTXF->FrontMaterial ()).AmbientColor ()).Blue ());
2332
2333 // Diffuse color
2334 MyCStructure.ContextFillArea.Front.ColorDif.r =
2335 float (((CTXF->FrontMaterial ()).DiffuseColor ()).Red ());
2336 MyCStructure.ContextFillArea.Front.ColorDif.g =
2337 float (((CTXF->FrontMaterial ()).DiffuseColor ()).Green ());
2338 MyCStructure.ContextFillArea.Front.ColorDif.b =
2339 float (((CTXF->FrontMaterial ()).DiffuseColor ()).Blue ());
2340
2341 // Emissive color
2342 MyCStructure.ContextFillArea.Front.ColorEms.r =
2343 float (((CTXF->FrontMaterial ()).EmissiveColor ()).Red ());
2344 MyCStructure.ContextFillArea.Front.ColorEms.g =
2345 float (((CTXF->FrontMaterial ()).EmissiveColor ()).Green ());
2346 MyCStructure.ContextFillArea.Front.ColorEms.b =
2347 float (((CTXF->FrontMaterial ()).EmissiveColor ()).Blue ());
2348
bbf32d01 2349 MyCStructure.ContextFillArea.Front.EnvReflexion =
7fd59977 2350 float ((CTXF->FrontMaterial ()).EnvReflexion());
2351
2352 Handle(Graphic3d_TextureMap) TempTextureMap = CTXF->TextureMap();
2353 if (! TempTextureMap.IsNull() )
2354 MyCStructure.ContextFillArea.Texture.TexId = TempTextureMap->TextureId();
2355 else
2356 MyCStructure.ContextFillArea.Texture.TexId = -1;
2357
2358 MyCStructure.ContextFillArea.Texture.doTextureMap = CTXF->TextureMapState() ? 1:0;
2359
bbf32d01 2360 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
7fd59977 2361 Standard_Integer aPolyMode;
2362 Standard_Real aPolyFactor, aPolyUnits;
2363 CTXF->PolygonOffsets(aPolyMode, aPolyFactor, aPolyUnits);
2364 MyCStructure.ContextFillArea.PolygonOffsetMode = aPolyMode;
2365 MyCStructure.ContextFillArea.PolygonOffsetFactor = aPolyFactor;
2366 MyCStructure.ContextFillArea.PolygonOffsetUnits = aPolyUnits;
bbf32d01 2367 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
7fd59977 2368}
2369
2370void Graphic3d_Structure::GraphicHighlight (const Aspect_TypeOfHighlightMethod AMethod) {
2371
2372 Standard_Real XMin, YMin, ZMin, XMax, YMax, ZMax;
2373 Standard_Real R, G, B;
2374
2375 MyCStructure.highlight = 1;
2376 MyHighlightMethod = AMethod;
2377
bbf32d01 2378 switch (AMethod)
7fd59977 2379 {
2380 case Aspect_TOHM_COLOR :
2381 MyHighlightColor.Values (R, G, B, Quantity_TOC_RGB);
2382 MyGraphicDriver->HighlightColor
2383 (MyCStructure, float (R), float (G),
2384 float (B) , Standard_True);
2385 MyGraphicDriver->NameSetStructure (MyCStructure);
2386 break;
2387 case Aspect_TOHM_BLINK :
2388 MyGraphicDriver->Blink (MyCStructure, Standard_True);
2389 MyGraphicDriver->NameSetStructure (MyCStructure);
2390 break;
2391 case Aspect_TOHM_BOUNDBOX :
2392 if (IsEmpty () || IsInfinite ()) {
81bba717 2393 // Empty or infinite structure
7fd59977 2394 XMin = YMin = ZMin = 0.;
2395 XMax = YMax = ZMax = 0.;
2396 }
2397 else {
2398 MinMaxCoord
2399 (XMin, YMin, ZMin, XMax, YMax, ZMax);
2400 }
2401 MyCStructure.BoundBox.Pmin.x = float (XMin);
2402 MyCStructure.BoundBox.Pmin.y = float (YMin);
2403 MyCStructure.BoundBox.Pmin.z = float (ZMin);
2404 MyCStructure.BoundBox.Pmax.x = float (XMax);
2405 MyCStructure.BoundBox.Pmax.y = float (YMax);
2406 MyCStructure.BoundBox.Pmax.z = float (ZMax);
2407 MyHighlightColor.Values (R, G, B, Quantity_TOC_RGB);
2408 MyCStructure.BoundBox.Color.r = float (R);
2409 MyCStructure.BoundBox.Color.g = float (G);
2410 MyCStructure.BoundBox.Color.b = float (B);
2411 MyGraphicDriver->BoundaryBox (MyCStructure, Standard_True);
2412 break;
2413 }
2414
2415}
2416
2417void Graphic3d_Structure::GraphicTransform (const TColStd_Array2OfReal& AMatrix) {
2418
2419 Standard_Integer i, j;
2420
2421 for (i=0; i<=3; i++)
2422 for (j=0; j<=3; j++)
2423 MyCStructure.Transformation[i][j] = float (AMatrix (i, j));
2424
2425 MyGraphicDriver->TransformStructure (MyCStructure);
2426
2427}
2428
2429void Graphic3d_Structure::GraphicUnHighlight () {
2430
2431 MyCStructure.highlight = 0;
2432
bbf32d01 2433 switch (MyHighlightMethod)
7fd59977 2434 {
2435 case Aspect_TOHM_COLOR :
2436 MyGraphicDriver->HighlightColor
2437 (MyCStructure, 0.0, 0.0, 0.0 , Standard_False);
2438 MyGraphicDriver->NameSetStructure (MyCStructure);
2439 break;
2440 case Aspect_TOHM_BLINK :
2441 MyGraphicDriver->Blink (MyCStructure, Standard_False);
2442 MyGraphicDriver->NameSetStructure (MyCStructure);
2443 break;
2444 case Aspect_TOHM_BOUNDBOX :
2445 MyGraphicDriver->BoundaryBox
2446 (MyCStructure, Standard_False);
2447 MyGraphicDriver->NameSetStructure (MyCStructure);
2448 break;
2449 }
2450
2451}
2452
2453Graphic3d_TypeOfStructure Graphic3d_Structure::ComputeVisual () const {
2454
2455 return (MyComputeVisual);
2456
2457}
2458
2459void Graphic3d_Structure::SetComputeVisual (const Graphic3d_TypeOfStructure AVisual) {
2460
81bba717 2461 // The ComputeVisual is saved only if the structure is
2462 // declared TOS_ALL, TOS_WIREFRAME or TOS_SHADING.
2463 // This declaration permits to calculate
2464 // proper representation of the structure calculated by Compute
2465 // instead of passage to TOS_COMPUTED.
7fd59977 2466 if (AVisual != Graphic3d_TOS_COMPUTED)
2467 MyComputeVisual = AVisual;
2468
2469}
2470
2471void Graphic3d_Structure::Plot (const Handle(Graphic3d_Plotter)& ) {
2472
2473}
2474
2475void Graphic3d_Structure::SetManager (const Handle(Graphic3d_StructureManager)& AManager, const Standard_Boolean WithPropagation) {
2476
81bba717 2477 // All connected structures should follow ?
7fd59977 2478#ifdef IMPLEMENTED
2479 if (WithPropagation) {
2480 Standard_Integer i, Length;
2481 Length = MyDescendants.Length ();
2482 for (i=1; i<=Length; i++)
2483 ((Graphic3d_Structure *)
2484 (MyDescendants.Value (i)))->SetStructureManager (AManager);
2485
2486 Length = MyAncestors.Length ();
2487 for (i=1; i<=Length; i++)
2488 ((Graphic3d_Structure *)
2489 (MyAncestors.Value (i)))->SetStructureManager (AManager);
2490 }
2491#endif
2492
81bba717 2493 // change of identification ?
7fd59977 2494 // MyStructureManager->Remove (Standard_Integer (MyCStructure.Id));
2495 // AManager->NewIdentification ();
2496 // MyCStructure.Id = int (AManager->NewIdentification ());
2497
2498 Aspect_TypeOfUpdate UpdateMode = MyStructureManager->UpdateMode ();
2499 Aspect_TypeOfUpdate NewUpdateMode = AManager->UpdateMode ();
2500 MyStructureManager->SetUpdateMode (Aspect_TOU_WAIT);
2501 AManager->SetUpdateMode (Aspect_TOU_WAIT);
2502
2503 if (MyCStructure.stick) {
2504 MyStructureManager->Erase (this);
2505 AManager->Display (this);
2506 }
2507
2508 if (MyCStructure.highlight) {
2509 }
2510
2511 if (MyCStructure.visible) {
2512 MyStructureManager->Invisible (this);
2513 AManager->Visible (this);
2514 }
2515
2516 if (MyCStructure.pick) {
2517 MyStructureManager->Undetectable (this);
2518 AManager->Detectable (this);
2519 }
2520
2521 MyStructureManager->SetUpdateMode (UpdateMode);
2522 AManager->SetUpdateMode (NewUpdateMode);
2523
81bba717 2524 // New manager
7fd59977 2525 MyPtrStructureManager = (void *) AManager.operator->();
2526
2527}
2528
2529void Graphic3d_Structure::SetHLRValidation (const Standard_Boolean AFlag) {
2530
2531 MyCStructure.HLRValidation = AFlag ? 1:0;
2532
2533}
2534
2535Standard_Boolean Graphic3d_Structure::HLRValidation () const {
2536
81bba717 2537 // Hidden parts stored in <me> are valid if :
2538 // 1/ the owner is defined.
2539 // 2/ they are not invalid.
7fd59977 2540
2541 Standard_Boolean Result = MyOwner != NULL && MyCStructure.HLRValidation != 0;
2542
2543 return Result;
2544
2545}
2546
2547Standard_Address Graphic3d_Structure::CStructure () const {
2548
2549 return Standard_Address (&MyCStructure);
2550
2551}