1 // Created on: 2000-06-16
2 // Copyright (c) 2000-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
20 #include <Graphic3d_Group.jxx>
21 #include <Graphic3d_Group.pxx>
24 // =======================================================================
25 // function : AddPrimitiveArray
27 // =======================================================================
29 void Graphic3d_Group :: AddPrimitiveArray ( const Handle(Graphic3d_ArrayOfPrimitives)& elem,const Standard_Boolean EvalMinMax )
31 if (IsDeleted () ) return;
33 if( !elem->IsValid() ) return;
35 if( !MyContainsFacet &&
36 (elem->Type() != Graphic3d_TOPA_POLYLINES) &&
37 (elem->Type() != Graphic3d_TOPA_SEGMENTS) &&
38 (elem->Type() != Graphic3d_TOPA_POINTS) ) {
39 MyStructure->GroupsWithFacet (+1);
40 MyContainsFacet = Standard_True;
43 MyIsEmpty = Standard_False;
45 MyListOfPArray.Append(elem);
51 for (int k=1; k<=elem->VertexNumber() ; k++) {
52 elem->Vertice(k,x,y,z);
54 if (x < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal(x);
55 if (y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal(y);
56 if (z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal(z);
57 if (x > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal(x);
58 if (y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal(y);
59 if (z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal(z);
63 MyGraphicDriver->PrimitiveArray(MyCGroup, elem->Array());
68 // =======================================================================
69 // function : UserDraw
71 // =======================================================================
73 void Graphic3d_Group :: UserDraw ( const Standard_Address AnObject,
74 const Standard_Boolean EvalMinMax,
75 const Standard_Boolean ContainsFacet )
77 if (IsDeleted ()) return;
79 // Without this modification, the group assumes the primitive contains
80 // no polygons and does not require the Z-buffer for display.
81 if (!MyContainsFacet && ContainsFacet) {
82 MyStructure->GroupsWithFacet (+1);
83 MyContainsFacet = Standard_True;
86 MyIsEmpty = Standard_False;
88 Graphic3d_CUserDraw AUserDraw;
89 AUserDraw.Data = AnObject;
90 AUserDraw.Bounds = ( EvalMinMax? &MyBounds : NULL );
91 MyGraphicDriver->UserDraw (MyCGroup, AUserDraw);
96 // =======================================================================
97 // function : SetFlippingOptions
99 // =======================================================================
101 void Graphic3d_Group::SetFlippingOptions (const Standard_Boolean theIsEnabled,
102 const gp_Ax2& theRefPlane)
104 MyGraphicDriver->SetFlippingOptions (MyCGroup, theIsEnabled, theRefPlane);
107 // =======================================================================
108 // function : SetStencilTestOptions
110 // =======================================================================
111 void Graphic3d_Group::SetStencilTestOptions (const Standard_Boolean theIsEnabled)
113 MyGraphicDriver->SetStencilTestOptions (MyCGroup, theIsEnabled);