0022819: Redesign of OpenGl driver
[occt.git] / src / Graphic3d / Graphic3d_Group_12.cxx
1
2 // File         Graphic3d_Group_12.cxx (Curve)
3 // Created      Aout 1994
4 // Author       NW,JPB,CAL
5
6 //-Copyright    MatraDatavision 1994
7
8 //-Version      
9
10 //-Design       Declaration des variables specifiques aux groupes
11 //              de primitives
12
13 //-Warning      Un groupe est defini dans une structure
14 //              Il s'agit de la plus petite entite editable
15
16 //-References   
17
18 //-Language     C++ 2.0
19
20 //-Declarations
21
22 // for the class
23 #include <Graphic3d_Group.jxx>
24 #include <Graphic3d_Group.pxx>
25
26 //-Methods, in order
27
28 void Graphic3d_Group::Bezier (const Graphic3d_Array1OfVertex& ListVertex, const Standard_Boolean EvalMinMax) {
29
30         if (IsDeleted ()) return;
31
32         MyIsEmpty       = Standard_False;
33
34 Standard_Integer i, j;
35
36         i       = ListVertex.Length ();
37
38         if (i <= 2)
39         Graphic3d_GroupDefinitionError::Raise ("Bad number of vertices");
40
41         // Min-Max Update
42         if (EvalMinMax) {
43 Standard_Real X, Y, Z;
44 Standard_Integer Lower  = ListVertex.Lower ();
45 Standard_Integer Upper  = ListVertex.Upper ();
46                 // Parcours des sommets
47                 for (j=0, i=Lower; i<=Upper; i++, j++) {
48                         ListVertex (i).Coord (X, Y, Z);
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->Bezier (MyCGroup, ListVertex, EvalMinMax);
59
60         Update ();
61
62 }
63
64 void Graphic3d_Group::Bezier (const Graphic3d_Array1OfVertex& ListVertex, const TColStd_Array1OfReal& ListWeight, const Standard_Boolean EvalMinMax) {
65
66         if (IsDeleted ()) return;
67
68         MyIsEmpty       = Standard_False;
69
70 Standard_Integer i, j;
71
72         i       = ListVertex.Length ();
73         j       = ListWeight.Length ();
74
75         if ((i <= 2) || (i != j))
76         Graphic3d_GroupDefinitionError::Raise ("Bad number of vertices");
77
78         // Min-Max Update
79         if (EvalMinMax) {
80 Standard_Real X, Y, Z;
81 Standard_Integer Lower  = ListVertex.Lower ();
82 Standard_Integer Upper  = ListVertex.Upper ();
83                 // Parcours des sommets
84                 for (j=0, i=Lower; i<=Upper; i++, j++) {
85                         ListVertex (i).Coord (X, Y, Z);
86                         if (X < MyBounds.XMin) MyBounds.XMin    = Standard_ShortReal (X);
87                         if (Y < MyBounds.YMin) MyBounds.YMin    = Standard_ShortReal (Y);
88                         if (Z < MyBounds.ZMin) MyBounds.ZMin    = Standard_ShortReal (Z);
89                         if (X > MyBounds.XMax) MyBounds.XMax    = Standard_ShortReal (X);
90                         if (Y > MyBounds.YMax) MyBounds.YMax    = Standard_ShortReal (Y);
91                         if (Z > MyBounds.ZMax) MyBounds.ZMax    = Standard_ShortReal (Z);
92                 }
93         }
94
95         MyGraphicDriver->Bezier
96                 (MyCGroup, ListVertex, ListWeight, EvalMinMax);
97
98         Update ();
99
100 }