0025090: Visualization - drop Graphic3d_Group::MyIsEmpty flag
[occt.git] / src / Graphic3d / Graphic3d_Group.cxx
CommitLineData
b311480e 1// Created by: NW,JPB,CAL
2// Copyright (c) 1991-1999 Matra Datavision
973c2be1 3// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
b64d84be 16#include <Graphic3d_Group.ixx>
7fd59977 17
b64d84be 18#include <gp_Pnt.hxx>
19#include <Graphic3d_ArrayOfPoints.hxx>
20#include <Graphic3d_StructureManager.hxx>
21#include <Graphic3d_ShaderProgram.hxx>
22#include <Graphic3d_TransModeFlags.hxx>
23#include <Graphic3d_TextureMap.hxx>
24#include <Message.hxx>
25#include <Message_Messenger.hxx>
26#include <NCollection_String.hxx>
27#include <TCollection_AsciiString.hxx>
7fd59977 28
b64d84be 29#include <Graphic3d_CStructure.hxx>
30#include <Graphic3d_Structure.pxx>
7fd59977 31
b64d84be 32#define MyContainsFacet myCBitFields.bool2
7fd59977 33
b64d84be 34// =======================================================================
35// function : Graphic3d_Group
36// purpose :
37// =======================================================================
38Graphic3d_Group::Graphic3d_Group (const Handle(Graphic3d_Structure)& theStruct)
31c0e219 39: myIsClosed (Standard_False)
b64d84be 40{
b64d84be 41 // A small commentary on the usage of This!
42 //
43 // Graphic3d_Group is created in a structure. Graphic3d_Structure is a
44 // manager of Graphic3d_Group. In the constructor of Graphic3d_Group
45 // a method Add of Graphic3d_Structure is called. It allows adding
46 // the instance of Graphic3d_Group in its manager. So there are 2 references
47 // to <me> and everything works well.
48 //
49 // This () is the instance of the class, the current group
50 //Handle(Graphic3d_Group) me = Handle(Graphic3d_Group)::DownCast (This());
7fd59977 51
b64d84be 52 myStructure = theStruct.operator->();
7fd59977 53
9cc773b5 54 MyContainsFacet = Standard_False,
7fd59977 55
b64d84be 56 ContextLine.IsDef = 0;
57 ContextText.IsDef = 0;
58 ContextMarker.IsDef = 0;
59 ContextFillArea.IsDef = 0;
7fd59977 60
b64d84be 61 ContextLine.IsSet = 0;
62 ContextText.IsSet = 0;
63 ContextMarker.IsSet = 0;
64 ContextFillArea.IsSet = 0;
65}
66
67// =======================================================================
68// function : Clear
69// purpose :
70// =======================================================================
71void Graphic3d_Group::Clear (Standard_Boolean theUpdateStructureMgr)
72{
73 if (IsDeleted())
74 {
75 return;
76 }
77
78 ContextLine.IsSet = 0,
79 ContextText.IsSet = 0,
80 ContextMarker.IsSet = 0,
81 ContextFillArea.IsSet = 0;
7fd59977 82
b64d84be 83 ContextLine.IsDef = 0,
84 ContextText.IsDef = 0,
85 ContextMarker.IsDef = 0,
86 ContextFillArea.IsDef = 0;
7fd59977 87
b7cd4ba7 88 myBounds.Clear();
7fd59977 89
b64d84be 90 if (MyContainsFacet)
91 {
92 myStructure->GroupsWithFacet (-1);
93 MyContainsFacet = Standard_False;
94 }
7fd59977 95
b64d84be 96 // clear method could be used on Graphic3d_Structure destruction,
97 // and its structure manager could be already destroyed, in that
98 // case we don't need to update it;
99 if (theUpdateStructureMgr)
100 {
101 Update();
102 }
103}
7fd59977 104
b64d84be 105// =======================================================================
106// function : Destroy
107// purpose :
108// =======================================================================
109void Graphic3d_Group::Destroy()
110{
111 // tell graphics driver to clear internal resources of the group
112 Clear (Standard_False);
113}
7fd59977 114
b64d84be 115// =======================================================================
116// function : Remove
117// purpose :
118// =======================================================================
119void Graphic3d_Group::Remove()
7fd59977 120{
b64d84be 121 if (IsDeleted())
122 {
123 return;
124 }
7fd59977 125
b64d84be 126 if (MyContainsFacet)
127 {
128 myStructure->GroupsWithFacet (-1);
129 MyContainsFacet = Standard_False;
130 }
131 myStructure->Remove (this);
7fd59977 132
b64d84be 133 Update();
7fd59977 134
b7cd4ba7 135 myBounds.Clear();
b64d84be 136}
137
138// =======================================================================
139// function : IsDeleted
140// purpose :
141// =======================================================================
142Standard_Boolean Graphic3d_Group::IsDeleted() const
143{
144 return myStructure == NULL
145 || myStructure->IsDeleted();
146}
147
148// =======================================================================
149// function : ContainsFacet
150// purpose :
151// =======================================================================
152Standard_Boolean Graphic3d_Group::ContainsFacet() const
153{
154 return MyContainsFacet;
155}
156
157// =======================================================================
158// function : IsEmpty
159// purpose :
160// =======================================================================
161Standard_Boolean Graphic3d_Group::IsEmpty() const
162{
163 if (IsDeleted())
164 {
165 return Standard_True;
166 }
167
9cc773b5 168 return !myStructure->IsInfinite()
169 && !myBounds.IsValid();
b64d84be 170}
171
172// =======================================================================
173// function : SetMinMaxValues
174// purpose :
175// =======================================================================
176void Graphic3d_Group::SetMinMaxValues (const Standard_Real theXMin, const Standard_Real theYMin, const Standard_Real theZMin,
177 const Standard_Real theXMax, const Standard_Real theYMax, const Standard_Real theZMax)
178{
ecc1d911 179 myBounds = Graphic3d_BndBox4f (Graphic3d_Vec4 (static_cast<Standard_ShortReal> (theXMin),
180 static_cast<Standard_ShortReal> (theYMin),
181 static_cast<Standard_ShortReal> (theZMin),
182 1.0f),
183 Graphic3d_Vec4 (static_cast<Standard_ShortReal> (theXMax),
184 static_cast<Standard_ShortReal> (theYMax),
185 static_cast<Standard_ShortReal> (theZMax),
186 1.0f));
b64d84be 187}
188
189// =======================================================================
190// function : MinMaxValues
191// purpose :
192// =======================================================================
193void Graphic3d_Group::MinMaxValues (Standard_Real& theXMin, Standard_Real& theYMin, Standard_Real& theZMin,
194 Standard_Real& theXMax, Standard_Real& theYMax, Standard_Real& theZMax) const
195{
196 MinMaxCoord (theXMin, theYMin, theZMin,
197 theXMax, theYMax, theZMax);
198}
199
200// =======================================================================
201// function : Structure
202// purpose :
203// =======================================================================
204Handle(Graphic3d_Structure) Graphic3d_Group::Structure() const
205{
206 return myStructure;
207}
208
209// =======================================================================
210// function : MinMaxCoord
211// purpose :
212// =======================================================================
213void Graphic3d_Group::MinMaxCoord (Standard_Real& theXMin, Standard_Real& theYMin, Standard_Real& theZMin,
214 Standard_Real& theXMax, Standard_Real& theYMax, Standard_Real& theZMax) const
215{
216 if (IsEmpty())
217 {
218 // Empty Group
219 theXMin = theYMin = theZMin = ShortRealFirst();
220 theXMax = theYMax = theZMax = ShortRealLast();
221 }
b7cd4ba7 222 else if (myBounds.IsValid())
223 {
224 const Graphic3d_Vec4& aMinPt = myBounds.CornerMin();
225 const Graphic3d_Vec4& aMaxPt = myBounds.CornerMax();
226 theXMin = Standard_Real (aMinPt.x());
227 theYMin = Standard_Real (aMinPt.y());
228 theZMin = Standard_Real (aMinPt.z());
229 theXMax = Standard_Real (aMaxPt.x());
230 theYMax = Standard_Real (aMaxPt.y());
231 theZMax = Standard_Real (aMaxPt.z());
232 }
b64d84be 233 else
234 {
b7cd4ba7 235 // for consistency with old API
236 theXMin = theYMin = theZMin = ShortRealLast();
237 theXMax = theYMax = theZMax = ShortRealFirst();
b64d84be 238 }
239}
240
241// =======================================================================
242// function : Update
243// purpose :
244// =======================================================================
245void Graphic3d_Group::Update() const
246{
247 if (IsDeleted())
248 {
249 return;
250 }
251
252 if (myStructure->StructureManager()->UpdateMode() == Aspect_TOU_ASAP)
253 {
254 myStructure->StructureManager()->Update();
255 }
256}
257
258// =======================================================================
259// function : SetGroupPrimitivesAspect
260// purpose :
261// =======================================================================
262void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine)
263{
264 if (IsDeleted())
265 {
266 return;
267 }
268
269 Standard_Real aWidth;
270 Quantity_Color aColor;
271 Aspect_TypeOfLine aLType;
272 theAspLine->Values (aColor, aLType, aWidth);
273
274 ContextLine.IsDef = 1;
275 ContextLine.Color.r = float (aColor.Red());
276 ContextLine.Color.g = float (aColor.Green());
277 ContextLine.Color.b = float (aColor.Blue());
278 ContextLine.LineType = aLType;
279 ContextLine.Width = float (aWidth);
280 ContextLine.ShaderProgram = theAspLine->ShaderProgram();
7fd59977 281
b64d84be 282 UpdateAspectLine (Standard_True);
7fd59977 283
b64d84be 284 ContextLine.IsSet = 1;
7fd59977 285
b64d84be 286 Update();
287}
288
289// =======================================================================
290// function : SetGroupPrimitivesAspect
291// purpose :
292// =======================================================================
293void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspFill)
294{
295 if (IsDeleted())
296 {
297 return;
298 }
299
300 Standard_Real anRGB[3];
301 Standard_Real aWidth;
302 Quantity_Color anIntColor;
303 Quantity_Color aBackIntColor;
304 Quantity_Color anEdgeColor;
305 Aspect_TypeOfLine aLType;
306 Aspect_InteriorStyle aStyle;
307 theAspFill->Values (aStyle, anIntColor, aBackIntColor, anEdgeColor, aLType, aWidth);
308
309 anIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB);
310 ContextFillArea.Style = aStyle;
311 ContextFillArea.IntColor.r = float (anRGB[0]);
312 ContextFillArea.IntColor.g = float (anRGB[1]);
313 ContextFillArea.IntColor.b = float (anRGB[2]);
314
315 if (theAspFill->Distinguish())
316 {
317 aBackIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB);
318 }
319 ContextFillArea.BackIntColor.r = float (anRGB[0]);
320 ContextFillArea.BackIntColor.g = float (anRGB[1]);
321 ContextFillArea.BackIntColor.b = float (anRGB[2]);
322
323 // Edges
324 ContextFillArea.Edge = theAspFill->Edge() ? 1 : 0;
325 ContextFillArea.EdgeColor.r = float (anEdgeColor.Red());
326 ContextFillArea.EdgeColor.g = float (anEdgeColor.Green());
327 ContextFillArea.EdgeColor.b = float (anEdgeColor.Blue());
328 ContextFillArea.LineType = aLType;
329 ContextFillArea.Width = float (aWidth);
330 ContextFillArea.Hatch = theAspFill->HatchStyle();
331
332 // Front and Back face
333 ContextFillArea.Distinguish = theAspFill->Distinguish() ? 1 : 0;
334 ContextFillArea.BackFace = theAspFill->BackFace() ? 1 : 0;
335
336 // Back Material
337 const Graphic3d_MaterialAspect& aBack = theAspFill->BackMaterial();
338
339 // Light specificity
340 ContextFillArea.Back.Shininess = float (aBack.Shininess());
341 ContextFillArea.Back.Ambient = float (aBack.Ambient());
342 ContextFillArea.Back.Diffuse = float (aBack.Diffuse());
343 ContextFillArea.Back.Specular = float (aBack.Specular());
344 ContextFillArea.Back.Transparency = float (aBack.Transparency());
345 ContextFillArea.Back.Emission = float (aBack.Emissive());
dc9ef964 346 ContextFillArea.Back.RefractionIndex = float (aBack.RefractionIndex());
b64d84be 347
348 // Reflection mode
349 ContextFillArea.Back.IsAmbient = aBack.ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0;
350 ContextFillArea.Back.IsDiffuse = aBack.ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0;
351 ContextFillArea.Back.IsSpecular = aBack.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0;
352 ContextFillArea.Back.IsEmission = aBack.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0;
353
354 // Material type
355 ContextFillArea.Back.IsPhysic = aBack.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0;
356
357 // Specular color
358 ContextFillArea.Back.ColorSpec.r = float (aBack.SpecularColor().Red());
359 ContextFillArea.Back.ColorSpec.g = float (aBack.SpecularColor().Green());
360 ContextFillArea.Back.ColorSpec.b = float (aBack.SpecularColor().Blue());
361
362 // Ambient color
363 ContextFillArea.Back.ColorAmb.r = float (aBack.AmbientColor().Red());
364 ContextFillArea.Back.ColorAmb.g = float (aBack.AmbientColor().Green());
365 ContextFillArea.Back.ColorAmb.b = float (aBack.AmbientColor().Blue());
366
367 // Diffuse color
368 ContextFillArea.Back.ColorDif.r = float (aBack.DiffuseColor().Red());
369 ContextFillArea.Back.ColorDif.g = float (aBack.DiffuseColor().Green());
370 ContextFillArea.Back.ColorDif.b = float (aBack.DiffuseColor().Blue());
371
372 // Emissive color
373 ContextFillArea.Back.ColorEms.r = float (aBack.EmissiveColor().Red());
374 ContextFillArea.Back.ColorEms.g = float (aBack.EmissiveColor().Green());
375 ContextFillArea.Back.ColorEms.b = float (aBack.EmissiveColor().Blue());
376
377 ContextFillArea.Back.EnvReflexion = float (aBack.EnvReflexion());
378
379 // Front Material
380 const Graphic3d_MaterialAspect& aFront = theAspFill->FrontMaterial();
381 // Light specificity
382 ContextFillArea.Front.Shininess = float (aFront.Shininess());
383 ContextFillArea.Front.Ambient = float (aFront.Ambient());
384 ContextFillArea.Front.Diffuse = float (aFront.Diffuse());
385 ContextFillArea.Front.Specular = float (aFront.Specular());
386 ContextFillArea.Front.Transparency = float (aFront.Transparency());
387 ContextFillArea.Front.Emission = float (aFront.Emissive());
dc9ef964 388 ContextFillArea.Front.RefractionIndex = float (aFront.RefractionIndex());
b64d84be 389
390 // Reflection mode
391 ContextFillArea.Front.IsAmbient = aFront.ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0;
392 ContextFillArea.Front.IsDiffuse = aFront.ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0;
393 ContextFillArea.Front.IsSpecular = aFront.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0;
394 ContextFillArea.Front.IsEmission = aFront.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0;
395
396 // Material type
397 ContextFillArea.Front.IsPhysic = aFront.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0;
398
399 // Specular color
400 ContextFillArea.Front.ColorSpec.r = float (aFront.SpecularColor().Red());
401 ContextFillArea.Front.ColorSpec.g = float (aFront.SpecularColor().Green());
402 ContextFillArea.Front.ColorSpec.b = float (aFront.SpecularColor().Blue());
403
404 // Ambient color
405 ContextFillArea.Front.ColorAmb.r = float (aFront.AmbientColor().Red());
406 ContextFillArea.Front.ColorAmb.g = float (aFront.AmbientColor().Green());
407 ContextFillArea.Front.ColorAmb.b = float (aFront.AmbientColor().Blue());
408
409 // Diffuse color
410 ContextFillArea.Front.ColorDif.r = float (aFront.DiffuseColor().Red());
411 ContextFillArea.Front.ColorDif.g = float (aFront.DiffuseColor().Green());
412 ContextFillArea.Front.ColorDif.b = float (aFront.DiffuseColor().Blue());
413
414 // Emissive color
415 ContextFillArea.Front.ColorEms.r = float (aFront.EmissiveColor().Red());
416 ContextFillArea.Front.ColorEms.g = float (aFront.EmissiveColor().Green());
417 ContextFillArea.Front.ColorEms.b = float (aFront.EmissiveColor().Blue());
418
419 ContextFillArea.Front.EnvReflexion = float (aFront.EnvReflexion());
420
421 ContextFillArea.IsDef = 1; // Definition material ok
422
423 // Texture map
424 ContextFillArea.Texture.TextureMap = theAspFill->TextureMap();
425 ContextFillArea.Texture.doTextureMap = theAspFill->TextureMapState() ? 1 : 0;
426
427 Standard_Integer aPolyMode;
428 Standard_ShortReal aPolyFactor, aPolyUnits;
429 theAspFill->PolygonOffsets (aPolyMode, aPolyFactor, aPolyUnits);
430 ContextFillArea.PolygonOffsetMode = aPolyMode;
431 ContextFillArea.PolygonOffsetFactor = aPolyFactor;
432 ContextFillArea.PolygonOffsetUnits = aPolyUnits;
433
434 ContextFillArea.ShaderProgram = theAspFill->ShaderProgram();
435
436 UpdateAspectFace (Standard_True);
437
438 ContextFillArea.IsSet = 1;
439
440 Update();
441}
442
443// =======================================================================
444// function : SetGroupPrimitivesAspect
445// purpose :
446// =======================================================================
447void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker)
448{
449 if (IsDeleted())
450 {
451 return;
452 }
453
454 Standard_Real aScale;
455 Quantity_Color aColor;
456 Aspect_TypeOfMarker aMarkerType;
457 theAspMarker->Values (aColor, aMarkerType, aScale);
458
459 ContextMarker.IsDef = 1;
460 ContextMarker.Color.r = Standard_ShortReal (aColor.Red());
461 ContextMarker.Color.g = Standard_ShortReal (aColor.Green());
462 ContextMarker.Color.b = Standard_ShortReal (aColor.Blue());
463 ContextMarker.MarkerType = aMarkerType;
464 ContextMarker.Scale = Standard_ShortReal (aScale);
465 ContextMarker.MarkerImage = theAspMarker->GetMarkerImage();
466 ContextMarker.ShaderProgram = theAspMarker->ShaderProgram();
467
468 UpdateAspectMarker (Standard_True);
469
470 ContextMarker.IsSet = 1;
471
472 Update();
473}
474
475// =======================================================================
476// function : SetGroupPrimitivesAspect
477// purpose :
478// =======================================================================
479void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText)
480{
481 if (IsDeleted())
482 {
483 return;
484 }
485
486 Standard_Real anExpansion, aSpace, aTextAngle;
487 Quantity_Color aColor, aColorSubTitle;
488 Standard_CString aFont;
489 Aspect_TypeOfStyleText aStyle;
490 Aspect_TypeOfDisplayText aDisplayType;
491 Standard_Boolean isTextZoomable;
492 Font_FontAspect aTextFontAspect;
493 theAspText->Values (aColor, aFont, anExpansion, aSpace, aStyle, aDisplayType,
494 aColorSubTitle, isTextZoomable, aTextAngle, aTextFontAspect);
495
496 ContextText.IsDef = 1;
497 ContextText.Color.r = float (aColor.Red());
498 ContextText.Color.g = float (aColor.Green());
499 ContextText.Color.b = float (aColor.Blue());
500 ContextText.Font = (char* )aFont;
501 ContextText.Expan = float (anExpansion);
502 ContextText.Space = float (aSpace);
503 ContextText.Style = aStyle;
504 ContextText.DisplayType = aDisplayType;
505 ContextText.ColorSubTitle.r = float (aColorSubTitle.Red());
506 ContextText.ColorSubTitle.g = float (aColorSubTitle.Green());
507 ContextText.ColorSubTitle.b = float (aColorSubTitle.Blue());
508 ContextText.TextZoomable = isTextZoomable;
509 ContextText.TextAngle = float (aTextAngle);
510 ContextText.TextFontAspect = aTextFontAspect;
511 ContextText.ShaderProgram = theAspText->ShaderProgram();
512
513 UpdateAspectText (Standard_True);
514
515 ContextText.IsSet = 1;
516
517 Update();
518}
519
520// =======================================================================
521// function : SetPrimitivesAspect
522// purpose :
523// =======================================================================
524void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine)
525{
526 if (IsDeleted())
527 {
528 return;
529 }
7fd59977 530
b64d84be 531 Standard_Real aWidth;
532 Quantity_Color aColor;
533 Aspect_TypeOfLine aLType;
534 theAspLine->Values (aColor, aLType, aWidth);
7fd59977 535
b64d84be 536 ContextLine.IsDef = 1;
537 ContextLine.Color.r = float (aColor.Red());
538 ContextLine.Color.g = float (aColor.Green());
539 ContextLine.Color.b = float (aColor.Blue());
540 ContextLine.LineType = aLType;
541 ContextLine.Width = float (aWidth);
542 ContextLine.ShaderProgram = theAspLine->ShaderProgram();
7fd59977 543
b64d84be 544 UpdateAspectLine (Standard_False);
7fd59977 545
b64d84be 546 ContextLine.IsSet = 1;
7fd59977 547
b64d84be 548 Update();
549}
550
551// =======================================================================
552// function : SetPrimitivesAspect
553// purpose :
554// =======================================================================
555void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspFill)
556{
557 if (IsDeleted())
558 {
559 return;
560 }
561
562 Standard_Real anRGB[3];
563 Standard_Real aWidth;
564 Quantity_Color anIntColor;
565 Quantity_Color aBackIntColor;
566 Quantity_Color anEdgeColor;
567 Aspect_TypeOfLine aLType;
568 Aspect_InteriorStyle aStyle;
569 theAspFill->Values (aStyle, anIntColor, aBackIntColor, anEdgeColor, aLType, aWidth);
570
571 anIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB);
572 ContextFillArea.Style = aStyle;
573 ContextFillArea.IntColor.r = float (anRGB[0]);
574 ContextFillArea.IntColor.g = float (anRGB[1]);
575 ContextFillArea.IntColor.b = float (anRGB[2]);
576
577 if (theAspFill->Distinguish())
578 {
579 aBackIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB);
580 }
581 ContextFillArea.BackIntColor.r = float(anRGB[0]);
582 ContextFillArea.BackIntColor.g = float(anRGB[1]);
583 ContextFillArea.BackIntColor.b = float(anRGB[2]);
584
585 // Edges
586 ContextFillArea.Edge = theAspFill->Edge() ? 1 : 0;
587 ContextFillArea.EdgeColor.r = float (anEdgeColor.Red());
588 ContextFillArea.EdgeColor.g = float (anEdgeColor.Green());
589 ContextFillArea.EdgeColor.b = float (anEdgeColor.Blue());
590 ContextFillArea.LineType = aLType;
591 ContextFillArea.Width = float (aWidth);
592 ContextFillArea.Hatch = theAspFill->HatchStyle();
593
594 // Front and Back face
595 ContextFillArea.Distinguish = theAspFill->Distinguish() ? 1 : 0;
596 ContextFillArea.BackFace = theAspFill->BackFace() ? 1 : 0;
597
598 // Back Material
599 const Graphic3d_MaterialAspect& aBack = theAspFill->BackMaterial();
600 // Material state
601 ContextFillArea.Back.Shininess = float (aBack.Shininess());
602 ContextFillArea.Back.Ambient = float (aBack.Ambient());
603 ContextFillArea.Back.Diffuse = float (aBack.Diffuse());
604 ContextFillArea.Back.Specular = float (aBack.Specular());
605 ContextFillArea.Back.Transparency = float (aBack.Transparency());
606 ContextFillArea.Back.Emission = float (aBack.Emissive());
607
608 // Reflection mode
609 ContextFillArea.Back.IsAmbient = aBack.ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0;
610 ContextFillArea.Back.IsDiffuse = aBack.ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0;
611 ContextFillArea.Back.IsSpecular = aBack.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0;
612 ContextFillArea.Back.IsEmission = aBack.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0;
613
614 // Material type
615 ContextFillArea.Back.IsPhysic = aBack.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0;
616
617 // Specular color
618 ContextFillArea.Back.ColorSpec.r = float (aBack.SpecularColor().Red());
619 ContextFillArea.Back.ColorSpec.g = float (aBack.SpecularColor().Green());
620 ContextFillArea.Back.ColorSpec.b = float (aBack.SpecularColor().Blue());
621
622 // Ambient color
623 ContextFillArea.Back.ColorAmb.r = float (aBack.AmbientColor().Red());
624 ContextFillArea.Back.ColorAmb.g = float (aBack.AmbientColor().Green());
625 ContextFillArea.Back.ColorAmb.b = float (aBack.AmbientColor().Blue());
626
627 // Diffuse color
628 ContextFillArea.Back.ColorDif.r = float (aBack.DiffuseColor().Red());
629 ContextFillArea.Back.ColorDif.g = float (aBack.DiffuseColor().Green());
630 ContextFillArea.Back.ColorDif.b = float (aBack.DiffuseColor().Blue());
631
632 // Emissive color
633 ContextFillArea.Back.ColorEms.r = float (aBack.EmissiveColor().Red());
634 ContextFillArea.Back.ColorEms.g = float (aBack.EmissiveColor().Green());
635 ContextFillArea.Back.ColorEms.b = float (aBack.EmissiveColor().Blue());
636
637 ContextFillArea.Back.EnvReflexion = float (aBack.EnvReflexion());
638
639 // Front Material
640 const Graphic3d_MaterialAspect& aFront = theAspFill->FrontMaterial();
641 // Light specificity
642 ContextFillArea.Front.Shininess = float (aFront.Shininess());
643 ContextFillArea.Front.Ambient = float (aFront.Ambient());
644 ContextFillArea.Front.Diffuse = float (aFront.Diffuse());
645 ContextFillArea.Front.Specular = float (aFront.Specular());
646 ContextFillArea.Front.Transparency = float (aFront.Transparency());
647 ContextFillArea.Front.Emission = float (aFront.Emissive());
648
649 // Reflection mode
650 ContextFillArea.Front.IsAmbient = aFront.ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0;
651 ContextFillArea.Front.IsDiffuse = aFront.ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0;
652 ContextFillArea.Front.IsSpecular = aFront.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0;
653 ContextFillArea.Front.IsEmission = aFront.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0;
654
655 // Material type
656 ContextFillArea.Front.IsPhysic = aFront.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0;
657
658 // Specular color
659 ContextFillArea.Front.ColorSpec.r = float (aFront.SpecularColor().Red());
660 ContextFillArea.Front.ColorSpec.g = float (aFront.SpecularColor().Green());
661 ContextFillArea.Front.ColorSpec.b = float (aFront.SpecularColor().Blue());
662
663 // Ambient color
664 ContextFillArea.Front.ColorAmb.r = float (aFront.AmbientColor().Red());
665 ContextFillArea.Front.ColorAmb.g = float (aFront.AmbientColor().Green());
666 ContextFillArea.Front.ColorAmb.b = float (aFront.AmbientColor().Blue());
667
668 // Diffuse color
669 ContextFillArea.Front.ColorDif.r = float (aFront.DiffuseColor().Red());
670 ContextFillArea.Front.ColorDif.g = float (aFront.DiffuseColor().Green());
671 ContextFillArea.Front.ColorDif.b = float (aFront.DiffuseColor().Blue());
672
673 // Emissive color
674 ContextFillArea.Front.ColorEms.r = float (aFront.EmissiveColor().Red());
675 ContextFillArea.Front.ColorEms.g = float (aFront.EmissiveColor().Green());
676 ContextFillArea.Front.ColorEms.b = float (aFront.EmissiveColor().Blue());
677
678 ContextFillArea.Front.EnvReflexion = float (aFront.EnvReflexion());
679
680 ContextFillArea.IsDef = 1; // Material definition ok
681
682 ContextFillArea.Texture.TextureMap = theAspFill->TextureMap();
683 ContextFillArea.Texture.doTextureMap = theAspFill->TextureMapState() ? 1 : 0;
684
685 Standard_Integer aPolyMode;
686 Standard_ShortReal aPolyFactor, aPolyUnits;
687 theAspFill->PolygonOffsets (aPolyMode, aPolyFactor, aPolyUnits);
688 ContextFillArea.PolygonOffsetMode = aPolyMode;
689 ContextFillArea.PolygonOffsetFactor = aPolyFactor;
690 ContextFillArea.PolygonOffsetUnits = aPolyUnits;
691
692 ContextFillArea.ShaderProgram = theAspFill->ShaderProgram();
693
694 UpdateAspectFace (Standard_False);
695
696 ContextFillArea.IsSet = 1;
697
698 Update();
699}
700
701// =======================================================================
702// function : SetPrimitivesAspect
703// purpose :
704// =======================================================================
705void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker)
706{
707 if (IsDeleted())
708 {
709 return;
710 }
711
712 Standard_Real aScale;
713 Quantity_Color aColor;
714 Aspect_TypeOfMarker aMarkerType;
715 theAspMarker->Values (aColor, aMarkerType, aScale);
716
717 ContextMarker.IsDef = 1;
718 ContextMarker.Color.r = Standard_ShortReal (aColor.Red());
719 ContextMarker.Color.g = Standard_ShortReal (aColor.Green());
720 ContextMarker.Color.b = Standard_ShortReal (aColor.Blue());
721 ContextMarker.MarkerType = aMarkerType;
722 ContextMarker.Scale = Standard_ShortReal (aScale);
723 ContextMarker.MarkerImage = theAspMarker->GetMarkerImage();
724
725 ContextMarker.ShaderProgram = theAspMarker->ShaderProgram();
726
727 UpdateAspectMarker (Standard_False);
728
729 ContextMarker.IsSet = 1;
730
731 Update();
732}
733
734// =======================================================================
735// function : SetPrimitivesAspect
736// purpose :
737// =======================================================================
738void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText)
739{
740 if (IsDeleted())
741 {
742 return;
743 }
744
745 Standard_CString aFont;
746 Standard_Real aSpace, anExpansion, aTextAngle;
747 Quantity_Color aColor, aColorSubTitle;
748 Aspect_TypeOfStyleText aStyle;
749 Aspect_TypeOfDisplayText aDisplayType;
750 Standard_Boolean aTextZoomable;
751 Font_FontAspect aTextFontAspect;
752 theAspText->Values (aColor, aFont, anExpansion, aSpace, aStyle, aDisplayType,
753 aColorSubTitle, aTextZoomable, aTextAngle, aTextFontAspect);
754
755 ContextText.IsDef = 1;
756 ContextText.Color.r = float (aColor.Red());
757 ContextText.Color.g = float (aColor.Green());
758 ContextText.Color.b = float (aColor.Blue());
759 ContextText.Font = (char* )aFont;
760 ContextText.Expan = float (anExpansion);
761 ContextText.Space = float (aSpace);
762 ContextText.Style = aStyle;
763 ContextText.DisplayType = aDisplayType;
764 ContextText.ColorSubTitle.r = float (aColorSubTitle.Red());
765 ContextText.ColorSubTitle.g = float (aColorSubTitle.Green());
766 ContextText.ColorSubTitle.b = float (aColorSubTitle.Blue());
767 ContextText.TextZoomable = aTextZoomable;
768 ContextText.TextAngle = float (aTextAngle);
769 ContextText.TextFontAspect = aTextFontAspect;
770 ContextText.ShaderProgram = theAspText->ShaderProgram();
771
772 UpdateAspectText (Standard_False);
773
774 ContextText.IsSet = 1;
775
776 Update();
777}
778
779// =======================================================================
780// function : IsGroupPrimitivesAspectSet
781// purpose :
782// =======================================================================
783Standard_Boolean Graphic3d_Group::IsGroupPrimitivesAspectSet (const Graphic3d_GroupAspect theAspect) const
784{
785 switch (theAspect)
786 {
787 case Graphic3d_ASPECT_LINE: return ContextLine.IsSet;
788 case Graphic3d_ASPECT_TEXT: return ContextText.IsSet;
789 case Graphic3d_ASPECT_MARKER: return ContextMarker.IsSet;
790 case Graphic3d_ASPECT_FILL_AREA: return ContextFillArea.IsSet;
791 default: return Standard_False;
792 }
793}
794
795// =======================================================================
796// function : GroupPrimitivesAspect
797// purpose :
798// =======================================================================
799void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
800 const Handle(Graphic3d_AspectText3d)& theAspText,
801 const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
802 const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const
803{
804 Quantity_Color aColor;
805 Graphic3d_MaterialAspect aFront, aBack;
806
807 const CALL_DEF_CONTEXTLINE& anAspLine = ContextLine.IsSet ? ContextLine : myStructure->CStructure()->ContextLine;
808 aColor.SetValues (Standard_Real (anAspLine.Color.r),
809 Standard_Real (anAspLine.Color.g),
810 Standard_Real (anAspLine.Color.b), Quantity_TOC_RGB);
811 theAspLine->SetColor (aColor);
812 theAspLine->SetType (Aspect_TypeOfLine (anAspLine.LineType));
813 theAspLine->SetWidth (Standard_Real (anAspLine.Width));
814 theAspLine->SetShaderProgram (anAspLine.ShaderProgram);
815
816 const CALL_DEF_CONTEXTTEXT& anAspText = ContextText.IsSet ? ContextText : myStructure->CStructure()->ContextText;
817 aColor.SetValues (Standard_Real (anAspText.Color.r),
818 Standard_Real (anAspText.Color.g),
819 Standard_Real (anAspText.Color.b), Quantity_TOC_RGB);
820 theAspText->SetColor (aColor);
821 aColor.SetValues (Standard_Real (anAspText.ColorSubTitle.r),
822 Standard_Real (anAspText.ColorSubTitle.g),
823 Standard_Real (anAspText.ColorSubTitle.b), Quantity_TOC_RGB);
824 theAspText->SetColorSubTitle (aColor);
825 theAspText->SetFont (anAspText.Font);
826 theAspText->SetSpace (Standard_Real (anAspText.Space));
827 theAspText->SetExpansionFactor (Standard_Real (anAspText.Expan));
828 theAspText->SetStyle (Aspect_TypeOfStyleText (anAspText.Style));
829 theAspText->SetDisplayType (Aspect_TypeOfDisplayText (anAspText.DisplayType));
830 theAspText->SetShaderProgram (anAspText.ShaderProgram);
831
832 const CALL_DEF_CONTEXTMARKER& anAspMarker = ContextMarker.IsSet ? ContextMarker : myStructure->CStructure()->ContextMarker;
833 aColor.SetValues (Standard_Real (anAspMarker.Color.r),
834 Standard_Real (anAspMarker.Color.g),
835 Standard_Real (anAspMarker.Color.b), Quantity_TOC_RGB);
836 theAspMarker->SetColor (aColor);
837 theAspMarker->SetType (anAspMarker.MarkerType);
838 theAspMarker->SetScale (Standard_Real (anAspMarker.Scale));
839 theAspMarker->SetShaderProgram (anAspMarker.ShaderProgram);
840 if (anAspMarker.MarkerType == Aspect_TOM_USERDEFINED)
841 {
842 theAspMarker->SetMarkerImage (ContextMarker.MarkerImage);
843 }
844
845 const CALL_DEF_CONTEXTFILLAREA& anAspFill = ContextFillArea.IsSet ? ContextFillArea : myStructure->CStructure()->ContextFillArea;
846 // Interior
847 theAspFill->SetInteriorStyle (Aspect_InteriorStyle (anAspFill.Style));
848 aColor.SetValues (Standard_Real (anAspFill.IntColor.r),
849 Standard_Real (anAspFill.IntColor.g),
850 Standard_Real (anAspFill.IntColor.b), Quantity_TOC_RGB);
851 theAspFill->SetInteriorColor (aColor);
852
853 // Edges
854 aColor.SetValues (Standard_Real (anAspFill.EdgeColor.r),
855 Standard_Real (anAspFill.EdgeColor.g),
856 Standard_Real (anAspFill.EdgeColor.b), Quantity_TOC_RGB);
857 theAspFill->SetEdgeColor (aColor);
858 theAspFill->SetEdgeLineType (Aspect_TypeOfLine (anAspFill.LineType));
859 theAspFill->SetEdgeWidth (Standard_Real (anAspFill.Width));
860
861 // Back Material
862 aBack.SetShininess (Standard_Real (anAspFill.Back.Shininess));
863 aBack.SetAmbient (Standard_Real (anAspFill.Back.Ambient));
864 aBack.SetDiffuse (Standard_Real (anAspFill.Back.Diffuse));
865 aBack.SetSpecular (Standard_Real (anAspFill.Back.Specular));
866 aBack.SetTransparency (Standard_Real (anAspFill.Back.Transparency));
867 aBack.SetEmissive (Standard_Real (anAspFill.Back.Emission));
868 anAspFill.Back.IsAmbient == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_AMBIENT) : aBack.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
869 anAspFill.Back.IsDiffuse == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE) : aBack.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
870 anAspFill.Back.IsSpecular == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_SPECULAR) : aBack.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
871 anAspFill.Back.IsEmission == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_EMISSION) : aBack.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
872
873 aColor.SetValues (Standard_Real (anAspFill.Back.ColorSpec.r),
874 Standard_Real (anAspFill.Back.ColorSpec.g),
875 Standard_Real (anAspFill.Back.ColorSpec.b), Quantity_TOC_RGB);
876 aBack.SetSpecularColor (aColor);
877
878 aColor.SetValues (Standard_Real (anAspFill.Back.ColorAmb.r),
879 Standard_Real (anAspFill.Back.ColorAmb.g),
880 Standard_Real (anAspFill.Back.ColorAmb.b), Quantity_TOC_RGB);
881 aBack.SetAmbientColor (aColor);
882
883 aColor.SetValues (Standard_Real (anAspFill.Back.ColorDif.r),
884 Standard_Real (anAspFill.Back.ColorDif.g),
885 Standard_Real (anAspFill.Back.ColorDif.b), Quantity_TOC_RGB);
886 aBack.SetDiffuseColor (aColor);
887
888 aColor.SetValues (Standard_Real (anAspFill.Back.ColorEms.r),
889 Standard_Real (anAspFill.Back.ColorEms.g),
890 Standard_Real (anAspFill.Back.ColorEms.b), Quantity_TOC_RGB);
891 aBack.SetEmissiveColor (aColor);
892
893 aBack.SetEnvReflexion (anAspFill.Back.EnvReflexion);
894
895 // Front Material
896 aFront.SetShininess (Standard_Real (anAspFill.Front.Shininess));
897 aFront.SetAmbient (Standard_Real (anAspFill.Front.Ambient));
898 aFront.SetDiffuse (Standard_Real (anAspFill.Front.Diffuse));
899 aFront.SetSpecular (Standard_Real (anAspFill.Front.Specular));
900 aFront.SetTransparency (Standard_Real (anAspFill.Front.Transparency));
901 aFront.SetEmissive (Standard_Real (anAspFill.Back.Emission));
902 anAspFill.Front.IsAmbient == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_AMBIENT) : aFront.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
903 anAspFill.Front.IsDiffuse == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE) : aFront.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
904 anAspFill.Front.IsSpecular == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_SPECULAR) : aFront.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
905 anAspFill.Front.IsEmission == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_EMISSION) : aFront.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
906
907 aColor.SetValues (Standard_Real (anAspFill.Front.ColorSpec.r),
908 Standard_Real (anAspFill.Front.ColorSpec.g),
909 Standard_Real (anAspFill.Front.ColorSpec.b), Quantity_TOC_RGB);
910 aFront.SetSpecularColor (aColor);
911
912 aColor.SetValues (Standard_Real (anAspFill.Front.ColorAmb.r),
913 Standard_Real (anAspFill.Front.ColorAmb.g),
914 Standard_Real (anAspFill.Front.ColorAmb.b), Quantity_TOC_RGB);
915 aFront.SetAmbientColor (aColor);
916
917 aColor.SetValues (Standard_Real (anAspFill.Front.ColorDif.r),
918 Standard_Real (anAspFill.Front.ColorDif.g),
919 Standard_Real (anAspFill.Front.ColorDif.b), Quantity_TOC_RGB);
920 aFront.SetDiffuseColor (aColor);
921
922 aColor.SetValues (Standard_Real (anAspFill.Front.ColorEms.r),
923 Standard_Real (anAspFill.Front.ColorEms.g),
924 Standard_Real (anAspFill.Front.ColorEms.b), Quantity_TOC_RGB);
925 aFront.SetEmissiveColor (aColor);
926
927 aFront.SetEnvReflexion (anAspFill.Front.EnvReflexion);
928
929 // Edges
930 anAspFill.Edge == 1 ? theAspFill->SetEdgeOn() : theAspFill->SetEdgeOff();
931 // Hatch
932 theAspFill->SetHatchStyle (Aspect_HatchStyle (anAspFill.Hatch));
933 // Materials
934 // Front and Back face
935 anAspFill.Distinguish == 1 ? theAspFill->SetDistinguishOn() : theAspFill->SetDistinguishOff();
936 anAspFill.BackFace == 1 ? theAspFill->SuppressBackFace() : theAspFill->AllowBackFace();
937 // Texture
938 theAspFill->SetTextureMap (anAspFill.Texture.TextureMap);
939 anAspFill.Texture.doTextureMap == 1 ? theAspFill->SetTextureMapOn() : theAspFill->SetTextureMapOff();
940 theAspFill->SetShaderProgram (anAspFill.ShaderProgram);
941 theAspFill->SetPolygonOffsets (anAspFill.PolygonOffsetMode,
942 anAspFill.PolygonOffsetFactor,
943 anAspFill.PolygonOffsetUnits);
944 theAspFill->SetBackMaterial (aBack);
945 theAspFill->SetFrontMaterial (aFront);
946}
947
948// =======================================================================
949// function : PrimitivesAspect
950// purpose :
951// =======================================================================
952void Graphic3d_Group::PrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
953 const Handle(Graphic3d_AspectText3d)& theAspText,
954 const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
955 const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const
956{
957 GroupPrimitivesAspect (theAspLine, theAspText, theAspMarker, theAspFill);
958}
959
960// =======================================================================
961// function : AddPrimitiveArray
962// purpose :
963// =======================================================================
964void Graphic3d_Group::AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim,
965 const Standard_Boolean theToEvalMinMax)
966{
967 if (IsDeleted()
968 || !thePrim->IsValid())
969 {
970 return;
971 }
972
871fa103 973 AddPrimitiveArray (thePrim->Type(), thePrim->Indices(), thePrim->Attributes(), thePrim->Bounds(), theToEvalMinMax);
974}
975
976// =======================================================================
977// function : AddPrimitiveArray
978// purpose :
979// =======================================================================
980void Graphic3d_Group::AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
981 const Handle(Graphic3d_IndexBuffer)& ,
982 const Handle(Graphic3d_Buffer)& theAttribs,
983 const Handle(Graphic3d_BoundBuffer)& ,
984 const Standard_Boolean theToEvalMinMax)
985{
986 if (IsDeleted()
987 || theAttribs.IsNull())
988 {
989 return;
990 }
991
b64d84be 992 if (!MyContainsFacet
871fa103 993 && theType != Graphic3d_TOPA_POLYLINES
994 && theType != Graphic3d_TOPA_SEGMENTS
995 && theType != Graphic3d_TOPA_POINTS)
b64d84be 996 {
997 myStructure->GroupsWithFacet (1);
998 MyContainsFacet = Standard_True;
999 }
1000
b64d84be 1001 if (theToEvalMinMax)
1002 {
871fa103 1003 const Standard_Integer aNbVerts = theAttribs->NbElements;
1004 for (Standard_Integer anAttribIter = 0; anAttribIter < theAttribs->NbAttributes; ++anAttribIter)
b64d84be 1005 {
871fa103 1006 const Graphic3d_Attribute& anAttrib = theAttribs->Attribute (anAttribIter);
1007 if (anAttrib.Id != Graphic3d_TOA_POS)
1008 {
1009 continue;
1010 }
1011
1012 const size_t anOffset = theAttribs->AttributeOffset (anAttribIter);
1013 switch (anAttrib.DataType)
1014 {
1015 case Graphic3d_TOD_VEC2:
1016 {
1017 for (Standard_Integer aVertIter = 0; aVertIter < aNbVerts; ++aVertIter)
1018 {
1019 const Graphic3d_Vec2& aVert = *reinterpret_cast<const Graphic3d_Vec2* >(theAttribs->value (aVertIter) + anOffset);
b7cd4ba7 1020 myBounds.Add (Graphic3d_Vec4 (aVert.x(), aVert.y(), 0.0f, 1.0f));
871fa103 1021 }
1022 break;
1023 }
1024 case Graphic3d_TOD_VEC3:
1025 case Graphic3d_TOD_VEC4:
1026 {
1027 for (Standard_Integer aVertIter = 0; aVertIter < aNbVerts; ++aVertIter)
1028 {
1029 const Graphic3d_Vec3& aVert = *reinterpret_cast<const Graphic3d_Vec3* >(theAttribs->value (aVertIter) + anOffset);
b7cd4ba7 1030 myBounds.Add (Graphic3d_Vec4 (aVert.x(), aVert.y(), aVert.z(), 1.0f));
871fa103 1031 }
1032 break;
1033 }
1034 default: break;
1035 }
1036 break;
b64d84be 1037 }
1038 }
1039
1040 Update();
1041}
1042
1043// =======================================================================
1044// function : Marker
1045// purpose :
1046// =======================================================================
1047void Graphic3d_Group::Marker (const Graphic3d_Vertex& thePoint,
1048 const Standard_Boolean theToEvalMinMax)
1049{
1050 Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints (1);
1051 aPoints->AddVertex (thePoint.X(), thePoint.Y(), thePoint.Z());
1052 AddPrimitiveArray (aPoints, theToEvalMinMax);
1053}
1054
1055// =======================================================================
1056// function : UserDraw
1057// purpose :
1058// =======================================================================
1059void Graphic3d_Group::UserDraw (const Standard_Address /*theObject*/,
1060 const Standard_Boolean /*theToEvalMinMax*/,
1061 const Standard_Boolean theContainsFacet)
1062{
1063 if (IsDeleted())
1064 {
1065 return;
1066 }
1067
1068 // Without this modification, the group assumes the primitive contains
1069 // no polygons and does not require the Z-buffer for display.
1070 if (!MyContainsFacet && theContainsFacet)
1071 {
1072 myStructure->GroupsWithFacet (1);
1073 MyContainsFacet = Standard_True;
1074 }
1075
b64d84be 1076 Update();
1077}
1078
1079// =======================================================================
1080// function : Text
1081// purpose :
1082// =======================================================================
1083void Graphic3d_Group::Text (const Standard_CString /*theText*/,
1084 const Graphic3d_Vertex& thePoint,
1085 const Standard_Real /*theHeight*/,
1086 const Quantity_PlaneAngle /*theAngle*/,
1087 const Graphic3d_TextPath /*theTp*/,
1088 const Graphic3d_HorizontalTextAlignment /*theHta*/,
1089 const Graphic3d_VerticalTextAlignment /*theVta*/,
1090 const Standard_Boolean theToEvalMinMax)
1091{
1092 if (IsDeleted())
1093 {
1094 return;
1095 }
1096
b64d84be 1097 if (theToEvalMinMax)
1098 {
1099 Standard_ShortReal x, y, z;
1100 thePoint.Coord (x, y, z);
b7cd4ba7 1101 myStructure->CStructure()->Is2dText = Standard_True;
1102 myBounds.Add (Graphic3d_Vec4 (static_cast<Standard_ShortReal> (x),
1103 static_cast<Standard_ShortReal> (y),
1104 static_cast<Standard_ShortReal> (z),
1105 1.0f));
b64d84be 1106 }
1107 Update();
1108}
1109
1110// =======================================================================
1111// function : Text
1112// purpose :
1113// =======================================================================
1114void Graphic3d_Group::Text (const Standard_CString theText,
1115 const Graphic3d_Vertex& thePoint,
1116 const Standard_Real theHeight,
1117 const Standard_Boolean theToEvalMinMax)
1118{
1119 Text (theText, thePoint, theHeight, 0.0,
1120 Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax);
1121}
1122
1123// =======================================================================
1124// function : Text
1125// purpose :
1126// =======================================================================
1127void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
1128 const Graphic3d_Vertex& thePoint,
1129 const Standard_Real theHeight,
1130 const Quantity_PlaneAngle theAngle,
1131 const Graphic3d_TextPath theTp,
1132 const Graphic3d_HorizontalTextAlignment theHta,
1133 const Graphic3d_VerticalTextAlignment theVta,
1134 const Standard_Boolean theToEvalMinMax)
1135{
1136 const NCollection_String aText ((Standard_Utf16Char* )theText.ToExtString());
1137 Text (aText.ToCString(), thePoint, theHeight, theAngle,
1138 theTp, theHta, theVta, theToEvalMinMax);
1139}
1140
1141// =======================================================================
1142// function : Text
1143// purpose :
1144// =======================================================================
1145void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
1146 const Graphic3d_Vertex& thePoint,
1147 const Standard_Real theHeight,
1148 const Standard_Boolean theToEvalMinMax)
1149{
1150 const NCollection_String aText ((Standard_Utf16Char* )theText.ToExtString());
1151 Text (aText.ToCString(), thePoint, theHeight, 0.0,
1152 Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax);
7fd59977 1153}
31c0e219 1154
1155// =======================================================================
1156// function : SetClosed
1157// purpose :
1158// =======================================================================
1159void Graphic3d_Group::SetClosed (const Standard_Boolean theIsClosed)
1160{
1161 myIsClosed = theIsClosed;
1162}
1163
1164// =======================================================================
1165// function : IsClosed
1166// purpose :
1167// =======================================================================
1168Standard_Boolean Graphic3d_Group::IsClosed() const
1169{
1170 return myIsClosed;
1171}
b7cd4ba7 1172
1173//=======================================================================
1174//function : BoundingBox
1175//purpose :
1176//=======================================================================
1177const Graphic3d_BndBox4f& Graphic3d_Group::BoundingBox() const
1178{
1179 return myBounds;
1180}
1181
1182//=======================================================================
1183//function : ChangeBoundingBox
1184//purpose :
1185//=======================================================================
1186Graphic3d_BndBox4f& Graphic3d_Group::ChangeBoundingBox()
1187{
1188 return myBounds;
1189}