a1d1d5de87adb2ec3b36df4f9636050b861c1eac
[occt.git] / src / Graphic3d / Graphic3d_Group_5.cxx
1 // Created by: NW,JPB,CAL
2 // Copyright (c) 1991-1999 Matra Datavision
3 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20
21 // Modified    
22 //              27/08/97 ; PCT : ajout coordonnee texture
23
24
25 //-Version      
26
27 //-Design       Declaration des variables specifiques aux groupes
28 //              de primitives
29
30 //-Warning      Un groupe est defini dans une structure
31 //              Il s'agit de la plus petite entite editable
32
33 //-References   
34
35 //-Language     C++ 2.0
36
37 //-Declarations
38
39 // for the class
40 #include <Graphic3d_Group.jxx>
41 #include <Graphic3d_Group.pxx>
42
43 #include <Graphic3d_VertexN.hxx>
44 #include <Graphic3d_VertexNT.hxx>
45
46 //-Methods, in order
47
48 void Graphic3d_Group::Polygon (const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) {
49
50         if (IsDeleted ()) return;
51
52         if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
53         MyContainsFacet = Standard_True;
54         MyIsEmpty       = Standard_False;
55
56         // Min-Max Update
57         if (EvalMinMax) {
58
59                 Standard_Real X, Y, Z;
60                 Standard_Integer i, j;
61                 Standard_Integer Lower  = ListVertex.Lower ();
62                 Standard_Integer Upper  = ListVertex.Upper ();
63                 // Parcours des sommets
64                 for (j=0, i=Lower; i<=Upper; i++, j++) {
65                         ListVertex (i).Coord (X, Y, Z);
66                         if (X < MyBounds.XMin) MyBounds.XMin    = Standard_ShortReal (X);
67                         if (Y < MyBounds.YMin) MyBounds.YMin    = Standard_ShortReal (Y);
68                         if (Z < MyBounds.ZMin) MyBounds.ZMin    = Standard_ShortReal (Z);
69                         if (X > MyBounds.XMax) MyBounds.XMax    = Standard_ShortReal (X);
70                         if (Y > MyBounds.YMax) MyBounds.YMax    = Standard_ShortReal (Y);
71                         if (Z > MyBounds.ZMax) MyBounds.ZMax    = Standard_ShortReal (Z);
72                 }
73         }
74
75         MyGraphicDriver->Polygon (MyCGroup, ListVertex, AType, EvalMinMax);
76
77         Update ();
78
79 }
80
81 void Graphic3d_Group::Polygon (const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_Vector& Normal, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) {
82
83         if (IsDeleted ()) return;
84
85         if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
86         MyContainsFacet = Standard_True;
87         MyIsEmpty       = Standard_False;
88
89         // Min-Max Update
90         if (EvalMinMax) {
91                 Standard_Real X, Y, Z;
92                 Standard_Integer i, j;
93                 Standard_Integer Lower  = ListVertex.Lower ();
94                 Standard_Integer Upper  = ListVertex.Upper ();
95                 // Parcours des sommets
96                 for (j=0, i=Lower; i<=Upper; i++, j++) {
97                         ListVertex (i).Coord (X, Y, Z);
98                         if (X < MyBounds.XMin) MyBounds.XMin    = Standard_ShortReal (X);
99                         if (Y < MyBounds.YMin) MyBounds.YMin    = Standard_ShortReal (Y);
100                         if (Z < MyBounds.ZMin) MyBounds.ZMin    = Standard_ShortReal (Z);
101                         if (X > MyBounds.XMax) MyBounds.XMax    = Standard_ShortReal (X);
102                         if (Y > MyBounds.YMax) MyBounds.YMax    = Standard_ShortReal (Y);
103                         if (Z > MyBounds.ZMax) MyBounds.ZMax    = Standard_ShortReal (Z);
104                 }
105         }
106
107         MyGraphicDriver->Polygon
108                 (MyCGroup, ListVertex, Normal, AType, EvalMinMax);
109
110         Update ();
111
112 }
113
114 void Graphic3d_Group::Polygon (const Graphic3d_Array1OfVertexN& ListVertex, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) {
115
116         if (IsDeleted ()) return;
117
118         if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
119         MyContainsFacet = Standard_True;
120         MyIsEmpty       = Standard_False;
121
122         // Min-Max Update
123         if (EvalMinMax) {
124                 Standard_Real X, Y, Z;
125                 Standard_Integer i;
126                 Standard_Integer Lower  = ListVertex.Lower ();
127                 Standard_Integer Upper  = ListVertex.Upper ();
128                 // Parcours des sommets
129                 for (i=Lower; i<=Upper; i++) {
130                         ListVertex (i).Coord (X, Y, Z);
131                         if (X < MyBounds.XMin) MyBounds.XMin    = Standard_ShortReal (X);
132                         if (Y < MyBounds.YMin) MyBounds.YMin    = Standard_ShortReal (Y);
133                         if (Z < MyBounds.ZMin) MyBounds.ZMin    = Standard_ShortReal (Z);
134                         if (X > MyBounds.XMax) MyBounds.XMax    = Standard_ShortReal (X);
135                         if (Y > MyBounds.YMax) MyBounds.YMax    = Standard_ShortReal (Y);
136                         if (Z > MyBounds.ZMax) MyBounds.ZMax    = Standard_ShortReal (Z);
137                 }
138         }
139
140         MyGraphicDriver->Polygon (MyCGroup, ListVertex, AType, EvalMinMax);
141
142         Update ();
143
144 }
145
146 void Graphic3d_Group::Polygon (const Graphic3d_Array1OfVertexN& ListVertex, const Graphic3d_Vector& Normal, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) {
147
148         if (IsDeleted ()) return;
149
150         if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
151         MyContainsFacet = Standard_True;
152         MyIsEmpty       = Standard_False;
153
154         // Min-Max Update
155         if (EvalMinMax) {
156                 Standard_Real X, Y, Z;
157                 Standard_Integer i;
158                 Standard_Integer Lower  = ListVertex.Lower ();
159                 Standard_Integer Upper  = ListVertex.Upper ();
160                 // Parcours des sommets
161                 for (i=Lower; i<=Upper; i++) {
162                         ListVertex (i).Coord (X, Y, Z);
163                         if (X < MyBounds.XMin) MyBounds.XMin    = Standard_ShortReal (X);
164                         if (Y < MyBounds.YMin) MyBounds.YMin    = Standard_ShortReal (Y);
165                         if (Z < MyBounds.ZMin) MyBounds.ZMin    = Standard_ShortReal (Z);
166                         if (X > MyBounds.XMax) MyBounds.XMax    = Standard_ShortReal (X);
167                         if (Y > MyBounds.YMax) MyBounds.YMax    = Standard_ShortReal (Y);
168                         if (Z > MyBounds.ZMax) MyBounds.ZMax    = Standard_ShortReal (Z);
169                 }
170         }
171
172         MyGraphicDriver->Polygon
173                 (MyCGroup, ListVertex, Normal, AType, EvalMinMax);
174
175         Update ();
176
177 }
178
179 void Graphic3d_Group::PolygonSet (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) {
180
181         if (IsDeleted ()) return;
182
183         if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
184         MyContainsFacet = Standard_True;
185         MyIsEmpty       = Standard_False;
186
187 Standard_Real X, Y, Z;
188
189 Standard_Integer i, ii;
190 Standard_Integer j;
191 Standard_Integer begin_points;
192 Standard_Integer end_points;
193 Standard_Integer nbpoints;
194 Standard_Integer Lower, Upper;
195
196         begin_points    = ListVertex.Lower ();
197         end_points      = ListVertex.Upper ();
198
199         Lower   = Bounds.Lower ();
200         Upper   = Bounds.Upper ();
201
202         // Parcours des facettes
203         for (j=Lower; j<=Upper; j++) {
204                 nbpoints        = Bounds.Value (j);
205
206                 Graphic3d_Array1OfVertex ListOfVertex (0, nbpoints-1);
207
208                 // Parcours des sommets
209                 for (i=0, ii=begin_points;
210                         ((ii<=end_points) && (i<=nbpoints-1)); i++, ii++) {
211                         ListVertex (ii).Coord (X, Y, Z);
212                         ListOfVertex (i).SetCoord (X, Y, Z);
213                 }
214
215                 Polygon (ListOfVertex, AType, EvalMinMax);
216                 begin_points += nbpoints;
217         }
218
219 }
220
221 void Graphic3d_Group::Polygon (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertex& ListVertex, const Standard_Boolean EvalMinMax) {
222
223         if (IsDeleted ()) return;
224
225         if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
226         MyContainsFacet = Standard_True;
227         MyIsEmpty       = Standard_False;
228
229         // Min-Max Update
230         if (EvalMinMax) {
231                 Standard_Real X, Y, Z;
232                 Standard_Integer i, ii;
233                 Standard_Integer k, kk;
234                 Standard_Integer begin_points;
235                 Standard_Integer end_points;
236                 Standard_Integer Lower, Upper;
237
238                 begin_points    = ListVertex.Lower ();
239                 end_points      = ListVertex.Upper ();
240
241                 Lower   = Bounds.Lower ();
242                 Upper   = Bounds.Upper ();
243                 // Parcours des facettes
244                 for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
245                         // Parcours des sommets
246                         for (i=0, ii=begin_points;
247                         ((ii<=end_points) || (i==int (Bounds.Value (kk))-1));
248                                                                 i++, ii++) {
249                                 ListVertex (ii).Coord (X, Y, Z);
250
251                                 if (X < MyBounds.XMin) MyBounds.XMin    = Standard_ShortReal (X);
252                                 if (Y < MyBounds.YMin) MyBounds.YMin    = Standard_ShortReal (Y);
253                                 if (Z < MyBounds.ZMin) MyBounds.ZMin    = Standard_ShortReal (Z);
254                                 if (X > MyBounds.XMax) MyBounds.XMax    = Standard_ShortReal (X);
255                                 if (Y > MyBounds.YMax) MyBounds.YMax    = Standard_ShortReal (Y);
256                                 if (Z > MyBounds.ZMax) MyBounds.ZMax    = Standard_ShortReal (Z);
257                         }
258                         begin_points += int (Bounds.Value (kk));
259                 }
260         }
261
262         MyGraphicDriver->PolygonHoles
263                 (MyCGroup, Bounds, ListVertex, EvalMinMax);
264
265         Update ();
266
267 }
268
269 void Graphic3d_Group::Polygon (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_Vector& Normal, const Standard_Boolean EvalMinMax) {
270
271         if (IsDeleted ()) return;
272
273         if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
274         MyContainsFacet = Standard_True;
275         MyIsEmpty       = Standard_False;
276
277         // Min-Max Update
278         if (EvalMinMax) {
279                 Standard_Real X, Y, Z;
280                 Standard_Integer i, ii;
281                 Standard_Integer k, kk;
282                 Standard_Integer begin_points;
283                 Standard_Integer end_points;
284                 Standard_Integer Lower, Upper;
285
286                 begin_points    = ListVertex.Lower ();
287                 end_points      = ListVertex.Upper ();
288
289                 Lower   = Bounds.Lower ();
290                 Upper   = Bounds.Upper ();
291                 // Parcours des facettes
292                 for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
293                         // Parcours des sommets
294                         for (i=0, ii=begin_points;
295                         ((ii<=end_points) || (i==int (Bounds.Value (kk))-1));
296                                                                 i++, ii++) {
297                                 ListVertex (ii).Coord (X, Y, Z);
298
299                                 if (X < MyBounds.XMin) MyBounds.XMin    = Standard_ShortReal (X);
300                                 if (Y < MyBounds.YMin) MyBounds.YMin    = Standard_ShortReal (Y);
301                                 if (Z < MyBounds.ZMin) MyBounds.ZMin    = Standard_ShortReal (Z);
302                                 if (X > MyBounds.XMax) MyBounds.XMax    = Standard_ShortReal (X);
303                                 if (Y > MyBounds.YMax) MyBounds.YMax    = Standard_ShortReal (Y);
304                                 if (Z > MyBounds.ZMax) MyBounds.ZMax    = Standard_ShortReal (Z);
305                         }
306                         begin_points += int (Bounds.Value (kk));
307                 }
308         }
309
310         MyGraphicDriver->PolygonHoles
311                 (MyCGroup, Bounds, ListVertex, Normal, EvalMinMax);
312
313         Update ();
314
315 }
316
317 void Graphic3d_Group::Polygon (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertexN& ListVertex, const Standard_Boolean EvalMinMax) {
318
319         if (IsDeleted ()) return;
320
321         if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
322         MyContainsFacet = Standard_True;
323         MyIsEmpty       = Standard_False;
324
325         // Min-Max Update
326         if (EvalMinMax) {
327                 Standard_Real X, Y, Z;
328                 Standard_Integer i, ii;
329                 Standard_Integer k, kk;
330                 Standard_Integer begin_points;
331                 Standard_Integer end_points;
332                 Standard_Integer Lower, Upper;
333
334                 begin_points    = ListVertex.Lower ();
335                 end_points      = ListVertex.Upper ();
336
337                 Lower   = Bounds.Lower ();
338                 Upper   = Bounds.Upper ();
339                 // Parcours des facettes
340                 for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
341                         // Parcours des sommets
342                         for (i=0, ii=begin_points;
343                         ((ii<=end_points) || (i==int (Bounds.Value (kk))-1));
344                                                                 i++, ii++) {
345                                 ListVertex (ii).Coord (X, Y, Z);
346                                 if (X < MyBounds.XMin) MyBounds.XMin    = Standard_ShortReal (X);
347                                 if (Y < MyBounds.YMin) MyBounds.YMin    = Standard_ShortReal (Y);
348                                 if (Z < MyBounds.ZMin) MyBounds.ZMin    = Standard_ShortReal (Z);
349                                 if (X > MyBounds.XMax) MyBounds.XMax    = Standard_ShortReal (X);
350                                 if (Y > MyBounds.YMax) MyBounds.YMax    = Standard_ShortReal (Y);
351                                 if (Z > MyBounds.ZMax) MyBounds.ZMax    = Standard_ShortReal (Z);
352                         }
353                         begin_points += int (Bounds.Value (kk));
354                 }
355         }
356
357         MyGraphicDriver->PolygonHoles
358                 (MyCGroup, Bounds, ListVertex, EvalMinMax);
359
360         Update ();
361
362 }
363
364 void Graphic3d_Group::Polygon (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertexN& ListVertex, const Graphic3d_Vector& Normal, const Standard_Boolean EvalMinMax) {
365
366         if (IsDeleted ()) return;
367
368         if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
369         MyContainsFacet = Standard_True;
370         MyIsEmpty       = Standard_False;
371
372         // Min-Max Update
373         if (EvalMinMax) {
374                 Standard_Real X, Y, Z;
375                 Standard_Integer i, ii;
376                 Standard_Integer k, kk;
377                 Standard_Integer begin_points;
378                 Standard_Integer end_points;
379                 Standard_Integer Lower, Upper;
380
381                 begin_points    = ListVertex.Lower ();
382                 end_points      = ListVertex.Upper ();
383
384                 Lower   = Bounds.Lower ();
385                 Upper   = Bounds.Upper ();
386                 // Parcours des facettes
387                 for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
388                         // Parcours des sommets
389                         for (i=0, ii=begin_points;
390                         ((ii<=end_points) || (i==int (Bounds.Value (kk))-1));
391                                                                 i++, ii++) {
392                                 ListVertex (ii).Coord (X, Y, Z);
393                                 if (X < MyBounds.XMin) MyBounds.XMin    = Standard_ShortReal (X);
394                                 if (Y < MyBounds.YMin) MyBounds.YMin    = Standard_ShortReal (Y);
395                                 if (Z < MyBounds.ZMin) MyBounds.ZMin    = Standard_ShortReal (Z);
396                                 if (X > MyBounds.XMax) MyBounds.XMax    = Standard_ShortReal (X);
397                                 if (Y > MyBounds.YMax) MyBounds.YMax    = Standard_ShortReal (Y);
398                                 if (Z > MyBounds.ZMax) MyBounds.ZMax    = Standard_ShortReal (Z);
399                         }
400                         begin_points += int (Bounds.Value (kk));
401                 }
402         }
403
404         MyGraphicDriver->PolygonHoles
405                 (MyCGroup, Bounds, ListVertex, Normal, EvalMinMax);
406
407         Update ();
408
409 }
410
411
412
413 void Graphic3d_Group::Polygon(const Graphic3d_Array1OfVertexNT& ListVertex,const Graphic3d_TypeOfPolygon AType,const Standard_Boolean EvalMinMax) 
414 {
415
416         if (IsDeleted ()) return;
417
418         if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
419         MyContainsFacet = Standard_True;
420         MyIsEmpty       = Standard_False;
421
422         // Min-Max Update
423         if (EvalMinMax) {
424                 Standard_Real X, Y, Z;
425                 Standard_Integer i;
426                 Standard_Integer Lower  = ListVertex.Lower ();
427                 Standard_Integer Upper  = ListVertex.Upper ();
428                 // Parcours des sommets
429                 for (i=Lower; i<=Upper; i++) {
430                         ListVertex (i).Coord (X, Y, Z);
431                         if (X < MyBounds.XMin) MyBounds.XMin    = Standard_ShortReal (X);
432                         if (Y < MyBounds.YMin) MyBounds.YMin    = Standard_ShortReal (Y);
433                         if (Z < MyBounds.ZMin) MyBounds.ZMin    = Standard_ShortReal (Z);
434                         if (X > MyBounds.XMax) MyBounds.XMax    = Standard_ShortReal (X);
435                         if (Y > MyBounds.YMax) MyBounds.YMax    = Standard_ShortReal (Y);
436                         if (Z > MyBounds.ZMax) MyBounds.ZMax    = Standard_ShortReal (Z);
437                 }
438         }
439
440         MyGraphicDriver->Polygon (MyCGroup, ListVertex, AType, EvalMinMax);
441
442         Update ();
443
444 }