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