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