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 deferred class ArrayOfPrimitives from Graphic3d inherits TShared
17 ---Purpose: This class furnish services to defined and fill an
18 -- array of primitives compatible with the use of
19 -- the OPENGl glDrawArrays() or glDrawElements() functions.
20 -- NOTE that the main goal of this kind of primitive
21 -- is to avoid multiple copies of datas between
22 -- each layer of the software.
23 -- So the array datas exist only one time and the use
24 -- of SetXxxxxx() methods enable to change dynamically
25 -- the aspect of this primitive.
28 -- 1) Decrease strongly the loading time.
29 -- 2) Decrease strongly the display time using optimized Opengl
31 -- 3) Enable to change dynamically the components of the primitive
32 -- (vertice,normal,color,texture coordinates).
33 -- 4) Add true triangle and quadrangle strips or fans capabilities.
37 TypeOfPrimitiveArray from Graphic3d,
38 PrimitiveArray from Graphic3d,
45 OutOfRange from Standard,
46 InitialisationError from Graphic3d
52 aType: TypeOfPrimitiveArray from Graphic3d;
53 maxVertexs: Integer from Standard;
54 maxBounds: Integer from Standard;
55 maxEdges: Integer from Standard;
56 hasVNormals: Boolean from Standard;
57 hasVColors: Boolean from Standard;
58 hasBColors: Boolean from Standard;
59 hasTexels: Boolean from Standard;
60 hasEdgeInfos: Boolean from Standard)
61 returns mutable ArrayOfPrimitives from Graphic3d
62 raises InitialisationError from Graphic3d;
64 -- You must use a coherent set of AddVertex() methods according to the
65 -- <hasVNormals>,<hasVColors>,<hasVTexels>,<hasBColors>
66 -- User is responsible of confuse vertex and bad normal orientation.
67 -- You must use AddBound() method only if the <maxBounds>
68 -- constructor parameter is > 0.
69 -- You must use AddEdge() method only if the <maxEdges>
70 -- constructor parameter is > 0.
71 -- You must use a coherent set of AddEdge() methods according to the
72 -- <hasEdgeInfos> constructor parameter.
74 Destroy( me: mutable);
78 -- -------------------------------------------------------------------
79 -- Methods to fill array
80 -- -------------------------------------------------------------------
82 AddVertex( me:mutable;
83 aVertice: Pnt from gp)
84 returns Integer from Standard
86 ---Purpose: Adds a vertice in the array.
87 -- returns the actual vertex number.
88 raises OutOfRange from Standard;
89 -- if the actual vertex number is >= <maxVertexs>
92 AddVertex( me:mutable;
93 X,Y,Z: Real from Standard)
94 returns Integer from Standard
96 ---Purpose: Adds a vertice in the array.
97 -- returns the actual vertex number.
98 raises OutOfRange from Standard;
99 -- if the actual vertex number is >= <maxVertexs>
102 AddVertex( me:mutable;
103 X,Y,Z: ShortReal from Standard)
104 returns Integer from Standard
106 ---Purpose: Adds a vertice in the array.
107 -- returns the actual vertex number.
108 raises OutOfRange from Standard;
109 -- if the actual vertex number is >= <maxVertexs>
111 AddVertex( me:mutable;
112 aVertice: Pnt from gp;
113 aColor: Color from Quantity)
114 returns Integer from Standard
116 ---Purpose: Adds a vertice and vertex color in the vertex array.
117 -- returns the actual vertex number.
118 -- Warning: <aColor> is ignored when the <hasVColors>
119 -- constructor parameter is FALSE
120 raises OutOfRange from Standard;
121 -- if the actual vertex number is >= <maxVertexs>
123 AddVertex( me : mutable;
124 aVertice : Pnt from gp;
125 aColor : Integer from Standard)
126 returns Integer from Standard
128 ---Purpose: Adds a vertice and vertex color in the vertex array.
129 -- returns the actual vertex number.
130 -- Warning: <aColor> is ignored when the <hasVColors>
131 -- constructor parameter is FALSE
132 -- aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
133 -- On all architecture proccers type (x86 or SPARC) you can
134 -- use this byte order.
135 raises OutOfRange from Standard;
136 -- if the actual vertex number is >= <maxVertexs>
138 AddVertex( me :mutable;
139 aVertice : Pnt from gp;
140 aNormal : Dir from gp)
141 returns Integer from Standard
143 ---Purpose: Adds a vertice and vertex normal in the vertex array.
144 -- returns the actual vertex number.
145 -- Warning: <aNormal> is ignored when the <hasVNormals>
146 -- constructor parameter is FALSE.
147 raises OutOfRange from Standard;
148 -- if the actual vertex number is >= <maxVertexs>
151 AddVertex( me:mutable;
152 X,Y,Z: Real from Standard;
153 NX,NY,NZ: Real from Standard)
154 returns Integer from Standard
156 ---Purpose: Adds a vertice and vertex normal in the vertex array.
157 -- returns the actual vertex number.
158 -- Warning: <aNormal> is ignored when the <hasVNormals>
159 -- constructor parameter is FALSE.
160 raises OutOfRange from Standard;
161 -- if the actual vertex number is >= <maxVertexs>
164 AddVertex( me:mutable;
165 X,Y,Z: ShortReal from Standard;
166 NX,NY,NZ: ShortReal from Standard)
167 returns Integer from Standard
169 ---Purpose: Adds a vertice and vertex normal in the vertex array.
170 -- returns the actual vertex number.
171 -- Warning: <aNormal> is ignored when the <hasVNormals>
172 -- constructor parameter is FALSE.
173 raises OutOfRange from Standard;
174 -- if the actual vertex number is >= <maxVertexs>
176 AddVertex( me:mutable;
177 aVertice: Pnt from gp;
178 aNormal: Dir from gp;
179 aColor: Color from Quantity)
180 returns Integer from Standard
182 ---Purpose: Adds a vertice,vertex normal and color in the vertex array.
183 -- returns the actual vertex number.
184 -- Warning: <aNormal> is ignored when the <hasVNormals>
185 -- constructor parameter is FALSE.
186 -- <aColor> is ignored when the <hasVColors>
187 -- constructor parameter is FALSE
188 raises OutOfRange from Standard;
189 -- if the actual vertex number is >= <maxVertexs>
191 AddVertex( me : mutable;
192 aVertice : Pnt from gp;
193 aNormal : Dir from gp;
194 aColor : Integer from Standard)
195 returns Integer from Standard
197 ---Purpose: Adds a vertice,vertex normal and color in the vertex array.
198 -- returns the actual vertex number.
199 -- Warning: <aNormal> is ignored when the <hasVNormals>
200 -- constructor parameter is FALSE.
201 -- <aColor> is ignored when the <hasVColors>
202 -- constructor parameter is FALSE
203 -- aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
204 -- On all architecture proccers type (x86 or SPARC) you can
205 -- use this byte order.
206 raises OutOfRange from Standard;
207 -- if the actual vertex number is >= <maxVertexs>
209 AddVertex( me:mutable;
210 aVertice: Pnt from gp;
211 aTexel: Pnt2d from gp)
212 returns Integer from Standard
214 ---Purpose: Adds a vertice and vertex texture in the vertex array.
215 -- returns the actual vertex number.
216 -- <aTexel> is ignored when the <hasVTexels>
217 -- constructor parameter is FALSE.
218 raises OutOfRange from Standard;
219 -- if the actual vertex number is >= <maxVertexs>
222 AddVertex( me:mutable;
223 X,Y,Z: Real from Standard;
224 TX,TY: Real from Standard)
225 returns Integer from Standard
227 ---Purpose: Adds a vertice and vertex texture coordinates in the vertex array.
228 -- returns the actual vertex number.
229 -- <aTexel> is ignored when the <hasVTexels>
230 -- constructor parameter is FALSE.
231 raises OutOfRange from Standard;
232 -- if the actual vertex number is >= <maxVertexs>
235 AddVertex( me:mutable;
236 X,Y,Z: ShortReal from Standard;
237 TX,TY: ShortReal from Standard)
238 returns Integer from Standard
240 ---Purpose: Adds a vertice and vertex texture coordinates in the vertex array.
241 -- returns the actual vertex number.
242 -- <aTexel> is ignored when the <hasVTexels>
243 -- constructor parameter is FALSE.
244 raises OutOfRange from Standard;
245 -- if the actual vertex number is >= <maxVertexs>
247 AddVertex( me:mutable;
248 aVertice: Pnt from gp;
249 aNormal: Dir from gp;
250 aTexel: Pnt2d from gp)
251 returns Integer from Standard
253 ---Purpose: Adds a vertice,vertex normal and texture in the vertex array.
254 -- returns the actual vertex number.
255 -- Warning: <aNormal> is ignored when the <hasVNormals>
256 -- constructor parameter is FALSE.
257 -- <aTexel> is ignored when the <hasVTexels>
258 -- constructor parameter is FALSE.
259 raises OutOfRange from Standard;
260 -- if the actual vertex number is >= <maxVertexs>
263 AddVertex( me:mutable;
264 X,Y,Z: Real from Standard;
265 NX,NY,NZ: Real from Standard;
266 TX,TY: Real from Standard)
267 returns Integer from Standard
269 ---Purpose: Adds a vertice,vertex normal and texture in the vertex array.
270 -- returns the actual vertex number.
271 -- Warning: <aNormal> is ignored when the <hasVNormals>
272 -- constructor parameter is FALSE.
273 -- <aTexel> is ignored when the <hasVTexels>
274 -- constructor parameter is FALSE.
275 raises OutOfRange from Standard;
276 -- if the actual vertex number is >= <maxVertexs>
279 AddVertex( me:mutable;
280 X,Y,Z: ShortReal from Standard;
281 NX,NY,NZ: ShortReal from Standard;
282 TX,TY: ShortReal from Standard)
283 returns Integer from Standard
285 ---Purpose: Adds a vertice,vertex normal and texture in the vertex array.
286 -- returns the actual vertex number.
287 -- Warning: <aNormal> is ignored when the <hasVNormals>
288 -- constructor parameter is FALSE.
289 -- <aTexel> is ignored when the <hasVTexels>
290 -- constructor parameter is FALSE.
291 raises OutOfRange from Standard;
292 -- if the actual vertex number is >= <maxVertexs>
294 AddBound( me:mutable;
295 edgeNumber: Integer from Standard)
296 returns Integer from Standard
298 ---Purpose: Adds a bound of length <edgeNumber> in the bound array
299 -- returns the actual bounds number.
300 raises OutOfRange from Standard;
301 -- if the actual Bound number is >= <maxBounds>
303 AddBound( me:mutable;
304 edgeNumber: Integer from Standard;
305 aBColor: Color from Quantity)
306 returns Integer from Standard
308 ---Purpose: Adds a bound of length <edgeNumber> and bound color
309 -- <aBColor> in the bound array.
310 -- returns the actual bounds number.
311 -- Warning: <aBColor> is ignored when the <hasBColors>
312 -- constructor parameter is FALSE
313 raises OutOfRange from Standard;
314 -- if the actual Bound number is >= <maxBounds>
316 AddBound( me:mutable;
317 edgeNumber: Integer from Standard;
318 R,G,B: Real from Standard)
319 returns Integer from Standard
321 ---Purpose: Adds a bound of length <edgeNumber> and bound color
322 -- coordinates in the bound array.
323 -- returns the actual bounds number.
324 -- Warning: <R,G,B> are ignored when the <hasBColors>
325 -- constructor parameter is FALSE
326 raises OutOfRange from Standard;
327 -- if the actual Bound number is >= <maxBounds>
330 vertexIndex: Integer from Standard;
331 isVisible: Boolean from Standard = Standard_True)
332 returns Integer from Standard
334 ---Purpose: Adds an edge in the range [1,VertexNumber()] in the array,
335 -- if <isVisible> is FALSE the edge between <vertexIndex> and
336 -- the next edge will not be visible even if the SetEdgeOn() method
337 -- is activated in Graphic3d_AspectFillArea3d class.
338 -- returns the actual edges number.
339 -- Warning: <isVisible> is ignored when the <hasEdgeInfos>
340 -- constructor parameter is FALSE.
341 raises OutOfRange from Standard;
342 -- if the actual edge number is >= <maxEdges>
344 -- -------------------------------------------------------------------
345 -- Methods to modify the array
346 -- -------------------------------------------------------------------
348 Orientate( me:mutable;
349 aNormal: Dir from gp)
350 returns Boolean from Standard;
352 ---Purpose: Orientate correctly all vertexs & normals of this array
353 -- according to the <aNormal> parameter and
354 -- returns TRUE when something has change in the array.
355 -- Warning: When the array has edges this method is apply
356 -- on edge sub array instead on vertex sub array.
358 Orientate( me:mutable;
359 aVertexIndex: Integer from Standard;
360 aVertexNumber: Integer from Standard;
361 aNormal: Dir from gp)
362 returns Boolean from Standard
364 ---Purpose: Orientate correctly a set of vertexs & normal
365 -- from <aVertexIndex> to <aVertexIndex>+<aVertexNumber>-1
366 -- according to the <aNormal> parameter and
367 -- returns TRUE when something has change in the array.
368 -- Warning: When the array has edges this method is apply
369 -- on edge sub array instead on vertex sub array.
370 raises OutOfRange from Standard is private;
371 -- if the <aVertexIndex> parameter is < 1 or > VertexNumber() or
374 Orientate( me:mutable;
375 aBoundIndex: Integer from Standard;
376 aNormal: Dir from gp)
377 returns Boolean from Standard
379 ---Purpose: Orientate correctly all vertexs & normal of the bound <aBound>
380 -- according to the <aNormal> parameter and
381 -- returns TRUE when something has change in the array.
382 -- Warning: When the array has edges this method is apply
383 -- on edge sub array instead on vertex sub array.
384 -- When this array has no bound, <aBoundIndex> design the item number
385 raises OutOfRange from Standard;
386 -- if the <aBoundIndex> parameter is < 1 or > BoundNumber()
387 -- or if the <aBoundIndex> parameter is < 1 or > ItemNumber()
389 SetVertice( me:mutable;
390 anIndex: Integer from Standard;
391 aVertice: Pnt from gp)
393 ---Purpose: Change the vertice of rank <anIndex> in the array.
394 raises OutOfRange from Standard;
395 -- if the index is <1 or > VertexNumber()
397 SetVertice( me:mutable;
398 anIndex: Integer from Standard;
399 X,Y,Z: ShortReal from Standard)
401 ---Purpose: Change the vertice of rank <anIndex> in the array.
402 raises OutOfRange from Standard;
403 -- if the index is <1 or > VertexNumber()
406 SetVertexColor( me : mutable;
407 anIndex : Integer from Standard;
408 aColor : Color from Quantity)
410 ---Purpose: Change the vertex color of rank <anIndex> in the array.
411 raises OutOfRange from Standard;
412 -- if the index is <1 or > VertexNumber()
414 SetVertexColor( me : mutable;
415 anIndex : Integer from Standard;
416 R,G,B : Real from Standard)
418 ---Purpose: Change the vertex color of rank <anIndex> in the array.
419 raises OutOfRange from Standard;
420 -- if the index is <1 or > VertexNumber()
423 SetVertexColor( me : mutable;
424 anIndex : Integer from Standard;
425 aColor : Integer from Standard)
427 ---Purpose: Change the vertex color of rank <anIndex> in the array.
428 -- aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
429 -- On all architecture proccers type (x86 or SPARC) you can
430 -- use this byte order.
431 raises OutOfRange from Standard;
432 -- if the index is <1 or > VertexNumber()
435 SetVertexNormal( me : mutable;
436 anIndex : Integer from Standard;
437 aNormal : Dir from gp)
439 ---Purpose: Change the vertex normal of rank <anIndex> in the array.
440 raises OutOfRange from Standard;
441 -- if the index is <1 or > VertexNumber()
443 SetVertexNormal( me : mutable;
444 anIndex : Integer from Standard;
445 NX,NY,NZ: Real from Standard)
447 ---Purpose: Change the vertex normal of rank <anIndex> in the array.
448 raises OutOfRange from Standard;
449 -- if the index is <1 or > VertexNumber()
452 SetVertexTexel( me:mutable;
453 anIndex: Integer from Standard;
454 aTexel: Pnt2d from gp)
456 ---Purpose: Change the vertex texel of rank <anIndex> in the array.
457 raises OutOfRange from Standard;
458 -- if the index is <1 or > VertexNumber()
460 SetVertexTexel( me:mutable;
461 anIndex: Integer from Standard;
462 TX,TY: Real from Standard)
464 ---Purpose: Change the vertex texel of rank <anIndex> in the array.
465 raises OutOfRange from Standard;
466 -- if the index is <1 or > VertexNumber()
469 SetBoundColor( me:mutable;
470 anIndex: Integer from Standard;
471 aColor: Color from Quantity)
473 ---Purpose: Change the bound color of rank <anIndex> in the array.
474 raises OutOfRange from Standard;
475 -- if the index is <1 or > BoundNumber()
477 SetBoundColor( me:mutable;
478 anIndex: Integer from Standard;
479 R,G,B: Real from Standard)
481 ---Purpose: Change the bound color of rank <anIndex> in the array.
482 raises OutOfRange from Standard;
483 -- if the index is <1 or > BoundNumber()
486 -------------------------------------------------------------------
487 -- Category Inquiries on array
488 -------------------------------------------------------------------
491 returns PrimitiveArray from Graphic3d;
493 ---Purpose: Returns the array address.
497 returns TypeOfPrimitiveArray from Graphic3d;
499 ---Purpose: Returns the type of this primitive
503 returns CString from Standard;
505 ---Purpose: Returns the string type of this primitive
507 HasVertexNormals( me )
508 returns Boolean from Standard;
510 ---Purpose: Returns TRUE when vertex normals array is defined.
513 HasVertexColors( me )
514 returns Boolean from Standard;
516 ---Purpose: Returns TRUE when vertex colors array is defined.
519 HasVertexTexels( me )
520 returns Boolean from Standard;
522 ---Purpose: Returns TRUE when vertex texels array is defined.
526 returns Integer from Standard;
528 ---Purpose: Returns the number of defined vertex
531 Vertice( me ; aRank: Integer from Standard)
534 ---Purpose: Returns the vertice at rank <aRank>
535 -- from the vertex table if defined.
536 raises OutOfRange from Standard;
537 -- when the rank is < 1 or > VertexNumber().
539 Vertice( me ; aRank: Integer from Standard;
540 X,Y,Z: out Real from Standard)
542 ---Purpose: Returns the vertice coordinates at rank <aRank>
543 -- from the vertex table if defined.
544 raises OutOfRange from Standard;
545 -- when the rank is < 1 or > VertexNumber().
548 VertexColor( me ; aRank: Integer from Standard)
549 returns Color from Quantity
551 ---Purpose: Returns the vertex color at rank <aRank>
552 -- from the vertex table if defined.
553 raises OutOfRange from Standard;
554 -- when the rank is < 1 or > VertexNumber().
556 VertexColor( me ; aRank : Integer from Standard;
557 R, G, B : out Real from Standard)
559 ---Purpose: Returns the vertex color values at rank <aRank>
560 -- from the vertex table if defined.
561 raises OutOfRange from Standard;
562 -- when the rank is < 1 or > VertexNumber().
565 VertexColor( me ; aRank: Integer from Standard;
566 aColor: out Integer from Standard)
568 ---Purpose: Returns the vertex color values at rank <aRank>
569 -- from the vertex table if defined.
570 raises OutOfRange from Standard;
571 -- when the rank is < 1 or > VertexNumber().
575 VertexNormal( me ; aRank: Integer from Standard)
578 ---Purpose: Returns the vertex normal at rank <aRank>
579 -- from the vertex table if defined.
580 raises OutOfRange from Standard;
581 -- when the rank is < 1 or > VertexNumber().
583 VertexNormal( me ; aRank: Integer from Standard;
584 NX,NY,NZ: out Real from Standard)
586 ---Purpose: Returns the vertex normal coordinates at rank <aRank>
587 -- from the vertex table if defined.
588 raises OutOfRange from Standard;
589 -- when the rank is < 1 or > VertexNumber().
592 VertexTexel( me ; aRank: Integer from Standard)
593 returns Pnt2d from gp
595 ---Purpose: Returns the vertex texture at rank <aRank>
596 -- from the vertex table if defined.
597 raises OutOfRange from Standard;
598 -- when the rank is < 1 or > VertexNumber().
600 VertexTexel( me ; aRank: Integer from Standard;
601 TX,TY: out Real from Standard)
603 ---Purpose: Returns the vertex texture coordinates at rank <aRank>
604 -- from the vertex table if defined.
605 raises OutOfRange from Standard;
606 -- when the rank is < 1 or > VertexNumber().
610 returns Boolean from Standard;
612 ---Purpose: Returns TRUE when edge visibillity array is defined.
616 returns Integer from Standard;
618 ---Purpose: Returns the number of defined edges
621 Edge( me ; aRank: Integer from Standard)
622 returns Integer from Standard
624 ---Purpose: Returns the vertex index at rank <aRank>
625 -- in the range [1,VertexNumber()]
626 raises OutOfRange from Standard;
627 -- when the rank is < 1 or > EdgeNumber()
630 EdgeIsVisible( me ; aRank: Integer from Standard)
631 returns Boolean from Standard
633 ---Purpose: Returns TRUE when the edge at rank <aRank>
635 raises OutOfRange from Standard;
636 -- when the rank is < 1 or > EdgeNumber()
640 returns Boolean from Standard;
642 ---Purpose: Returns TRUE when bound colors array is defined.
646 returns Integer from Standard;
648 ---Purpose: Returns the number of defined bounds
651 Bound( me ; aRank: Integer from Standard)
652 returns Integer from Standard
654 ---Purpose: Returns the edge number at rank <aRank>.
655 raises OutOfRange from Standard;
656 -- when the rank is < 1 or > BoundNumber()
659 BoundColor( me ; aRank: Integer from Standard)
660 returns Color from Quantity
662 ---Purpose: Returns the bound color at rank <aRank>
663 -- from the bound table if defined.
664 raises OutOfRange from Standard;
665 -- when the rank is < 1 or > BoundNumber()
667 BoundColor( me ; aRank: Integer from Standard;
668 R,G,B: out Real from Standard)
670 ---Purpose: Returns the bound color values at rank <aRank>
671 -- from the bound table if defined.
672 raises OutOfRange from Standard;
673 -- when the rank is < 1 or > BoundNumber()
676 returns Integer from Standard;
678 ---Purpose: Returns the number of total items according to
681 -------------------------------------------------------------------
682 -- Category Miscellaneous
683 -------------------------------------------------------------------
685 IsValid( me:mutable )
686 returns Boolean from Standard;
688 ---Purpose: Returns TRUE only when the contains of this array is
691 ComputeVNormals( me:mutable ; fromIndex,toIndex: Integer from Standard)
695 myPrimitiveArray: PrimitiveArray from Graphic3d;
696 myMaxBounds: Integer from Standard;
697 myMaxVertexs: Integer from Standard;
698 myMaxEdges: Integer from Standard;
701 class Group from Graphic3d