1 -- Created on: 2000-06-16
2 -- Copyright (c) 2000-2012 OPEN CASCADE SAS
4 -- The content of this file is subject to the Open CASCADE Technology Public
5 -- License Version 6.5 (the "License"). You may not use the content of this file
6 -- except in compliance with the License. Please obtain a copy of the License
7 -- at http://www.opencascade.org and read it completely before using this file.
9 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 -- The Original Code and all software distributed under the License is
13 -- distributed on an "AS IS" basis, without warranty of any kind, and the
14 -- Initial Developer hereby disclaims all such warranties, including without
15 -- limitation, any warranties of merchantability, fitness for a particular
16 -- purpose or non-infringement. Please see the License for the specific terms
17 -- and conditions governing the rights and limitations under the License.
20 deferred class ArrayOfPrimitives from Graphic3d inherits TShared
22 ---Purpose: This class furnish services to defined and fill an
23 -- array of primitives compatible with the use of
24 -- the OPENGl glDrawArrays() or glDrawElements() functions.
25 -- NOTE that the main goal of this kind of primitive
26 -- is to avoid multiple copies of datas between
27 -- each layer of the software.
28 -- So the array datas exist only one time and the use
29 -- of SetXxxxxx() methods enable to change dynamically
30 -- the aspect of this primitive.
33 -- 1) Decrease strongly the loading time.
34 -- 2) Decrease strongly the display time using optimized Opengl
36 -- 3) Enable to change dynamically the components of the primitive
37 -- (vertice,normal,color,texture coordinates).
38 -- 4) Add true triangle and quadrangle strips or fans capabilities.
42 TypeOfPrimitiveArray from Graphic3d,
43 PrimitiveArray from Graphic3d,
50 OutOfRange from Standard,
51 InitialisationError from Graphic3d
57 aType: TypeOfPrimitiveArray from Graphic3d;
58 maxVertexs: Integer from Standard;
59 maxBounds: Integer from Standard;
60 maxEdges: Integer from Standard;
61 hasVNormals: Boolean from Standard;
62 hasVColors: Boolean from Standard;
63 hasBColors: Boolean from Standard;
64 hasTexels: Boolean from Standard;
65 hasEdgeInfos: Boolean from Standard)
66 returns mutable ArrayOfPrimitives from Graphic3d
67 raises InitialisationError from Graphic3d;
69 -- You must use a coherent set of AddVertex() methods according to the
70 -- <hasVNormals>,<hasVColors>,<hasVTexels>,<hasBColors>
71 -- User is responsible of confuse vertex and bad normal orientation.
72 -- You must use AddBound() method only if the <maxBounds>
73 -- constructor parameter is > 0.
74 -- You must use AddEdge() method only if the <maxEdges>
75 -- constructor parameter is > 0.
76 -- You must use a coherent set of AddEdge() methods according to the
77 -- <hasEdgeInfos> constructor parameter.
79 Destroy( me: mutable);
83 -- -------------------------------------------------------------------
84 -- Methods to fill array
85 -- -------------------------------------------------------------------
87 AddVertex( me:mutable;
88 aVertice: Pnt from gp)
89 returns Integer from Standard
91 ---Purpose: Adds a vertice in the array.
92 -- returns the actual vertex number.
93 raises OutOfRange from Standard;
94 -- if the actual vertex number is >= <maxVertexs>
97 AddVertex( me:mutable;
98 X,Y,Z: Real from Standard)
99 returns Integer from Standard
101 ---Purpose: Adds a vertice in the array.
102 -- returns the actual vertex number.
103 raises OutOfRange from Standard;
104 -- if the actual vertex number is >= <maxVertexs>
107 AddVertex( me:mutable;
108 X,Y,Z: ShortReal from Standard)
109 returns Integer from Standard
111 ---Purpose: Adds a vertice in the array.
112 -- returns the actual vertex number.
113 raises OutOfRange from Standard;
114 -- if the actual vertex number is >= <maxVertexs>
116 AddVertex( me:mutable;
117 aVertice: Pnt from gp;
118 aColor: Color from Quantity)
119 returns Integer from Standard
121 ---Purpose: Adds a vertice and vertex color in the vertex array.
122 -- returns the actual vertex number.
123 -- Warning: <aColor> is ignored when the <hasVColors>
124 -- constructor parameter is FALSE
125 raises OutOfRange from Standard;
126 -- if the actual vertex number is >= <maxVertexs>
128 AddVertex( me : mutable;
129 aVertice : Pnt from gp;
130 aColor : Integer from Standard)
131 returns Integer from Standard
133 ---Purpose: Adds a vertice and vertex color in the vertex array.
134 -- returns the actual vertex number.
135 -- Warning: <aColor> is ignored when the <hasVColors>
136 -- constructor parameter is FALSE
137 -- aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
138 -- On all architecture proccers type (x86 or SPARC) you can
139 -- use this byte order.
140 raises OutOfRange from Standard;
141 -- if the actual vertex number is >= <maxVertexs>
143 AddVertex( me :mutable;
144 aVertice : Pnt from gp;
145 aNormal : Dir from gp)
146 returns Integer from Standard
148 ---Purpose: Adds a vertice and vertex normal in the vertex array.
149 -- returns the actual vertex number.
150 -- Warning: <aNormal> is ignored when the <hasVNormals>
151 -- constructor parameter is FALSE.
152 raises OutOfRange from Standard;
153 -- if the actual vertex number is >= <maxVertexs>
156 AddVertex( me:mutable;
157 X,Y,Z: Real from Standard;
158 NX,NY,NZ: Real from Standard)
159 returns Integer from Standard
161 ---Purpose: Adds a vertice and vertex normal in the vertex array.
162 -- returns the actual vertex number.
163 -- Warning: <aNormal> is ignored when the <hasVNormals>
164 -- constructor parameter is FALSE.
165 raises OutOfRange from Standard;
166 -- if the actual vertex number is >= <maxVertexs>
169 AddVertex( me:mutable;
170 X,Y,Z: ShortReal from Standard;
171 NX,NY,NZ: ShortReal from Standard)
172 returns Integer from Standard
174 ---Purpose: Adds a vertice and vertex normal in the vertex array.
175 -- returns the actual vertex number.
176 -- Warning: <aNormal> is ignored when the <hasVNormals>
177 -- constructor parameter is FALSE.
178 raises OutOfRange from Standard;
179 -- if the actual vertex number is >= <maxVertexs>
181 AddVertex( me:mutable;
182 aVertice: Pnt from gp;
183 aNormal: Dir from gp;
184 aColor: Color from Quantity)
185 returns Integer from Standard
187 ---Purpose: Adds a vertice,vertex normal and color in the vertex array.
188 -- returns the actual vertex number.
189 -- Warning: <aNormal> is ignored when the <hasVNormals>
190 -- constructor parameter is FALSE.
191 -- <aColor> is ignored when the <hasVColors>
192 -- constructor parameter is FALSE
193 raises OutOfRange from Standard;
194 -- if the actual vertex number is >= <maxVertexs>
196 AddVertex( me : mutable;
197 aVertice : Pnt from gp;
198 aNormal : Dir from gp;
199 aColor : Integer from Standard)
200 returns Integer from Standard
202 ---Purpose: Adds a vertice,vertex normal and color in the vertex array.
203 -- returns the actual vertex number.
204 -- Warning: <aNormal> is ignored when the <hasVNormals>
205 -- constructor parameter is FALSE.
206 -- <aColor> is ignored when the <hasVColors>
207 -- constructor parameter is FALSE
208 -- aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
209 -- On all architecture proccers type (x86 or SPARC) you can
210 -- use this byte order.
211 raises OutOfRange from Standard;
212 -- if the actual vertex number is >= <maxVertexs>
214 AddVertex( me:mutable;
215 aVertice: Pnt from gp;
216 aTexel: Pnt2d from gp)
217 returns Integer from Standard
219 ---Purpose: Adds a vertice and vertex texture in the vertex array.
220 -- returns the actual vertex number.
221 -- <aTexel> is ignored when the <hasVTexels>
222 -- constructor parameter is FALSE.
223 raises OutOfRange from Standard;
224 -- if the actual vertex number is >= <maxVertexs>
227 AddVertex( me:mutable;
228 X,Y,Z: Real from Standard;
229 TX,TY: Real from Standard)
230 returns Integer from Standard
232 ---Purpose: Adds a vertice and vertex texture coordinates in the vertex array.
233 -- returns the actual vertex number.
234 -- <aTexel> is ignored when the <hasVTexels>
235 -- constructor parameter is FALSE.
236 raises OutOfRange from Standard;
237 -- if the actual vertex number is >= <maxVertexs>
240 AddVertex( me:mutable;
241 X,Y,Z: ShortReal from Standard;
242 TX,TY: ShortReal from Standard)
243 returns Integer from Standard
245 ---Purpose: Adds a vertice and vertex texture coordinates in the vertex array.
246 -- returns the actual vertex number.
247 -- <aTexel> is ignored when the <hasVTexels>
248 -- constructor parameter is FALSE.
249 raises OutOfRange from Standard;
250 -- if the actual vertex number is >= <maxVertexs>
252 AddVertex( me:mutable;
253 aVertice: Pnt from gp;
254 aNormal: Dir from gp;
255 aTexel: Pnt2d from gp)
256 returns Integer from Standard
258 ---Purpose: Adds a vertice,vertex normal and texture in the vertex array.
259 -- returns the actual vertex number.
260 -- Warning: <aNormal> is ignored when the <hasVNormals>
261 -- constructor parameter is FALSE.
262 -- <aTexel> is ignored when the <hasVTexels>
263 -- constructor parameter is FALSE.
264 raises OutOfRange from Standard;
265 -- if the actual vertex number is >= <maxVertexs>
268 AddVertex( me:mutable;
269 X,Y,Z: Real from Standard;
270 NX,NY,NZ: Real from Standard;
271 TX,TY: Real from Standard)
272 returns Integer from Standard
274 ---Purpose: Adds a vertice,vertex normal and texture in the vertex array.
275 -- returns the actual vertex number.
276 -- Warning: <aNormal> is ignored when the <hasVNormals>
277 -- constructor parameter is FALSE.
278 -- <aTexel> is ignored when the <hasVTexels>
279 -- constructor parameter is FALSE.
280 raises OutOfRange from Standard;
281 -- if the actual vertex number is >= <maxVertexs>
284 AddVertex( me:mutable;
285 X,Y,Z: ShortReal from Standard;
286 NX,NY,NZ: ShortReal from Standard;
287 TX,TY: ShortReal from Standard)
288 returns Integer from Standard
290 ---Purpose: Adds a vertice,vertex normal and texture in the vertex array.
291 -- returns the actual vertex number.
292 -- Warning: <aNormal> is ignored when the <hasVNormals>
293 -- constructor parameter is FALSE.
294 -- <aTexel> is ignored when the <hasVTexels>
295 -- constructor parameter is FALSE.
296 raises OutOfRange from Standard;
297 -- if the actual vertex number is >= <maxVertexs>
299 AddBound( me:mutable;
300 edgeNumber: Integer from Standard)
301 returns Integer from Standard
303 ---Purpose: Adds a bound of length <edgeNumber> in the bound array
304 -- returns the actual bounds number.
305 raises OutOfRange from Standard;
306 -- if the actual Bound number is >= <maxBounds>
308 AddBound( me:mutable;
309 edgeNumber: Integer from Standard;
310 aBColor: Color from Quantity)
311 returns Integer from Standard
313 ---Purpose: Adds a bound of length <edgeNumber> and bound color
314 -- <aBColor> in the bound array.
315 -- returns the actual bounds number.
316 -- Warning: <aBColor> is ignored when the <hasBColors>
317 -- constructor parameter is FALSE
318 raises OutOfRange from Standard;
319 -- if the actual Bound number is >= <maxBounds>
321 AddBound( me:mutable;
322 edgeNumber: Integer from Standard;
323 R,G,B: Real from Standard)
324 returns Integer from Standard
326 ---Purpose: Adds a bound of length <edgeNumber> and bound color
327 -- coordinates in the bound array.
328 -- returns the actual bounds number.
329 -- Warning: <R,G,B> are ignored when the <hasBColors>
330 -- constructor parameter is FALSE
331 raises OutOfRange from Standard;
332 -- if the actual Bound number is >= <maxBounds>
335 vertexIndex: Integer from Standard;
336 isVisible: Boolean from Standard = Standard_True)
337 returns Integer from Standard
339 ---Purpose: Adds an edge in the range [1,VertexNumber()] in the array,
340 -- if <isVisible> is FALSE the edge between <vertexIndex> and
341 -- the next edge will not be visible even if the SetEdgeOn() method
342 -- is activated in Graphic3d_AspectFillArea3d class.
343 -- returns the actual edges number.
344 -- Warning: <isVisible> is ignored when the <hasEdgeInfos>
345 -- constructor parameter is FALSE.
346 raises OutOfRange from Standard;
347 -- if the actual edge number is >= <maxEdges>
349 -- -------------------------------------------------------------------
350 -- Methods to modify the array
351 -- -------------------------------------------------------------------
353 Orientate( me:mutable;
354 aNormal: Dir from gp)
355 returns Boolean from Standard;
357 ---Purpose: Orientate correctly all vertexs & normals of this array
358 -- according to the <aNormal> parameter and
359 -- returns TRUE when something has change in the array.
360 -- Warning: When the array has edges this method is apply
361 -- on edge sub array instead on vertex sub array.
363 Orientate( me:mutable;
364 aVertexIndex: Integer from Standard;
365 aVertexNumber: Integer from Standard;
366 aNormal: Dir from gp)
367 returns Boolean from Standard
369 ---Purpose: Orientate correctly a set of vertexs & normal
370 -- from <aVertexIndex> to <aVertexIndex>+<aVertexNumber>-1
371 -- according to the <aNormal> parameter and
372 -- returns TRUE when something has change in the array.
373 -- Warning: When the array has edges this method is apply
374 -- on edge sub array instead on vertex sub array.
375 raises OutOfRange from Standard is private;
376 -- if the <aVertexIndex> parameter is < 1 or > VertexNumber() or
379 Orientate( me:mutable;
380 aBoundIndex: Integer from Standard;
381 aNormal: Dir from gp)
382 returns Boolean from Standard
384 ---Purpose: Orientate correctly all vertexs & normal of the bound <aBound>
385 -- according to the <aNormal> parameter and
386 -- returns TRUE when something has change in the array.
387 -- Warning: When the array has edges this method is apply
388 -- on edge sub array instead on vertex sub array.
389 -- When this array has no bound, <aBoundIndex> design the item number
390 raises OutOfRange from Standard;
391 -- if the <aBoundIndex> parameter is < 1 or > BoundNumber()
392 -- or if the <aBoundIndex> parameter is < 1 or > ItemNumber()
394 SetVertice( me:mutable;
395 anIndex: Integer from Standard;
396 aVertice: Pnt from gp)
398 ---Purpose: Change the vertice of rank <anIndex> in the array.
399 raises OutOfRange from Standard;
400 -- if the index is <1 or > VertexNumber()
402 SetVertice( me:mutable;
403 anIndex: Integer from Standard;
404 X,Y,Z: ShortReal from Standard)
406 ---Purpose: Change the vertice of rank <anIndex> in the array.
407 raises OutOfRange from Standard;
408 -- if the index is <1 or > VertexNumber()
411 SetVertexColor( me : mutable;
412 anIndex : Integer from Standard;
413 aColor : Color from Quantity)
415 ---Purpose: Change the vertex color of rank <anIndex> in the array.
416 raises OutOfRange from Standard;
417 -- if the index is <1 or > VertexNumber()
419 SetVertexColor( me : mutable;
420 anIndex : Integer from Standard;
421 R,G,B : Real from Standard)
423 ---Purpose: Change the vertex color of rank <anIndex> in the array.
424 raises OutOfRange from Standard;
425 -- if the index is <1 or > VertexNumber()
428 SetVertexColor( me : mutable;
429 anIndex : Integer from Standard;
430 aColor : Integer from Standard)
432 ---Purpose: Change the vertex color of rank <anIndex> in the array.
433 -- aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
434 -- On all architecture proccers type (x86 or SPARC) you can
435 -- use this byte order.
436 raises OutOfRange from Standard;
437 -- if the index is <1 or > VertexNumber()
440 SetVertexNormal( me : mutable;
441 anIndex : Integer from Standard;
442 aNormal : Dir from gp)
444 ---Purpose: Change the vertex normal of rank <anIndex> in the array.
445 raises OutOfRange from Standard;
446 -- if the index is <1 or > VertexNumber()
448 SetVertexNormal( me : mutable;
449 anIndex : Integer from Standard;
450 NX,NY,NZ: Real from Standard)
452 ---Purpose: Change the vertex normal of rank <anIndex> in the array.
453 raises OutOfRange from Standard;
454 -- if the index is <1 or > VertexNumber()
457 SetVertexTexel( me:mutable;
458 anIndex: Integer from Standard;
459 aTexel: Pnt2d from gp)
461 ---Purpose: Change the vertex texel of rank <anIndex> in the array.
462 raises OutOfRange from Standard;
463 -- if the index is <1 or > VertexNumber()
465 SetVertexTexel( me:mutable;
466 anIndex: Integer from Standard;
467 TX,TY: Real from Standard)
469 ---Purpose: Change the vertex texel of rank <anIndex> in the array.
470 raises OutOfRange from Standard;
471 -- if the index is <1 or > VertexNumber()
474 SetBoundColor( me:mutable;
475 anIndex: Integer from Standard;
476 aColor: Color from Quantity)
478 ---Purpose: Change the bound color of rank <anIndex> in the array.
479 raises OutOfRange from Standard;
480 -- if the index is <1 or > BoundNumber()
482 SetBoundColor( me:mutable;
483 anIndex: Integer from Standard;
484 R,G,B: Real from Standard)
486 ---Purpose: Change the bound color of rank <anIndex> in the array.
487 raises OutOfRange from Standard;
488 -- if the index is <1 or > BoundNumber()
491 -------------------------------------------------------------------
492 -- Category Inquiries on array
493 -------------------------------------------------------------------
496 returns PrimitiveArray from Graphic3d;
498 ---Purpose: Returns the array address.
502 returns TypeOfPrimitiveArray from Graphic3d;
504 ---Purpose: Returns the type of this primitive
508 returns CString from Standard;
510 ---Purpose: Returns the string type of this primitive
512 HasVertexNormals( me )
513 returns Boolean from Standard;
515 ---Purpose: Returns TRUE when vertex normals array is defined.
518 HasVertexColors( me )
519 returns Boolean from Standard;
521 ---Purpose: Returns TRUE when vertex colors array is defined.
524 HasVertexTexels( me )
525 returns Boolean from Standard;
527 ---Purpose: Returns TRUE when vertex texels array is defined.
531 returns Integer from Standard;
533 ---Purpose: Returns the number of defined vertex
536 Vertice( me ; aRank: Integer from Standard)
539 ---Purpose: Returns the vertice at rank <aRank>
540 -- from the vertex table if defined.
541 raises OutOfRange from Standard;
542 -- when the rank is < 1 or > VertexNumber().
544 Vertice( me ; aRank: Integer from Standard;
545 X,Y,Z: out Real from Standard)
547 ---Purpose: Returns the vertice coordinates at rank <aRank>
548 -- from the vertex table if defined.
549 raises OutOfRange from Standard;
550 -- when the rank is < 1 or > VertexNumber().
553 VertexColor( me ; aRank: Integer from Standard)
554 returns Color from Quantity
556 ---Purpose: Returns the vertex color at rank <aRank>
557 -- from the vertex table if defined.
558 raises OutOfRange from Standard;
559 -- when the rank is < 1 or > VertexNumber().
561 VertexColor( me ; aRank : Integer from Standard;
562 R, G, B : out Real from Standard)
564 ---Purpose: Returns the vertex color values at rank <aRank>
565 -- from the vertex table if defined.
566 raises OutOfRange from Standard;
567 -- when the rank is < 1 or > VertexNumber().
570 VertexColor( me ; aRank: Integer from Standard;
571 aColor: out Integer from Standard)
573 ---Purpose: Returns the vertex color values at rank <aRank>
574 -- from the vertex table if defined.
575 raises OutOfRange from Standard;
576 -- when the rank is < 1 or > VertexNumber().
580 VertexNormal( me ; aRank: Integer from Standard)
583 ---Purpose: Returns the vertex normal at rank <aRank>
584 -- from the vertex table if defined.
585 raises OutOfRange from Standard;
586 -- when the rank is < 1 or > VertexNumber().
588 VertexNormal( me ; aRank: Integer from Standard;
589 NX,NY,NZ: out Real from Standard)
591 ---Purpose: Returns the vertex normal coordinates at rank <aRank>
592 -- from the vertex table if defined.
593 raises OutOfRange from Standard;
594 -- when the rank is < 1 or > VertexNumber().
597 VertexTexel( me ; aRank: Integer from Standard)
598 returns Pnt2d from gp
600 ---Purpose: Returns the vertex texture at rank <aRank>
601 -- from the vertex table if defined.
602 raises OutOfRange from Standard;
603 -- when the rank is < 1 or > VertexNumber().
605 VertexTexel( me ; aRank: Integer from Standard;
606 TX,TY: out Real from Standard)
608 ---Purpose: Returns the vertex texture coordinates at rank <aRank>
609 -- from the vertex table if defined.
610 raises OutOfRange from Standard;
611 -- when the rank is < 1 or > VertexNumber().
615 returns Boolean from Standard;
617 ---Purpose: Returns TRUE when edge visibillity array is defined.
621 returns Integer from Standard;
623 ---Purpose: Returns the number of defined edges
626 Edge( me ; aRank: Integer from Standard)
627 returns Integer from Standard
629 ---Purpose: Returns the vertex index at rank <aRank>
630 -- in the range [1,VertexNumber()]
631 raises OutOfRange from Standard;
632 -- when the rank is < 1 or > EdgeNumber()
635 EdgeIsVisible( me ; aRank: Integer from Standard)
636 returns Boolean from Standard
638 ---Purpose: Returns TRUE when the edge at rank <aRank>
640 raises OutOfRange from Standard;
641 -- when the rank is < 1 or > EdgeNumber()
645 returns Boolean from Standard;
647 ---Purpose: Returns TRUE when bound colors array is defined.
651 returns Integer from Standard;
653 ---Purpose: Returns the number of defined bounds
656 Bound( me ; aRank: Integer from Standard)
657 returns Integer from Standard
659 ---Purpose: Returns the edge number at rank <aRank>.
660 raises OutOfRange from Standard;
661 -- when the rank is < 1 or > BoundNumber()
664 BoundColor( me ; aRank: Integer from Standard)
665 returns Color from Quantity
667 ---Purpose: Returns the bound color at rank <aRank>
668 -- from the bound table if defined.
669 raises OutOfRange from Standard;
670 -- when the rank is < 1 or > BoundNumber()
672 BoundColor( me ; aRank: Integer from Standard;
673 R,G,B: out Real from Standard)
675 ---Purpose: Returns the bound color values at rank <aRank>
676 -- from the bound table if defined.
677 raises OutOfRange from Standard;
678 -- when the rank is < 1 or > BoundNumber()
681 returns Integer from Standard;
683 ---Purpose: Returns the number of total items according to
686 -------------------------------------------------------------------
687 -- Category Miscellaneous
688 -------------------------------------------------------------------
690 IsValid( me:mutable )
691 returns Boolean from Standard;
693 ---Purpose: Returns TRUE only when the contains of this array is
696 ComputeVNormals( me:mutable ; fromIndex,toIndex: Integer from Standard)
700 myPrimitiveArray: PrimitiveArray from Graphic3d;
701 myMaxBounds: Integer from Standard;
702 myMaxVertexs: Integer from Standard;
703 myMaxEdges: Integer from Standard;
706 class Group from Graphic3d