1 // Created on: 2000-06-16
2 // Copyright (c) 2000-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <Graphic3d_Group.jxx>
16 #include <Graphic3d_Group.pxx>
18 #include <Graphic3d_ArrayOfPoints.hxx>
21 // =======================================================================
22 // function : AddPrimitiveArray
24 // =======================================================================
26 void Graphic3d_Group :: AddPrimitiveArray ( const Handle(Graphic3d_ArrayOfPrimitives)& elem,const Standard_Boolean EvalMinMax )
28 if (IsDeleted () ) return;
30 if( !elem->IsValid() ) return;
32 if( !MyContainsFacet &&
33 (elem->Type() != Graphic3d_TOPA_POLYLINES) &&
34 (elem->Type() != Graphic3d_TOPA_SEGMENTS) &&
35 (elem->Type() != Graphic3d_TOPA_POINTS) ) {
36 MyStructure->GroupsWithFacet (+1);
37 MyContainsFacet = Standard_True;
40 MyIsEmpty = Standard_False;
42 MyListOfPArray.Append(elem);
48 for (int k=1; k<=elem->VertexNumber() ; k++) {
49 elem->Vertice(k,x,y,z);
51 if (x < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal(x);
52 if (y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal(y);
53 if (z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal(z);
54 if (x > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal(x);
55 if (y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal(y);
56 if (z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal(z);
60 MyGraphicDriver->PrimitiveArray(MyCGroup, elem->Array());
65 // =======================================================================
68 // =======================================================================
70 void Graphic3d_Group::Marker (const Graphic3d_Vertex& thePoint,
71 const Standard_Boolean theToEvalMinMax)
73 Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints (1);
74 aPoints->AddVertex (thePoint.X(), thePoint.Y(), thePoint.Z());
75 AddPrimitiveArray (aPoints, theToEvalMinMax);
78 // =======================================================================
79 // function : UserDraw
81 // =======================================================================
83 void Graphic3d_Group :: UserDraw ( const Standard_Address AnObject,
84 const Standard_Boolean EvalMinMax,
85 const Standard_Boolean ContainsFacet )
87 if (IsDeleted ()) return;
89 // Without this modification, the group assumes the primitive contains
90 // no polygons and does not require the Z-buffer for display.
91 if (!MyContainsFacet && ContainsFacet) {
92 MyStructure->GroupsWithFacet (+1);
93 MyContainsFacet = Standard_True;
96 MyIsEmpty = Standard_False;
98 Graphic3d_CUserDraw AUserDraw;
99 AUserDraw.Data = AnObject;
100 AUserDraw.Bounds = ( EvalMinMax? &MyBounds : NULL );
101 MyGraphicDriver->UserDraw (MyCGroup, AUserDraw);
106 // =======================================================================
107 // function : SetFlippingOptions
109 // =======================================================================
111 void Graphic3d_Group::SetFlippingOptions (const Standard_Boolean theIsEnabled,
112 const gp_Ax2& theRefPlane)
114 MyGraphicDriver->SetFlippingOptions (MyCGroup, theIsEnabled, theRefPlane);
117 // =======================================================================
118 // function : SetStencilTestOptions
120 // =======================================================================
121 void Graphic3d_Group::SetStencilTestOptions (const Standard_Boolean theIsEnabled)
123 MyGraphicDriver->SetStencilTestOptions (MyCGroup, theIsEnabled);