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 Buffer_Handle from Graphic3d,
39 BoundBuffer_Handle from Graphic3d,
40 IndexBuffer_Handle from Graphic3d,
48 OutOfRange from Standard,
49 InitialisationError from Graphic3d
55 aType: TypeOfPrimitiveArray from Graphic3d;
56 maxVertexs: Integer from Standard;
57 maxBounds: Integer from Standard;
58 maxEdges: Integer from Standard;
59 hasVNormals: Boolean from Standard;
60 hasVColors: Boolean from Standard;
61 hasBColors: Boolean from Standard;
62 hasTexels: Boolean from Standard)
63 returns ArrayOfPrimitives from Graphic3d
64 raises InitialisationError from Graphic3d;
66 -- You must use a coherent set of AddVertex() methods according to the
67 -- <hasVNormals>,<hasVColors>,<hasVTexels>,<hasBColors>
68 -- User is responsible of confuse vertex and bad normal orientation.
69 -- You must use AddBound() method only if the <maxBounds>
70 -- constructor parameter is > 0.
71 -- You must use AddEdge() method only if the <maxEdges>
72 -- constructor parameter is > 0.
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>
91 ---C++: alias "Standard_Integer AddVertex (const Graphic3d_Vec3& theVertex);"
93 AddVertex( me:mutable;
94 X,Y,Z: Real from Standard)
95 returns Integer from Standard
97 ---Purpose: Adds a vertice in the array.
98 -- returns the actual vertex number.
99 raises OutOfRange from Standard;
100 -- if the actual vertex number is >= <maxVertexs>
103 AddVertex( me:mutable;
104 X,Y,Z: ShortReal from Standard)
105 returns Integer from Standard
107 ---Purpose: Adds a vertice in the array.
108 -- returns the actual vertex number.
109 raises OutOfRange from Standard;
110 -- if the actual vertex number is >= <maxVertexs>
112 AddVertex( me:mutable;
113 aVertice: Pnt from gp;
114 aColor: Color from Quantity)
115 returns Integer from Standard
117 ---Purpose: Adds a vertice and vertex color in the vertex array.
118 -- returns the actual vertex number.
119 -- Warning: <aColor> is ignored when the <hasVColors>
120 -- constructor parameter is FALSE
121 raises OutOfRange from Standard;
122 -- if the actual vertex number is >= <maxVertexs>
124 AddVertex( me : mutable;
125 aVertice : Pnt from gp;
126 aColor : Integer from Standard)
127 returns Integer from Standard
129 ---Purpose: Adds a vertice and vertex color in the vertex array.
130 -- returns the actual vertex number.
131 -- Warning: <aColor> is ignored when the <hasVColors>
132 -- constructor parameter is FALSE
133 -- aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
134 -- On all architecture proccers type (x86 or SPARC) you can
135 -- use this byte order.
136 raises OutOfRange from Standard;
137 -- if the actual vertex number is >= <maxVertexs>
139 AddVertex( me :mutable;
140 aVertice : Pnt from gp;
141 aNormal : Dir from gp)
142 returns Integer from Standard
144 ---Purpose: Adds a vertice and vertex normal in the vertex array.
145 -- returns the actual vertex number.
146 -- Warning: <aNormal> is ignored when the <hasVNormals>
147 -- constructor parameter is FALSE.
148 raises OutOfRange from Standard;
149 -- if the actual vertex number is >= <maxVertexs>
152 AddVertex( me:mutable;
153 X,Y,Z: Real from Standard;
154 NX,NY,NZ: Real from Standard)
155 returns Integer from Standard
157 ---Purpose: Adds a vertice and vertex normal in the vertex array.
158 -- returns the actual vertex number.
159 -- Warning: <aNormal> is ignored when the <hasVNormals>
160 -- constructor parameter is FALSE.
161 raises OutOfRange from Standard;
162 -- if the actual vertex number is >= <maxVertexs>
165 AddVertex( me:mutable;
166 X,Y,Z: ShortReal from Standard;
167 NX,NY,NZ: ShortReal from Standard)
168 returns Integer from Standard
170 ---Purpose: Adds a vertice and vertex normal in the vertex array.
171 -- returns the actual vertex number.
172 -- Warning: <aNormal> is ignored when the <hasVNormals>
173 -- constructor parameter is FALSE.
174 raises OutOfRange from Standard;
175 -- if the actual vertex number is >= <maxVertexs>
177 AddVertex( me:mutable;
178 aVertice: Pnt from gp;
179 aNormal: Dir from gp;
180 aColor: Color from Quantity)
181 returns Integer from Standard
183 ---Purpose: Adds a vertice,vertex normal and color in the vertex array.
184 -- returns the actual vertex number.
185 -- Warning: <aNormal> is ignored when the <hasVNormals>
186 -- constructor parameter is FALSE.
187 -- <aColor> is ignored when the <hasVColors>
188 -- constructor parameter is FALSE
189 raises OutOfRange from Standard;
190 -- if the actual vertex number is >= <maxVertexs>
192 AddVertex( me : mutable;
193 aVertice : Pnt from gp;
194 aNormal : Dir from gp;
195 aColor : Integer from Standard)
196 returns Integer from Standard
198 ---Purpose: Adds a vertice,vertex normal and color in the vertex array.
199 -- returns the actual vertex number.
200 -- Warning: <aNormal> is ignored when the <hasVNormals>
201 -- constructor parameter is FALSE.
202 -- <aColor> is ignored when the <hasVColors>
203 -- constructor parameter is FALSE
204 -- aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
205 -- On all architecture proccers type (x86 or SPARC) you can
206 -- use this byte order.
207 raises OutOfRange from Standard;
208 -- if the actual vertex number is >= <maxVertexs>
210 AddVertex( me:mutable;
211 aVertice: Pnt from gp;
212 aTexel: Pnt2d from gp)
213 returns Integer from Standard
215 ---Purpose: Adds a vertice and vertex texture in the vertex array.
216 -- returns the actual vertex number.
217 -- <aTexel> is ignored when the <hasVTexels>
218 -- constructor parameter is FALSE.
219 raises OutOfRange from Standard;
220 -- if the actual vertex number is >= <maxVertexs>
223 AddVertex( me:mutable;
224 X,Y,Z: Real from Standard;
225 TX,TY: Real from Standard)
226 returns Integer from Standard
228 ---Purpose: Adds a vertice and vertex texture coordinates in the vertex array.
229 -- returns the actual vertex number.
230 -- <aTexel> is ignored when the <hasVTexels>
231 -- constructor parameter is FALSE.
232 raises OutOfRange from Standard;
233 -- if the actual vertex number is >= <maxVertexs>
236 AddVertex( me:mutable;
237 X,Y,Z: ShortReal from Standard;
238 TX,TY: ShortReal from Standard)
239 returns Integer from Standard
241 ---Purpose: Adds a vertice and vertex texture coordinates in the vertex array.
242 -- returns the actual vertex number.
243 -- <aTexel> is ignored when the <hasVTexels>
244 -- constructor parameter is FALSE.
245 raises OutOfRange from Standard;
246 -- if the actual vertex number is >= <maxVertexs>
248 AddVertex( me:mutable;
249 aVertice: Pnt from gp;
250 aNormal: Dir from gp;
251 aTexel: Pnt2d from gp)
252 returns Integer from Standard
254 ---Purpose: Adds a vertice,vertex normal and texture in the vertex array.
255 -- returns the actual vertex number.
256 -- Warning: <aNormal> is ignored when the <hasVNormals>
257 -- constructor parameter is FALSE.
258 -- <aTexel> is ignored when the <hasVTexels>
259 -- constructor parameter is FALSE.
260 raises OutOfRange from Standard;
261 -- if the actual vertex number is >= <maxVertexs>
264 AddVertex( me:mutable;
265 X,Y,Z: Real from Standard;
266 NX,NY,NZ: Real from Standard;
267 TX,TY: Real from Standard)
268 returns Integer from Standard
270 ---Purpose: Adds a vertice,vertex normal and texture in the vertex array.
271 -- returns the actual vertex number.
272 -- Warning: <aNormal> is ignored when the <hasVNormals>
273 -- constructor parameter is FALSE.
274 -- <aTexel> is ignored when the <hasVTexels>
275 -- constructor parameter is FALSE.
276 raises OutOfRange from Standard;
277 -- if the actual vertex number is >= <maxVertexs>
280 AddVertex( me:mutable;
281 X,Y,Z: ShortReal from Standard;
282 NX,NY,NZ: ShortReal from Standard;
283 TX,TY: ShortReal from Standard)
284 returns Integer from Standard
286 ---Purpose: Adds a vertice,vertex normal and texture in the vertex array.
287 -- returns the actual vertex number.
288 -- Warning: <aNormal> is ignored when the <hasVNormals>
289 -- constructor parameter is FALSE.
290 -- <aTexel> is ignored when the <hasVTexels>
291 -- constructor parameter is FALSE.
292 raises OutOfRange from Standard;
293 -- if the actual vertex number is >= <maxVertexs>
295 AddBound( me:mutable;
296 edgeNumber: Integer from Standard)
297 returns Integer from Standard
299 ---Purpose: Adds a bound of length <edgeNumber> in the bound array
300 -- returns the actual bounds number.
301 raises OutOfRange from Standard;
302 -- if the actual Bound number is >= <maxBounds>
304 AddBound( me:mutable;
305 edgeNumber: Integer from Standard;
306 aBColor: Color from Quantity)
307 returns Integer from Standard
309 ---Purpose: Adds a bound of length <edgeNumber> and bound color
310 -- <aBColor> in the bound array.
311 -- returns the actual bounds number.
312 -- Warning: <aBColor> is ignored when the <hasBColors>
313 -- constructor parameter is FALSE
314 raises OutOfRange from Standard;
315 -- if the actual Bound number is >= <maxBounds>
317 AddBound( me:mutable;
318 edgeNumber: Integer from Standard;
319 R,G,B: Real from Standard)
320 returns Integer from Standard
322 ---Purpose: Adds a bound of length <edgeNumber> and bound color
323 -- coordinates in the bound array.
324 -- returns the actual bounds number.
325 -- Warning: <R,G,B> are ignored when the <hasBColors>
326 -- constructor parameter is FALSE
327 raises OutOfRange from Standard;
328 -- if the actual Bound number is >= <maxBounds>
331 vertexIndex: Integer from Standard)
332 returns Integer from Standard
334 ---Purpose: Adds an edge in the range [1,VertexNumber()] in the array.
335 -- Returns the actual edges number.
336 raises OutOfRange from Standard;
337 -- if the actual edge number is >= <maxEdges>
339 -- -------------------------------------------------------------------
340 -- Methods to modify the array
341 -- -------------------------------------------------------------------
343 SetVertice( me:mutable;
344 anIndex: Integer from Standard;
345 aVertice: Pnt from gp)
347 ---Purpose: Change the vertice of rank <anIndex> in the array.
348 raises OutOfRange from Standard;
349 -- if the index is <1 or > VertexNumber()
351 SetVertice( me:mutable;
352 anIndex: Integer from Standard;
353 X,Y,Z: ShortReal from Standard)
355 ---Purpose: Change the vertice of rank <anIndex> in the array.
356 raises OutOfRange from Standard;
357 -- if the index is <1 or > VertexNumber()
360 SetVertexColor( me : mutable;
361 anIndex : Integer from Standard;
362 aColor : Color from Quantity)
364 ---Purpose: Change the vertex color of rank <anIndex> in the array.
365 raises OutOfRange from Standard;
366 -- if the index is <1 or > VertexNumber()
368 SetVertexColor( me : mutable;
369 anIndex : Integer from Standard;
370 R,G,B : Real from Standard)
372 ---Purpose: Change the vertex color of rank <anIndex> in the array.
373 raises OutOfRange from Standard;
374 -- if the index is <1 or > VertexNumber()
377 SetVertexColor( me : mutable;
378 anIndex : Integer from Standard;
379 aColor : Integer from Standard)
381 ---Purpose: Change the vertex color of rank <anIndex> in the array.
382 -- aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
383 -- On all architecture proccers type (x86 or SPARC) you can
384 -- use this byte order.
385 raises OutOfRange from Standard;
386 -- if the index is <1 or > VertexNumber()
389 SetVertexNormal( me : mutable;
390 anIndex : Integer from Standard;
391 aNormal : Dir from gp)
393 ---Purpose: Change the vertex normal of rank <anIndex> in the array.
394 raises OutOfRange from Standard;
395 -- if the index is <1 or > VertexNumber()
397 SetVertexNormal( me : mutable;
398 anIndex : Integer from Standard;
399 NX,NY,NZ: Real from Standard)
401 ---Purpose: Change the vertex normal of rank <anIndex> in the array.
402 raises OutOfRange from Standard;
403 -- if the index is <1 or > VertexNumber()
406 SetVertexTexel( me:mutable;
407 anIndex: Integer from Standard;
408 aTexel: Pnt2d from gp)
410 ---Purpose: Change the vertex texel of rank <anIndex> in the array.
411 raises OutOfRange from Standard;
412 -- if the index is <1 or > VertexNumber()
414 SetVertexTexel( me:mutable;
415 anIndex: Integer from Standard;
416 TX,TY: Real from Standard)
418 ---Purpose: Change the vertex texel of rank <anIndex> in the array.
419 raises OutOfRange from Standard;
420 -- if the index is <1 or > VertexNumber()
423 SetBoundColor( me:mutable;
424 anIndex: Integer from Standard;
425 aColor: Color from Quantity)
427 ---Purpose: Change the bound color of rank <anIndex> in the array.
428 raises OutOfRange from Standard;
429 -- if the index is <1 or > BoundNumber()
431 SetBoundColor( me:mutable;
432 anIndex: Integer from Standard;
433 R,G,B: Real from Standard)
435 ---Purpose: Change the bound color of rank <anIndex> in the array.
436 raises OutOfRange from Standard;
437 -- if the index is <1 or > BoundNumber()
440 -------------------------------------------------------------------
441 -- Category Inquiries on array
442 -------------------------------------------------------------------
445 returns IndexBuffer_Handle from Graphic3d;
446 ---Purpose: Returns optional index buffer.
448 ---C++: return const &
451 returns Buffer_Handle from Graphic3d;
452 ---Purpose: Returns vertex attributes buffer (colors, normals, texture coordinates).
454 ---C++: return const &
457 returns BoundBuffer_Handle from Graphic3d;
458 ---Purpose: Returns optional bounds buffer.
460 ---C++: return const &
463 returns TypeOfPrimitiveArray from Graphic3d;
465 ---Purpose: Returns the type of this primitive
469 returns CString from Standard;
471 ---Purpose: Returns the string type of this primitive
473 HasVertexNormals( me )
474 returns Boolean from Standard;
476 ---Purpose: Returns TRUE when vertex normals array is defined.
479 HasVertexColors( me )
480 returns Boolean from Standard;
482 ---Purpose: Returns TRUE when vertex colors array is defined.
485 HasVertexTexels( me )
486 returns Boolean from Standard;
488 ---Purpose: Returns TRUE when vertex texels array is defined.
492 returns Integer from Standard;
494 ---Purpose: Returns the number of defined vertex
497 Vertice( me ; aRank: Integer from Standard)
500 ---Purpose: Returns the vertice at rank <aRank>
501 -- from the vertex table if defined.
502 raises OutOfRange from Standard;
503 -- when the rank is < 1 or > VertexNumber().
505 Vertice( me ; aRank: Integer from Standard;
506 X,Y,Z: out Real from Standard)
508 ---Purpose: Returns the vertice coordinates at rank <aRank>
509 -- from the vertex table if defined.
510 raises OutOfRange from Standard;
511 -- when the rank is < 1 or > VertexNumber().
514 VertexColor( me ; aRank: Integer from Standard)
515 returns Color from Quantity
517 ---Purpose: Returns the vertex color at rank <aRank>
518 -- from the vertex table if defined.
519 raises OutOfRange from Standard;
520 -- when the rank is < 1 or > VertexNumber().
522 VertexColor( me ; aRank : Integer from Standard;
523 R, G, B : out Real from Standard)
525 ---Purpose: Returns the vertex color values at rank <aRank>
526 -- from the vertex table if defined.
527 raises OutOfRange from Standard;
528 -- when the rank is < 1 or > VertexNumber().
531 VertexColor( me ; aRank: Integer from Standard;
532 aColor: out Integer from Standard)
534 ---Purpose: Returns the vertex color values at rank <aRank>
535 -- from the vertex table if defined.
536 raises OutOfRange from Standard;
537 -- when the rank is < 1 or > VertexNumber().
541 VertexNormal( me ; aRank: Integer from Standard)
544 ---Purpose: Returns the vertex normal at rank <aRank>
545 -- from the vertex table if defined.
546 raises OutOfRange from Standard;
547 -- when the rank is < 1 or > VertexNumber().
549 VertexNormal( me ; aRank: Integer from Standard;
550 NX,NY,NZ: out Real from Standard)
552 ---Purpose: Returns the vertex normal coordinates at rank <aRank>
553 -- from the vertex table if defined.
554 raises OutOfRange from Standard;
555 -- when the rank is < 1 or > VertexNumber().
558 VertexTexel( me ; aRank: Integer from Standard)
559 returns Pnt2d from gp
561 ---Purpose: Returns the vertex texture at rank <aRank>
562 -- from the vertex table if defined.
563 raises OutOfRange from Standard;
564 -- when the rank is < 1 or > VertexNumber().
566 VertexTexel( me ; aRank: Integer from Standard;
567 TX,TY: out Real from Standard)
569 ---Purpose: Returns the vertex texture coordinates at rank <aRank>
570 -- from the vertex table if defined.
571 raises OutOfRange from Standard;
572 -- when the rank is < 1 or > VertexNumber().
576 returns Integer from Standard;
578 ---Purpose: Returns the number of defined edges
581 Edge( me ; aRank: Integer from Standard)
582 returns Integer from Standard
584 ---Purpose: Returns the vertex index at rank <aRank>
585 -- in the range [1,VertexNumber()]
586 raises OutOfRange from Standard;
587 -- when the rank is < 1 or > EdgeNumber()
591 returns Boolean from Standard;
593 ---Purpose: Returns TRUE when bound colors array is defined.
597 returns Integer from Standard;
599 ---Purpose: Returns the number of defined bounds
602 Bound( me ; aRank: Integer from Standard)
603 returns Integer from Standard
605 ---Purpose: Returns the edge number at rank <aRank>.
606 raises OutOfRange from Standard;
607 -- when the rank is < 1 or > BoundNumber()
610 BoundColor( me ; aRank: Integer from Standard)
611 returns Color from Quantity
613 ---Purpose: Returns the bound color at rank <aRank>
614 -- from the bound table if defined.
615 raises OutOfRange from Standard;
616 -- when the rank is < 1 or > BoundNumber()
618 BoundColor( me ; aRank: Integer from Standard;
619 R,G,B: out Real from Standard)
621 ---Purpose: Returns the bound color values at rank <aRank>
622 -- from the bound table if defined.
623 raises OutOfRange from Standard;
624 -- when the rank is < 1 or > BoundNumber()
627 returns Integer from Standard;
629 ---Purpose: Returns the number of total items according to
632 -------------------------------------------------------------------
633 -- Category Miscellaneous
634 -------------------------------------------------------------------
636 IsValid( me:mutable )
637 returns Boolean from Standard;
639 ---Purpose: Returns TRUE only when the contains of this array is
642 ComputeVNormals( me:mutable ; fromIndex,toIndex: Integer from Standard)
647 myIndices : IndexBuffer_Handle from Graphic3d; -- optional index buffer
648 myAttribs : Buffer_Handle from Graphic3d; -- vertex attributes buffer (colors, normals, texture coordinates)
649 myBounds : BoundBuffer_Handle from Graphic3d; -- vertex attributes buffer (colors, normals, texture coordinates)
651 myType : TypeOfPrimitiveArray from Graphic3d;
653 myMaxBounds : Integer from Standard;
654 myMaxVertexs : Integer from Standard;
655 myMaxEdges : Integer from Standard;
656 myVNor : Byte from Standard; -- offset to normal attribute
657 myVTex : Byte from Standard; -- offset to texel attribute
658 myVCol : Byte from Standard; -- offset to color attribute
661 class Group from Graphic3d