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