b311480e |
1 | // Created on: 2000-06-16 |
2 | // Copyright (c) 2000-2012 OPEN CASCADE SAS |
3 | // |
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. |
8 | // |
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. |
11 | // |
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. |
18 | |
7fd59977 |
19 | |
20 | #include <Graphic3d_Group.jxx> |
21 | #include <Graphic3d_Group.pxx> |
22 | #include <gp_Pnt.hxx> |
23 | |
24 | void Graphic3d_Group :: AddPrimitiveArray ( const Handle(Graphic3d_ArrayOfPrimitives)& elem,const Standard_Boolean EvalMinMax ) |
25 | { |
26 | if (IsDeleted () ) return; |
27 | |
28 | if( !elem->IsValid() ) return; |
29 | |
30 | if( !MyContainsFacet && |
31 | (elem->Type() != Graphic3d_TOPA_POLYLINES) && |
32 | (elem->Type() != Graphic3d_TOPA_SEGMENTS) && |
33 | (elem->Type() != Graphic3d_TOPA_POINTS) ) { |
34 | MyStructure->GroupsWithFacet (+1); |
35 | MyContainsFacet = Standard_True; |
36 | } |
37 | |
38 | MyIsEmpty = Standard_False; |
39 | |
40 | MyListOfPArray.Append(elem); |
41 | |
42 | // Min-Max Update |
43 | if (EvalMinMax) { |
44 | Standard_Real x,y,z; |
45 | |
46 | for (int k=1; k<=elem->VertexNumber() ; k++) { |
47 | elem->Vertice(k,x,y,z); |
48 | |
49 | if (x < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal(x); |
50 | if (y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal(y); |
51 | if (z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal(z); |
52 | if (x > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal(x); |
53 | if (y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal(y); |
54 | if (z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal(z); |
55 | } |
56 | } |
57 | |
58 | MyGraphicDriver->PrimitiveArray(MyCGroup, elem->Array()); |
59 | |
60 | Update (); |
61 | } |
62 | |
7fd59977 |
63 | void Graphic3d_Group :: UserDraw ( const Standard_Address AnObject, |
64 | const Standard_Boolean EvalMinMax, |
65 | const Standard_Boolean ContainsFacet ) |
66 | { |
67 | if (IsDeleted ()) return; |
68 | |
7fd59977 |
69 | // Without this modification, the group assumes the primitive contains |
70 | // no polygons and does not require the Z-buffer for display. |
71 | if (!MyContainsFacet && ContainsFacet) { |
72 | MyStructure->GroupsWithFacet (+1); |
73 | MyContainsFacet = Standard_True; |
74 | } |
7fd59977 |
75 | |
76 | MyIsEmpty = Standard_False; |
77 | |
78 | Graphic3d_CUserDraw AUserDraw; |
79 | AUserDraw.Data = AnObject; |
80 | AUserDraw.Bounds = ( EvalMinMax? &MyBounds : NULL ); |
81 | MyGraphicDriver->UserDraw (MyCGroup, AUserDraw); |
82 | |
83 | Update (); |
84 | } |