1 // Created by: NW,JPB,CAL
2 // Copyright (c) 1991-1999 Matra Datavision
3 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
22 // 27/08/97 ; PCT : ajout coordonnee texture
27 //-Design Declaration des variables specifiques aux groupes
30 //-Warning Un groupe est defini dans une structure
31 // Il s'agit de la plus petite entite editable
40 #include <Graphic3d_Group.jxx>
41 #include <Graphic3d_Group.pxx>
43 #include <Graphic3d_VertexN.hxx>
44 #include <Graphic3d_VertexNT.hxx>
48 void Graphic3d_Group::Polygon (const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) {
50 if (IsDeleted ()) return;
52 if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
53 MyContainsFacet = Standard_True;
54 MyIsEmpty = Standard_False;
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);
75 MyGraphicDriver->Polygon (MyCGroup, ListVertex, AType, EvalMinMax);
81 void Graphic3d_Group::Polygon (const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_Vector& Normal, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) {
83 if (IsDeleted ()) return;
85 if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
86 MyContainsFacet = Standard_True;
87 MyIsEmpty = Standard_False;
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);
107 MyGraphicDriver->Polygon
108 (MyCGroup, ListVertex, Normal, AType, EvalMinMax);
114 void Graphic3d_Group::Polygon (const Graphic3d_Array1OfVertexN& ListVertex, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) {
116 if (IsDeleted ()) return;
118 if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
119 MyContainsFacet = Standard_True;
120 MyIsEmpty = Standard_False;
124 Standard_Real X, Y, Z;
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);
140 MyGraphicDriver->Polygon (MyCGroup, ListVertex, AType, EvalMinMax);
146 void Graphic3d_Group::Polygon (const Graphic3d_Array1OfVertexN& ListVertex, const Graphic3d_Vector& Normal, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) {
148 if (IsDeleted ()) return;
150 if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
151 MyContainsFacet = Standard_True;
152 MyIsEmpty = Standard_False;
156 Standard_Real X, Y, Z;
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);
172 MyGraphicDriver->Polygon
173 (MyCGroup, ListVertex, Normal, AType, EvalMinMax);
179 void Graphic3d_Group::PolygonSet (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) {
181 if (IsDeleted ()) return;
183 if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
184 MyContainsFacet = Standard_True;
185 MyIsEmpty = Standard_False;
187 Standard_Real X, Y, Z;
189 Standard_Integer i, ii;
191 Standard_Integer begin_points;
192 Standard_Integer end_points;
193 Standard_Integer nbpoints;
194 Standard_Integer Lower, Upper;
196 begin_points = ListVertex.Lower ();
197 end_points = ListVertex.Upper ();
199 Lower = Bounds.Lower ();
200 Upper = Bounds.Upper ();
202 // Parcours des facettes
203 for (j=Lower; j<=Upper; j++) {
204 nbpoints = Bounds.Value (j);
206 Graphic3d_Array1OfVertex ListOfVertex (0, nbpoints-1);
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);
215 Polygon (ListOfVertex, AType, EvalMinMax);
216 begin_points += nbpoints;
221 void Graphic3d_Group::Polygon (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertex& ListVertex, const Standard_Boolean EvalMinMax) {
223 if (IsDeleted ()) return;
225 if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
226 MyContainsFacet = Standard_True;
227 MyIsEmpty = Standard_False;
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;
238 begin_points = ListVertex.Lower ();
239 end_points = ListVertex.Upper ();
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));
249 ListVertex (ii).Coord (X, Y, Z);
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);
258 begin_points += int (Bounds.Value (kk));
262 MyGraphicDriver->PolygonHoles
263 (MyCGroup, Bounds, ListVertex, EvalMinMax);
269 void Graphic3d_Group::Polygon (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_Vector& Normal, const Standard_Boolean EvalMinMax) {
271 if (IsDeleted ()) return;
273 if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
274 MyContainsFacet = Standard_True;
275 MyIsEmpty = Standard_False;
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;
286 begin_points = ListVertex.Lower ();
287 end_points = ListVertex.Upper ();
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));
297 ListVertex (ii).Coord (X, Y, Z);
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);
306 begin_points += int (Bounds.Value (kk));
310 MyGraphicDriver->PolygonHoles
311 (MyCGroup, Bounds, ListVertex, Normal, EvalMinMax);
317 void Graphic3d_Group::Polygon (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertexN& ListVertex, const Standard_Boolean EvalMinMax) {
319 if (IsDeleted ()) return;
321 if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
322 MyContainsFacet = Standard_True;
323 MyIsEmpty = Standard_False;
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;
334 begin_points = ListVertex.Lower ();
335 end_points = ListVertex.Upper ();
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));
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);
353 begin_points += int (Bounds.Value (kk));
357 MyGraphicDriver->PolygonHoles
358 (MyCGroup, Bounds, ListVertex, EvalMinMax);
364 void Graphic3d_Group::Polygon (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertexN& ListVertex, const Graphic3d_Vector& Normal, const Standard_Boolean EvalMinMax) {
366 if (IsDeleted ()) return;
368 if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
369 MyContainsFacet = Standard_True;
370 MyIsEmpty = Standard_False;
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;
381 begin_points = ListVertex.Lower ();
382 end_points = ListVertex.Upper ();
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));
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);
400 begin_points += int (Bounds.Value (kk));
404 MyGraphicDriver->PolygonHoles
405 (MyCGroup, Bounds, ListVertex, Normal, EvalMinMax);
413 void Graphic3d_Group::Polygon(const Graphic3d_Array1OfVertexNT& ListVertex,const Graphic3d_TypeOfPolygon AType,const Standard_Boolean EvalMinMax)
416 if (IsDeleted ()) return;
418 if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1);
419 MyContainsFacet = Standard_True;
420 MyIsEmpty = Standard_False;
424 Standard_Real X, Y, Z;
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);
440 MyGraphicDriver->Polygon (MyCGroup, ListVertex, AType, EvalMinMax);