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>
96 AddVertex( me:mutable;
97 X,Y,Z: Real from Standard)
98 returns Integer from Standard
100 ---Purpose: Adds a vertice in the array.
101 -- returns the actual vertex number.
102 raises OutOfRange from Standard;
103 -- if the actual vertex number is >= <maxVertexs>
105 AddVertex( me:mutable;
106 aVertice: Pnt from gp;
107 aColor: Color from Quantity)
108 returns Integer from Standard
110 ---Purpose: Adds a vertice and vertex color in the vertex array.
111 -- returns the actual vertex number.
112 -- Warning: <aColor> is ignored when the <hasVColors>
113 -- constructor parameter is FALSE
114 raises OutOfRange from Standard;
115 -- if the actual vertex number is >= <maxVertexs>
117 AddVertex( me : mutable;
118 aVertice : Pnt from gp;
119 aColor : Integer from Standard)
120 returns Integer from Standard
122 ---Purpose: Adds a vertice and vertex color in the vertex array.
123 -- returns the actual vertex number.
124 -- Warning: <aColor> is ignored when the <hasVColors>
125 -- constructor parameter is FALSE
126 -- aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
127 -- On all architecture proccers type (x86 or SPARC) you can
128 -- use this byte order.
129 raises OutOfRange from Standard;
130 -- if the actual vertex number is >= <maxVertexs>
133 AddVertex( me :mutable;
134 aVertice : Pnt from gp;
135 aNormal : Dir from gp)
136 returns Integer from Standard
138 ---Purpose: Adds a vertice and vertex normal in the vertex array.
139 -- returns the actual vertex number.
140 -- Warning: <aNormal> is ignored when the <hasVNormals>
141 -- constructor parameter is FALSE.
142 raises OutOfRange from Standard;
143 -- if the actual vertex number is >= <maxVertexs>
145 AddVertex( me:mutable;
146 X,Y,Z: Real from Standard;
147 NX,NY,NZ: Real from Standard)
148 returns Integer from Standard
150 ---Purpose: Adds a vertice and vertex normal in the vertex array.
151 -- returns the actual vertex number.
152 -- Warning: <aNormal> is ignored when the <hasVNormals>
153 -- constructor parameter is FALSE.
154 raises OutOfRange from Standard;
155 -- if the actual vertex number is >= <maxVertexs>
157 AddVertex( me:mutable;
158 aVertice: Pnt from gp;
159 aNormal: Dir from gp;
160 aColor: Color from Quantity)
161 returns Integer from Standard
163 ---Purpose: Adds a vertice,vertex normal and color in the vertex array.
164 -- returns the actual vertex number.
165 -- Warning: <aNormal> is ignored when the <hasVNormals>
166 -- constructor parameter is FALSE.
167 -- <aColor> is ignored when the <hasVColors>
168 -- constructor parameter is FALSE
169 raises OutOfRange from Standard;
170 -- if the actual vertex number is >= <maxVertexs>
172 AddVertex( me : mutable;
173 aVertice : Pnt from gp;
174 aNormal : Dir from gp;
175 aColor : Integer from Standard)
176 returns Integer from Standard
178 ---Purpose: Adds a vertice,vertex normal and color in the vertex array.
179 -- returns the actual vertex number.
180 -- Warning: <aNormal> is ignored when the <hasVNormals>
181 -- constructor parameter is FALSE.
182 -- <aColor> is ignored when the <hasVColors>
183 -- constructor parameter is FALSE
184 -- aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
185 -- On all architecture proccers type (x86 or SPARC) you can
186 -- use this byte order.
187 raises OutOfRange from Standard;
188 -- if the actual vertex number is >= <maxVertexs>
191 AddVertex( me:mutable;
192 aVertice: Pnt from gp;
193 aTexel: Pnt2d from gp)
194 returns Integer from Standard
196 ---Purpose: Adds a vertice and vertex texture in the vertex array.
197 -- returns the actual vertex number.
198 -- <aTexel> is ignored when the <hasVTexels>
199 -- constructor parameter is FALSE.
200 raises OutOfRange from Standard;
201 -- if the actual vertex number is >= <maxVertexs>
203 AddVertex( me:mutable;
204 X,Y,Z: Real from Standard;
205 TX,TY: Real from Standard)
206 returns Integer from Standard
208 ---Purpose: Adds a vertice and vertex texture coordinates in the vertex array.
209 -- returns the actual vertex number.
210 -- <aTexel> is ignored when the <hasVTexels>
211 -- constructor parameter is FALSE.
212 raises OutOfRange from Standard;
213 -- if the actual vertex number is >= <maxVertexs>
215 AddVertex( me:mutable;
216 aVertice: Pnt from gp;
217 aNormal: Dir from gp;
218 aTexel: Pnt2d from gp)
219 returns Integer from Standard
221 ---Purpose: Adds a vertice,vertex normal and texture in the vertex array.
222 -- returns the actual vertex number.
223 -- Warning: <aNormal> is ignored when the <hasVNormals>
224 -- constructor parameter is FALSE.
225 -- <aTexel> is ignored when the <hasVTexels>
226 -- constructor parameter is FALSE.
227 raises OutOfRange from Standard;
228 -- if the actual vertex number is >= <maxVertexs>
230 AddVertex( me:mutable;
231 X,Y,Z: Real from Standard;
232 NX,NY,NZ: Real from Standard;
233 TX,TY: Real from Standard)
234 returns Integer from Standard
236 ---Purpose: Adds a vertice,vertex normal and texture in the vertex array.
237 -- returns the actual vertex number.
238 -- Warning: <aNormal> is ignored when the <hasVNormals>
239 -- constructor parameter is FALSE.
240 -- <aTexel> is ignored when the <hasVTexels>
241 -- constructor parameter is FALSE.
242 raises OutOfRange from Standard;
243 -- if the actual vertex number is >= <maxVertexs>
245 AddBound( me:mutable;
246 edgeNumber: Integer from Standard)
247 returns Integer from Standard
249 ---Purpose: Adds a bound of length <edgeNumber> in the bound array
250 -- returns the actual bounds number.
251 raises OutOfRange from Standard;
252 -- if the actual Bound number is >= <maxBounds>
254 AddBound( me:mutable;
255 edgeNumber: Integer from Standard;
256 aBColor: Color from Quantity)
257 returns Integer from Standard
259 ---Purpose: Adds a bound of length <edgeNumber> and bound color
260 -- <aBColor> in the bound array.
261 -- returns the actual bounds number.
262 -- Warning: <aBColor> is ignored when the <hasBColors>
263 -- constructor parameter is FALSE
264 raises OutOfRange from Standard;
265 -- if the actual Bound number is >= <maxBounds>
267 AddBound( me:mutable;
268 edgeNumber: Integer from Standard;
269 R,G,B: Real from Standard)
270 returns Integer from Standard
272 ---Purpose: Adds a bound of length <edgeNumber> and bound color
273 -- coordinates in the bound array.
274 -- returns the actual bounds number.
275 -- Warning: <R,G,B> are ignored when the <hasBColors>
276 -- constructor parameter is FALSE
277 raises OutOfRange from Standard;
278 -- if the actual Bound number is >= <maxBounds>
281 vertexIndex: Integer from Standard;
282 isVisible: Boolean from Standard = Standard_True)
283 returns Integer from Standard
285 ---Purpose: Adds an edge in the range [1,VertexNumber()] in the array,
286 -- if <isVisible> is FALSE the edge between <vertexIndex> and
287 -- the next edge will not be visible even if the SetEdgeOn() method
288 -- is activated in Graphic3d_AspectFillArea3d class.
289 -- returns the actual edges number.
290 -- Warning: <isVisible> is ignored when the <hasEdgeInfos>
291 -- constructor parameter is FALSE.
292 raises OutOfRange from Standard;
293 -- if the actual edge number is >= <maxEdges>
295 -- -------------------------------------------------------------------
296 -- Methods to modify the array
297 -- -------------------------------------------------------------------
299 Orientate( me:mutable;
300 aNormal: Dir from gp)
301 returns Boolean from Standard;
303 ---Purpose: Orientate correctly all vertexs & normals of this array
304 -- according to the <aNormal> parameter and
305 -- returns TRUE when something has change in the array.
306 -- Warning: When the array has edges this method is apply
307 -- on edge sub array instead on vertex sub array.
309 Orientate( me:mutable;
310 aVertexIndex: Integer from Standard;
311 aVertexNumber: Integer from Standard;
312 aNormal: Dir from gp)
313 returns Boolean from Standard
315 ---Purpose: Orientate correctly a set of vertexs & normal
316 -- from <aVertexIndex> to <aVertexIndex>+<aVertexNumber>-1
317 -- according to the <aNormal> parameter and
318 -- returns TRUE when something has change in the array.
319 -- Warning: When the array has edges this method is apply
320 -- on edge sub array instead on vertex sub array.
321 raises OutOfRange from Standard is private;
322 -- if the <aVertexIndex> parameter is < 1 or > VertexNumber() or
325 Orientate( me:mutable;
326 aBoundIndex: Integer from Standard;
327 aNormal: Dir from gp)
328 returns Boolean from Standard
330 ---Purpose: Orientate correctly all vertexs & normal of the bound <aBound>
331 -- according to the <aNormal> parameter and
332 -- returns TRUE when something has change in the array.
333 -- Warning: When the array has edges this method is apply
334 -- on edge sub array instead on vertex sub array.
335 -- When this array has no bound, <aBoundIndex> design the item number
336 raises OutOfRange from Standard;
337 -- if the <aBoundIndex> parameter is < 1 or > BoundNumber()
338 -- or if the <aBoundIndex> parameter is < 1 or > ItemNumber()
340 SetVertice( me:mutable;
341 anIndex: Integer from Standard;
342 aVertice: Pnt from gp)
344 ---Purpose: Change the vertice of rank <anIndex> in the array.
345 raises OutOfRange from Standard;
346 -- if the index is <1 or > VertexNumber()
348 SetVertice( me:mutable;
349 anIndex: Integer from Standard;
350 X,Y,Z: Real from Standard)
352 ---Purpose: Change the vertice of rank <anIndex> in the array.
353 raises OutOfRange from Standard;
354 -- if the index is <1 or > VertexNumber()
357 SetVertexColor( me : mutable;
358 anIndex : Integer from Standard;
359 aColor : Color from Quantity)
361 ---Purpose: Change the vertex color of rank <anIndex> in the array.
362 raises OutOfRange from Standard;
363 -- if the index is <1 or > VertexNumber()
365 SetVertexColor( me : mutable;
366 anIndex : Integer from Standard;
367 R,G,B : Real from Standard)
369 ---Purpose: Change the vertex color of rank <anIndex> in the array.
370 raises OutOfRange from Standard;
371 -- if the index is <1 or > VertexNumber()
374 SetVertexColor( me : mutable;
375 anIndex : Integer from Standard;
376 aColor : Integer from Standard)
378 ---Purpose: Change the vertex color of rank <anIndex> in the array.
379 -- aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
380 -- On all architecture proccers type (x86 or SPARC) you can
381 -- use this byte order.
382 raises OutOfRange from Standard;
383 -- if the index is <1 or > VertexNumber()
386 SetVertexNormal( me : mutable;
387 anIndex : Integer from Standard;
388 aNormal : Dir from gp)
390 ---Purpose: Change the vertex normal of rank <anIndex> in the array.
391 raises OutOfRange from Standard;
392 -- if the index is <1 or > VertexNumber()
394 SetVertexNormal( me : mutable;
395 anIndex : Integer from Standard;
396 NX,NY,NZ: Real from Standard)
398 ---Purpose: Change the vertex normal of rank <anIndex> in the array.
399 raises OutOfRange from Standard;
400 -- if the index is <1 or > VertexNumber()
403 SetVertexTexel( me:mutable;
404 anIndex: Integer from Standard;
405 aTexel: Pnt2d from gp)
407 ---Purpose: Change the vertex texel of rank <anIndex> in the array.
408 raises OutOfRange from Standard;
409 -- if the index is <1 or > VertexNumber()
411 SetVertexTexel( me:mutable;
412 anIndex: Integer from Standard;
413 TX,TY: Real from Standard)
415 ---Purpose: Change the vertex texel of rank <anIndex> in the array.
416 raises OutOfRange from Standard;
417 -- if the index is <1 or > VertexNumber()
420 SetBoundColor( me:mutable;
421 anIndex: Integer from Standard;
422 aColor: Color from Quantity)
424 ---Purpose: Change the bound color of rank <anIndex> in the array.
425 raises OutOfRange from Standard;
426 -- if the index is <1 or > BoundNumber()
428 SetBoundColor( me:mutable;
429 anIndex: Integer from Standard;
430 R,G,B: Real from Standard)
432 ---Purpose: Change the bound color of rank <anIndex> in the array.
433 raises OutOfRange from Standard;
434 -- if the index is <1 or > BoundNumber()
437 -------------------------------------------------------------------
438 -- Category Inquiries on array
439 -------------------------------------------------------------------
442 returns PrimitiveArray from Graphic3d;
444 ---Purpose: Returns the array address.
448 returns TypeOfPrimitiveArray from Graphic3d;
450 ---Purpose: Returns the type of this primitive
454 returns CString from Standard;
456 ---Purpose: Returns the string type of this primitive
458 HasVertexNormals( me )
459 returns Boolean from Standard;
461 ---Purpose: Returns TRUE when vertex normals array is defined.
464 HasVertexColors( me )
465 returns Boolean from Standard;
467 ---Purpose: Returns TRUE when vertex colors array is defined.
470 HasVertexTexels( me )
471 returns Boolean from Standard;
473 ---Purpose: Returns TRUE when vertex texels array is defined.
477 returns Integer from Standard;
479 ---Purpose: Returns the number of defined vertex
482 Vertice( me ; aRank: Integer from Standard)
485 ---Purpose: Returns the vertice at rank <aRank>
486 -- from the vertex table if defined.
487 raises OutOfRange from Standard;
488 -- when the rank is < 1 or > VertexNumber().
490 Vertice( me ; aRank: Integer from Standard;
491 X,Y,Z: out Real from Standard)
493 ---Purpose: Returns the vertice coordinates at rank <aRank>
494 -- from the vertex table if defined.
495 raises OutOfRange from Standard;
496 -- when the rank is < 1 or > VertexNumber().
499 VertexColor( me ; aRank: Integer from Standard)
500 returns Color from Quantity
502 ---Purpose: Returns the vertex color at rank <aRank>
503 -- from the vertex table if defined.
504 raises OutOfRange from Standard;
505 -- when the rank is < 1 or > VertexNumber().
507 VertexColor( me ; aRank : Integer from Standard;
508 R, G, B : out Real from Standard)
510 ---Purpose: Returns the vertex color values at rank <aRank>
511 -- from the vertex table if defined.
512 raises OutOfRange from Standard;
513 -- when the rank is < 1 or > VertexNumber().
516 VertexColor( me ; aRank: Integer from Standard;
517 aColor: out Integer from Standard)
519 ---Purpose: Returns the vertex color values at rank <aRank>
520 -- from the vertex table if defined.
521 raises OutOfRange from Standard;
522 -- when the rank is < 1 or > VertexNumber().
526 VertexNormal( me ; aRank: Integer from Standard)
529 ---Purpose: Returns the vertex normal at rank <aRank>
530 -- from the vertex table if defined.
531 raises OutOfRange from Standard;
532 -- when the rank is < 1 or > VertexNumber().
534 VertexNormal( me ; aRank: Integer from Standard;
535 NX,NY,NZ: out Real from Standard)
537 ---Purpose: Returns the vertex normal coordinates at rank <aRank>
538 -- from the vertex table if defined.
539 raises OutOfRange from Standard;
540 -- when the rank is < 1 or > VertexNumber().
543 VertexTexel( me ; aRank: Integer from Standard)
544 returns Pnt2d from gp
546 ---Purpose: Returns the vertex texture at rank <aRank>
547 -- from the vertex table if defined.
548 raises OutOfRange from Standard;
549 -- when the rank is < 1 or > VertexNumber().
551 VertexTexel( me ; aRank: Integer from Standard;
552 TX,TY: out Real from Standard)
554 ---Purpose: Returns the vertex texture coordinates at rank <aRank>
555 -- from the vertex table if defined.
556 raises OutOfRange from Standard;
557 -- when the rank is < 1 or > VertexNumber().
561 returns Boolean from Standard;
563 ---Purpose: Returns TRUE when edge visibillity array is defined.
567 returns Integer from Standard;
569 ---Purpose: Returns the number of defined edges
572 Edge( me ; aRank: Integer from Standard)
573 returns Integer from Standard
575 ---Purpose: Returns the vertex index at rank <aRank>
576 -- in the range [1,VertexNumber()]
577 raises OutOfRange from Standard;
578 -- when the rank is < 1 or > EdgeNumber()
581 EdgeIsVisible( me ; aRank: Integer from Standard)
582 returns Boolean from Standard
584 ---Purpose: Returns TRUE when the edge at rank <aRank>
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 -------------------------------------------------------------------
638 ---Purpose: Enable to use the arrays of primitives
639 -- Warning: Updates the current value of the environment symbol
640 -- CSF_USE_ARRAY_OF_PRIMITIVES
644 ---Purpose: Disable to use the arrays of primitives
645 -- Warning: Updates the current value of the environment symbol
646 -- CSF_USE_ARRAY_OF_PRIMITIVES
649 returns Boolean from Standard;
651 ---Purpose: Returns TRUE when the arrays are enable to use.
652 -- Warning: The initial value can be defined seting the symbol
653 -- CSF_USE_ARRAY_OF_PRIMITIVES to "Yes" or "No"
655 IsValid( me:mutable )
656 returns Boolean from Standard;
658 ---Purpose: Returns TRUE only when the contains of this array is
661 ComputeVNormals( me:mutable ; fromIndex,toIndex: Integer from Standard)
665 myPrimitiveArray: PrimitiveArray from Graphic3d;
666 myMaxBounds: Integer from Standard;
667 myMaxVertexs: Integer from Standard;
668 myMaxEdges: Integer from Standard;
671 class Group from Graphic3d