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,
47 OutOfRange from Standard,
48 InitialisationError from Graphic3d
54 aType: TypeOfPrimitiveArray from Graphic3d;
55 maxVertexs: Integer from Standard;
56 maxBounds: Integer from Standard;
57 maxEdges: Integer from Standard;
58 hasVNormals: Boolean from Standard;
59 hasVColors: Boolean from Standard;
60 hasBColors: Boolean from Standard;
61 hasTexels: Boolean from Standard)
62 returns mutable ArrayOfPrimitives from Graphic3d
63 raises InitialisationError from Graphic3d;
65 -- You must use a coherent set of AddVertex() methods according to the
66 -- <hasVNormals>,<hasVColors>,<hasVTexels>,<hasBColors>
67 -- User is responsible of confuse vertex and bad normal orientation.
68 -- You must use AddBound() method only if the <maxBounds>
69 -- constructor parameter is > 0.
70 -- You must use AddEdge() method only if the <maxEdges>
71 -- constructor parameter is > 0.
73 Destroy( me: mutable);
77 -- -------------------------------------------------------------------
78 -- Methods to fill array
79 -- -------------------------------------------------------------------
81 AddVertex( me:mutable;
82 aVertice: Pnt from gp)
83 returns Integer from Standard
85 ---Purpose: Adds a vertice in the array.
86 -- returns the actual vertex number.
87 raises OutOfRange from Standard;
88 -- if the actual vertex number is >= <maxVertexs>
91 AddVertex( me:mutable;
92 X,Y,Z: Real from Standard)
93 returns Integer from Standard
95 ---Purpose: Adds a vertice in the array.
96 -- returns the actual vertex number.
97 raises OutOfRange from Standard;
98 -- if the actual vertex number is >= <maxVertexs>
101 AddVertex( me:mutable;
102 X,Y,Z: ShortReal from Standard)
103 returns Integer from Standard
105 ---Purpose: Adds a vertice in the array.
106 -- returns the actual vertex number.
107 raises OutOfRange from Standard;
108 -- if the actual vertex number is >= <maxVertexs>
110 AddVertex( me:mutable;
111 aVertice: Pnt from gp;
112 aColor: Color from Quantity)
113 returns Integer from Standard
115 ---Purpose: Adds a vertice and vertex color in the vertex array.
116 -- returns the actual vertex number.
117 -- Warning: <aColor> is ignored when the <hasVColors>
118 -- constructor parameter is FALSE
119 raises OutOfRange from Standard;
120 -- if the actual vertex number is >= <maxVertexs>
122 AddVertex( me : mutable;
123 aVertice : Pnt from gp;
124 aColor : Integer from Standard)
125 returns Integer from Standard
127 ---Purpose: Adds a vertice and vertex color in the vertex array.
128 -- returns the actual vertex number.
129 -- Warning: <aColor> is ignored when the <hasVColors>
130 -- constructor parameter is FALSE
131 -- aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
132 -- On all architecture proccers type (x86 or SPARC) you can
133 -- use this byte order.
134 raises OutOfRange from Standard;
135 -- if the actual vertex number is >= <maxVertexs>
137 AddVertex( me :mutable;
138 aVertice : Pnt from gp;
139 aNormal : Dir from gp)
140 returns Integer from Standard
142 ---Purpose: Adds a vertice and vertex normal in the vertex array.
143 -- returns the actual vertex number.
144 -- Warning: <aNormal> is ignored when the <hasVNormals>
145 -- constructor parameter is FALSE.
146 raises OutOfRange from Standard;
147 -- if the actual vertex number is >= <maxVertexs>
150 AddVertex( me:mutable;
151 X,Y,Z: Real from Standard;
152 NX,NY,NZ: Real from Standard)
153 returns Integer from Standard
155 ---Purpose: Adds a vertice and vertex normal in the vertex array.
156 -- returns the actual vertex number.
157 -- Warning: <aNormal> is ignored when the <hasVNormals>
158 -- constructor parameter is FALSE.
159 raises OutOfRange from Standard;
160 -- if the actual vertex number is >= <maxVertexs>
163 AddVertex( me:mutable;
164 X,Y,Z: ShortReal from Standard;
165 NX,NY,NZ: ShortReal from Standard)
166 returns Integer from Standard
168 ---Purpose: Adds a vertice and vertex normal in the vertex array.
169 -- returns the actual vertex number.
170 -- Warning: <aNormal> is ignored when the <hasVNormals>
171 -- constructor parameter is FALSE.
172 raises OutOfRange from Standard;
173 -- if the actual vertex number is >= <maxVertexs>
175 AddVertex( me:mutable;
176 aVertice: Pnt from gp;
177 aNormal: Dir from gp;
178 aColor: Color from Quantity)
179 returns Integer from Standard
181 ---Purpose: Adds a vertice,vertex normal and color in the vertex array.
182 -- returns the actual vertex number.
183 -- Warning: <aNormal> is ignored when the <hasVNormals>
184 -- constructor parameter is FALSE.
185 -- <aColor> is ignored when the <hasVColors>
186 -- constructor parameter is FALSE
187 raises OutOfRange from Standard;
188 -- if the actual vertex number is >= <maxVertexs>
190 AddVertex( me : mutable;
191 aVertice : Pnt from gp;
192 aNormal : Dir from gp;
193 aColor : Integer from Standard)
194 returns Integer from Standard
196 ---Purpose: Adds a vertice,vertex normal and color in the vertex array.
197 -- returns the actual vertex number.
198 -- Warning: <aNormal> is ignored when the <hasVNormals>
199 -- constructor parameter is FALSE.
200 -- <aColor> is ignored when the <hasVColors>
201 -- constructor parameter is FALSE
202 -- aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
203 -- On all architecture proccers type (x86 or SPARC) you can
204 -- use this byte order.
205 raises OutOfRange from Standard;
206 -- if the actual vertex number is >= <maxVertexs>
208 AddVertex( me:mutable;
209 aVertice: Pnt from gp;
210 aTexel: Pnt2d from gp)
211 returns Integer from Standard
213 ---Purpose: Adds a vertice and vertex texture in the vertex array.
214 -- returns the actual vertex number.
215 -- <aTexel> is ignored when the <hasVTexels>
216 -- constructor parameter is FALSE.
217 raises OutOfRange from Standard;
218 -- if the actual vertex number is >= <maxVertexs>
221 AddVertex( me:mutable;
222 X,Y,Z: Real from Standard;
223 TX,TY: Real from Standard)
224 returns Integer from Standard
226 ---Purpose: Adds a vertice and vertex texture coordinates in the vertex array.
227 -- returns the actual vertex number.
228 -- <aTexel> is ignored when the <hasVTexels>
229 -- constructor parameter is FALSE.
230 raises OutOfRange from Standard;
231 -- if the actual vertex number is >= <maxVertexs>
234 AddVertex( me:mutable;
235 X,Y,Z: ShortReal from Standard;
236 TX,TY: ShortReal from Standard)
237 returns Integer from Standard
239 ---Purpose: Adds a vertice and vertex texture coordinates in the vertex array.
240 -- returns the actual vertex number.
241 -- <aTexel> is ignored when the <hasVTexels>
242 -- constructor parameter is FALSE.
243 raises OutOfRange from Standard;
244 -- if the actual vertex number is >= <maxVertexs>
246 AddVertex( me:mutable;
247 aVertice: Pnt from gp;
248 aNormal: Dir from gp;
249 aTexel: Pnt2d from gp)
250 returns Integer from Standard
252 ---Purpose: Adds a vertice,vertex normal and texture in the vertex array.
253 -- returns the actual vertex number.
254 -- Warning: <aNormal> is ignored when the <hasVNormals>
255 -- constructor parameter is FALSE.
256 -- <aTexel> is ignored when the <hasVTexels>
257 -- constructor parameter is FALSE.
258 raises OutOfRange from Standard;
259 -- if the actual vertex number is >= <maxVertexs>
262 AddVertex( me:mutable;
263 X,Y,Z: Real from Standard;
264 NX,NY,NZ: Real from Standard;
265 TX,TY: Real from Standard)
266 returns Integer from Standard
268 ---Purpose: Adds a vertice,vertex normal and texture in the vertex array.
269 -- returns the actual vertex number.
270 -- Warning: <aNormal> is ignored when the <hasVNormals>
271 -- constructor parameter is FALSE.
272 -- <aTexel> is ignored when the <hasVTexels>
273 -- constructor parameter is FALSE.
274 raises OutOfRange from Standard;
275 -- if the actual vertex number is >= <maxVertexs>
278 AddVertex( me:mutable;
279 X,Y,Z: ShortReal from Standard;
280 NX,NY,NZ: ShortReal from Standard;
281 TX,TY: ShortReal from Standard)
282 returns Integer from Standard
284 ---Purpose: Adds a vertice,vertex normal and texture in the vertex array.
285 -- returns the actual vertex number.
286 -- Warning: <aNormal> is ignored when the <hasVNormals>
287 -- constructor parameter is FALSE.
288 -- <aTexel> is ignored when the <hasVTexels>
289 -- constructor parameter is FALSE.
290 raises OutOfRange from Standard;
291 -- if the actual vertex number is >= <maxVertexs>
293 AddBound( me:mutable;
294 edgeNumber: Integer from Standard)
295 returns Integer from Standard
297 ---Purpose: Adds a bound of length <edgeNumber> in the bound array
298 -- returns the actual bounds number.
299 raises OutOfRange from Standard;
300 -- if the actual Bound number is >= <maxBounds>
302 AddBound( me:mutable;
303 edgeNumber: Integer from Standard;
304 aBColor: Color from Quantity)
305 returns Integer from Standard
307 ---Purpose: Adds a bound of length <edgeNumber> and bound color
308 -- <aBColor> in the bound array.
309 -- returns the actual bounds number.
310 -- Warning: <aBColor> is ignored when the <hasBColors>
311 -- constructor parameter is FALSE
312 raises OutOfRange from Standard;
313 -- if the actual Bound number is >= <maxBounds>
315 AddBound( me:mutable;
316 edgeNumber: Integer from Standard;
317 R,G,B: Real from Standard)
318 returns Integer from Standard
320 ---Purpose: Adds a bound of length <edgeNumber> and bound color
321 -- coordinates in the bound array.
322 -- returns the actual bounds number.
323 -- Warning: <R,G,B> are ignored when the <hasBColors>
324 -- constructor parameter is FALSE
325 raises OutOfRange from Standard;
326 -- if the actual Bound number is >= <maxBounds>
329 vertexIndex: Integer from Standard)
330 returns Integer from Standard
332 ---Purpose: Adds an edge in the range [1,VertexNumber()] in the array.
333 -- Returns the actual edges number.
334 raises OutOfRange from Standard;
335 -- if the actual edge number is >= <maxEdges>
337 -- -------------------------------------------------------------------
338 -- Methods to modify the array
339 -- -------------------------------------------------------------------
341 SetVertice( me:mutable;
342 anIndex: Integer from Standard;
343 aVertice: Pnt from gp)
345 ---Purpose: Change the vertice of rank <anIndex> in the array.
346 raises OutOfRange from Standard;
347 -- if the index is <1 or > VertexNumber()
349 SetVertice( me:mutable;
350 anIndex: Integer from Standard;
351 X,Y,Z: ShortReal from Standard)
353 ---Purpose: Change the vertice of rank <anIndex> in the array.
354 raises OutOfRange from Standard;
355 -- if the index is <1 or > VertexNumber()
358 SetVertexColor( me : mutable;
359 anIndex : Integer from Standard;
360 aColor : Color from Quantity)
362 ---Purpose: Change the vertex color of rank <anIndex> in the array.
363 raises OutOfRange from Standard;
364 -- if the index is <1 or > VertexNumber()
366 SetVertexColor( me : mutable;
367 anIndex : Integer from Standard;
368 R,G,B : Real from Standard)
370 ---Purpose: Change the vertex color of rank <anIndex> in the array.
371 raises OutOfRange from Standard;
372 -- if the index is <1 or > VertexNumber()
375 SetVertexColor( me : mutable;
376 anIndex : Integer from Standard;
377 aColor : Integer from Standard)
379 ---Purpose: Change the vertex color of rank <anIndex> in the array.
380 -- aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
381 -- On all architecture proccers type (x86 or SPARC) you can
382 -- use this byte order.
383 raises OutOfRange from Standard;
384 -- if the index is <1 or > VertexNumber()
387 SetVertexNormal( me : mutable;
388 anIndex : Integer from Standard;
389 aNormal : Dir from gp)
391 ---Purpose: Change the vertex normal of rank <anIndex> in the array.
392 raises OutOfRange from Standard;
393 -- if the index is <1 or > VertexNumber()
395 SetVertexNormal( me : mutable;
396 anIndex : Integer from Standard;
397 NX,NY,NZ: Real from Standard)
399 ---Purpose: Change the vertex normal of rank <anIndex> in the array.
400 raises OutOfRange from Standard;
401 -- if the index is <1 or > VertexNumber()
404 SetVertexTexel( me:mutable;
405 anIndex: Integer from Standard;
406 aTexel: Pnt2d from gp)
408 ---Purpose: Change the vertex texel of rank <anIndex> in the array.
409 raises OutOfRange from Standard;
410 -- if the index is <1 or > VertexNumber()
412 SetVertexTexel( me:mutable;
413 anIndex: Integer from Standard;
414 TX,TY: Real from Standard)
416 ---Purpose: Change the vertex texel of rank <anIndex> in the array.
417 raises OutOfRange from Standard;
418 -- if the index is <1 or > VertexNumber()
421 SetBoundColor( me:mutable;
422 anIndex: Integer from Standard;
423 aColor: Color from Quantity)
425 ---Purpose: Change the bound color of rank <anIndex> in the array.
426 raises OutOfRange from Standard;
427 -- if the index is <1 or > BoundNumber()
429 SetBoundColor( me:mutable;
430 anIndex: Integer from Standard;
431 R,G,B: Real from Standard)
433 ---Purpose: Change the bound color of rank <anIndex> in the array.
434 raises OutOfRange from Standard;
435 -- if the index is <1 or > BoundNumber()
438 -------------------------------------------------------------------
439 -- Category Inquiries on array
440 -------------------------------------------------------------------
443 returns IndexBuffer_Handle from Graphic3d;
444 ---Purpose: Returns optional index buffer.
446 ---C++: return const &
449 returns Buffer_Handle from Graphic3d;
450 ---Purpose: Returns vertex attributes buffer (colors, normals, texture coordinates).
452 ---C++: return const &
455 returns BoundBuffer_Handle from Graphic3d;
456 ---Purpose: Returns optional bounds buffer.
458 ---C++: return const &
461 returns TypeOfPrimitiveArray from Graphic3d;
463 ---Purpose: Returns the type of this primitive
467 returns CString from Standard;
469 ---Purpose: Returns the string type of this primitive
471 HasVertexNormals( me )
472 returns Boolean from Standard;
474 ---Purpose: Returns TRUE when vertex normals array is defined.
477 HasVertexColors( me )
478 returns Boolean from Standard;
480 ---Purpose: Returns TRUE when vertex colors array is defined.
483 HasVertexTexels( me )
484 returns Boolean from Standard;
486 ---Purpose: Returns TRUE when vertex texels array is defined.
490 returns Integer from Standard;
492 ---Purpose: Returns the number of defined vertex
495 Vertice( me ; aRank: Integer from Standard)
498 ---Purpose: Returns the vertice at rank <aRank>
499 -- from the vertex table if defined.
500 raises OutOfRange from Standard;
501 -- when the rank is < 1 or > VertexNumber().
503 Vertice( me ; aRank: Integer from Standard;
504 X,Y,Z: out Real from Standard)
506 ---Purpose: Returns the vertice coordinates at rank <aRank>
507 -- from the vertex table if defined.
508 raises OutOfRange from Standard;
509 -- when the rank is < 1 or > VertexNumber().
512 VertexColor( me ; aRank: Integer from Standard)
513 returns Color from Quantity
515 ---Purpose: Returns the vertex color at rank <aRank>
516 -- from the vertex table if defined.
517 raises OutOfRange from Standard;
518 -- when the rank is < 1 or > VertexNumber().
520 VertexColor( me ; aRank : Integer from Standard;
521 R, G, B : out Real from Standard)
523 ---Purpose: Returns the vertex color values at rank <aRank>
524 -- from the vertex table if defined.
525 raises OutOfRange from Standard;
526 -- when the rank is < 1 or > VertexNumber().
529 VertexColor( me ; aRank: Integer from Standard;
530 aColor: out Integer from Standard)
532 ---Purpose: Returns the vertex color values at rank <aRank>
533 -- from the vertex table if defined.
534 raises OutOfRange from Standard;
535 -- when the rank is < 1 or > VertexNumber().
539 VertexNormal( me ; aRank: Integer from Standard)
542 ---Purpose: Returns the vertex normal at rank <aRank>
543 -- from the vertex table if defined.
544 raises OutOfRange from Standard;
545 -- when the rank is < 1 or > VertexNumber().
547 VertexNormal( me ; aRank: Integer from Standard;
548 NX,NY,NZ: out Real from Standard)
550 ---Purpose: Returns the vertex normal coordinates at rank <aRank>
551 -- from the vertex table if defined.
552 raises OutOfRange from Standard;
553 -- when the rank is < 1 or > VertexNumber().
556 VertexTexel( me ; aRank: Integer from Standard)
557 returns Pnt2d from gp
559 ---Purpose: Returns the vertex texture at rank <aRank>
560 -- from the vertex table if defined.
561 raises OutOfRange from Standard;
562 -- when the rank is < 1 or > VertexNumber().
564 VertexTexel( me ; aRank: Integer from Standard;
565 TX,TY: out Real from Standard)
567 ---Purpose: Returns the vertex texture coordinates at rank <aRank>
568 -- from the vertex table if defined.
569 raises OutOfRange from Standard;
570 -- when the rank is < 1 or > VertexNumber().
574 returns Integer from Standard;
576 ---Purpose: Returns the number of defined edges
579 Edge( me ; aRank: Integer from Standard)
580 returns Integer from Standard
582 ---Purpose: Returns the vertex index at rank <aRank>
583 -- in the range [1,VertexNumber()]
584 raises OutOfRange from Standard;
585 -- when the rank is < 1 or > EdgeNumber()
589 returns Boolean from Standard;
591 ---Purpose: Returns TRUE when bound colors array is defined.
595 returns Integer from Standard;
597 ---Purpose: Returns the number of defined bounds
600 Bound( me ; aRank: Integer from Standard)
601 returns Integer from Standard
603 ---Purpose: Returns the edge number at rank <aRank>.
604 raises OutOfRange from Standard;
605 -- when the rank is < 1 or > BoundNumber()
608 BoundColor( me ; aRank: Integer from Standard)
609 returns Color from Quantity
611 ---Purpose: Returns the bound color at rank <aRank>
612 -- from the bound table if defined.
613 raises OutOfRange from Standard;
614 -- when the rank is < 1 or > BoundNumber()
616 BoundColor( me ; aRank: Integer from Standard;
617 R,G,B: out Real from Standard)
619 ---Purpose: Returns the bound color values at rank <aRank>
620 -- from the bound table if defined.
621 raises OutOfRange from Standard;
622 -- when the rank is < 1 or > BoundNumber()
625 returns Integer from Standard;
627 ---Purpose: Returns the number of total items according to
630 -------------------------------------------------------------------
631 -- Category Miscellaneous
632 -------------------------------------------------------------------
634 IsValid( me:mutable )
635 returns Boolean from Standard;
637 ---Purpose: Returns TRUE only when the contains of this array is
640 ComputeVNormals( me:mutable ; fromIndex,toIndex: Integer from Standard)
645 myIndices : IndexBuffer_Handle from Graphic3d; -- optional index buffer
646 myAttribs : Buffer_Handle from Graphic3d; -- vertex attributes buffer (colors, normals, texture coordinates)
647 myBounds : BoundBuffer_Handle from Graphic3d; -- vertex attributes buffer (colors, normals, texture coordinates)
649 myType : TypeOfPrimitiveArray from Graphic3d;
651 myMaxBounds : Integer from Standard;
652 myMaxVertexs : Integer from Standard;
653 myMaxEdges : Integer from Standard;
654 myVNor : Byte from Standard; -- offset to normal attribute
655 myVTex : Byte from Standard; -- offset to texel attribute
656 myVCol : Byte from Standard; -- offset to color attribute
659 class Group from Graphic3d