1 // Created on: 1995-01-14
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 // Modified 23/02/98 : FMN ; Remplacement PI par Standard_PI
23 // JR 02.01.100 : Implicit conversions
28 //-Design Declaration des variables specifiques aux Type de markers
30 //-Warning Un style est definie, soit par son type predefini TOM_...
31 // soit par sa description dans l'espace -1,+1
40 #include <Aspect_MarkerStyle.ixx>
44 //-Global data definitions
46 // MyMarkerType : TypeOfMarker from Aspect;
47 // MyXpoint : Array1OfShortReal from TShort;
48 // MyYpoint : Array1OfShortReal from TShort;
49 // MySpoint : Array1OfBoolean from TColStd;
57 Aspect_MarkerStyle::Aspect_MarkerStyle () : MyMarkerType(Aspect_TOM_POINT) {
61 Aspect_MarkerStyle::Aspect_MarkerStyle (
62 const Aspect_TypeOfMarker aType) : MyMarkerType(aType) {
66 Aspect_MarkerStyle::Aspect_MarkerStyle (const TColStd_Array1OfReal& aXpoint,
67 const TColStd_Array1OfReal& aYpoint)
68 : MyMarkerType(Aspect_TOM_USERDEFINED) {
69 Standard_Integer i,j=1;
71 MyXpoint = new TShort_HArray1OfShortReal(1,aXpoint.Length());
72 MyYpoint = new TShort_HArray1OfShortReal(1,aXpoint.Length());
73 MySpoint = new TColStd_HArray1OfBoolean(1,aXpoint.Length());
75 if( aXpoint.Length() != aYpoint.Length() ) {
76 Aspect_MarkerStyleDefinitionError::Raise ("Bad Descriptor length") ;
79 for( i=aXpoint.Lower() ; i<=aXpoint.Upper() ; i++,j++ ) {
80 Standard_ShortReal X = (Standard_ShortReal ) aXpoint(i);
81 Standard_ShortReal Y = (Standard_ShortReal ) aYpoint(i);
82 if( X < -1. || X > 1. || Y < -1. || Y > 1. ) {
83 Aspect_MarkerStyleDefinitionError::Raise ("Bad Descriptor value") ;
85 MyXpoint->SetValue(j,X);
86 MyYpoint->SetValue(j,Y);
87 MySpoint->SetValue(j,(j > 1) ? Standard_True : Standard_False);
91 Aspect_MarkerStyle::Aspect_MarkerStyle (const TColStd_Array1OfReal& aXpoint,
92 const TColStd_Array1OfReal& aYpoint,
93 const TColStd_Array1OfBoolean& aSpoint)
94 : MyMarkerType(Aspect_TOM_USERDEFINED) {
95 Standard_Integer i,j=1;
97 MyXpoint = new TShort_HArray1OfShortReal(1,aXpoint.Length());
98 MyYpoint = new TShort_HArray1OfShortReal(1,aXpoint.Length());
99 MySpoint = new TColStd_HArray1OfBoolean(1,aXpoint.Length());
101 if( (aXpoint.Length() != aYpoint.Length()) ||
102 (aXpoint.Length() != aSpoint.Length()) ) {
103 Aspect_MarkerStyleDefinitionError::Raise ("Bad Descriptor length") ;
106 for( i=aXpoint.Lower() ; i<=aXpoint.Upper() ; i++,j++ ) {
107 Standard_ShortReal X = (Standard_ShortReal ) aXpoint(i);
108 Standard_ShortReal Y = (Standard_ShortReal ) aYpoint(i);
109 Standard_Boolean S = aSpoint(i);
110 if( X < -1. || X > 1. || Y < -1. || Y > 1. ) {
111 Aspect_MarkerStyleDefinitionError::Raise ("Bad Descriptor value") ;
113 MyXpoint->SetValue(j,X);
114 MyYpoint->SetValue(j,Y);
115 MySpoint->SetValue(j,S);
116 MySpoint->SetValue(j,(j > 1) ? S : Standard_False);
120 Aspect_MarkerStyle& Aspect_MarkerStyle::Assign (const Aspect_MarkerStyle& Other) {
122 MyMarkerType = Other.MyMarkerType ;
123 MyXpoint = Other.MyXpoint ;
124 MyYpoint = Other.MyYpoint ;
125 MySpoint = Other.MySpoint ;
131 Aspect_TypeOfMarker Aspect_MarkerStyle::Type () const {
136 Standard_Integer Aspect_MarkerStyle::Length () const {
138 return MyXpoint->Length();
141 Standard_Boolean Aspect_MarkerStyle::Values (const Standard_Integer aRank,
142 Standard_Real &X,Standard_Real &Y) const {
144 if( aRank < 1 || aRank > Length() ) {
145 Aspect_MarkerStyleDefinitionError::Raise ("Bad Descriptor rank") ;
148 X = MyXpoint->Value(aRank);
149 Y = MyYpoint->Value(aRank);
150 return MySpoint->Value(aRank);
153 const TShort_Array1OfShortReal& Aspect_MarkerStyle::XValues () const {
155 return MyXpoint->Array1();
158 const TShort_Array1OfShortReal& Aspect_MarkerStyle::YValues () const {
160 return MyYpoint->Array1();
163 const TColStd_Array1OfBoolean& Aspect_MarkerStyle::SValues () const {
165 return MySpoint->Array1();
168 #define MAX_O_POINT 12
169 #define MAX_BALL_LINE 12
171 #define FALSE Standard_False
172 #define TRUE Standard_True
175 void Aspect_MarkerStyle::SetPredefinedStyle() {
177 switch ( MyMarkerType ) {
178 case Aspect_TOM_USERDEFINED :
179 Aspect_MarkerStyleDefinitionError::Raise
180 ("Bad Marker Type Style");
182 case Aspect_TOM_POINT :
183 MyXpoint = new TShort_HArray1OfShortReal(1,5) ;
184 MyYpoint = new TShort_HArray1OfShortReal(1,5) ;
185 MySpoint = new TColStd_HArray1OfBoolean(1,5) ;
187 MyXpoint->SetValue(1,-1.);
188 MyYpoint->SetValue(1,-1.);
189 MySpoint->SetValue(1,FALSE);
191 MyXpoint->SetValue(2,-1.);
192 MyYpoint->SetValue(2,1.);
193 MySpoint->SetValue(2,TRUE);
195 MyXpoint->SetValue(3,1.);
196 MyYpoint->SetValue(3,1.);
197 MySpoint->SetValue(3,TRUE);
199 MyXpoint->SetValue(4,1.);
200 MyYpoint->SetValue(4,-1.);
201 MySpoint->SetValue(4,TRUE);
203 MyXpoint->SetValue(5,-1.);
204 MyYpoint->SetValue(5,-1.);
205 MySpoint->SetValue(5,TRUE);
207 case Aspect_TOM_PLUS :
208 MyXpoint = new TShort_HArray1OfShortReal(1,4) ;
209 MyYpoint = new TShort_HArray1OfShortReal(1,4) ;
210 MySpoint = new TColStd_HArray1OfBoolean(1,4) ;
212 MyXpoint->SetValue(1, 0.);
213 MyYpoint->SetValue(1,-1.);
214 MySpoint->SetValue(1,FALSE);
216 MyXpoint->SetValue(2, 0.);
217 MyYpoint->SetValue(2, 1.);
218 MySpoint->SetValue(2,TRUE);
220 MyXpoint->SetValue(3,-1.);
221 MyYpoint->SetValue(3, 0.);
222 MySpoint->SetValue(3,FALSE);
224 MyXpoint->SetValue(4, 1.);
225 MyYpoint->SetValue(4, 0.);
226 MySpoint->SetValue(4,TRUE);
228 case Aspect_TOM_STAR :
229 MyXpoint = new TShort_HArray1OfShortReal(1,8) ;
230 MyYpoint = new TShort_HArray1OfShortReal(1,8) ;
231 MySpoint = new TColStd_HArray1OfBoolean(1,8) ;
233 MyXpoint->SetValue(1, 0.);
234 MyYpoint->SetValue(1,-1.);
235 MySpoint->SetValue(1,FALSE);
237 MyXpoint->SetValue(2, 0.);
238 MyYpoint->SetValue(2, 1.);
239 MySpoint->SetValue(2,TRUE);
241 MyXpoint->SetValue(3,-1.);
242 MyYpoint->SetValue(3, 0.);
243 MySpoint->SetValue(3,FALSE);
245 MyXpoint->SetValue(4, 1.);
246 MyYpoint->SetValue(4, 0.);
247 MySpoint->SetValue(4,TRUE);
249 MyXpoint->SetValue(5,(float ) -0.7);
250 MyYpoint->SetValue(5,(float ) -0.7);
251 MySpoint->SetValue(5,FALSE);
253 MyXpoint->SetValue(6,(float ) 0.7);
254 MyYpoint->SetValue(6,(float ) 0.7);
255 MySpoint->SetValue(6,TRUE);
257 MyXpoint->SetValue(7,(float ) 0.7);
258 MyYpoint->SetValue(7,(float ) -0.7);
259 MySpoint->SetValue(7,FALSE);
261 MyXpoint->SetValue(8,(float ) -0.7);
262 MyYpoint->SetValue(8,(float ) 0.7);
263 MySpoint->SetValue(8,TRUE);
266 MyXpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+1) ;
267 MyYpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+1) ;
268 MySpoint = new TColStd_HArray1OfBoolean(1,MAX_O_POINT+1) ;
270 { Standard_Integer i;
271 Standard_Real da = 2. * M_PI / MAX_O_POINT;
272 Standard_Real a = 0.;
273 for( i=1 ; i<= MAX_O_POINT+1 ; i++,a += da ) {
274 MyXpoint->SetValue(i,(float ) Cos(a));
275 MyYpoint->SetValue(i,(float ) Sin(a));
276 MySpoint->SetValue(i,(i > 1) ? TRUE : FALSE);
279 MyXpoint->SetValue(i,1.);
280 MyYpoint->SetValue(i,0.);
284 MyXpoint = new TShort_HArray1OfShortReal(1,4) ;
285 MyYpoint = new TShort_HArray1OfShortReal(1,4) ;
286 MySpoint = new TColStd_HArray1OfBoolean(1,4) ;
288 MyXpoint->SetValue(1,(float ) -0.7);
289 MyYpoint->SetValue(1,(float ) -0.7);
290 MySpoint->SetValue(1,FALSE);
292 MyXpoint->SetValue(2,(float ) 0.7);
293 MyYpoint->SetValue(2,(float ) 0.7);
294 MySpoint->SetValue(2,TRUE);
296 MyXpoint->SetValue(3,(float ) 0.7);
297 MyYpoint->SetValue(3,(float ) -0.7);
298 MySpoint->SetValue(3,FALSE);
300 MyXpoint->SetValue(4,(float ) -0.7);
301 MyYpoint->SetValue(4,(float ) 0.7);
302 MySpoint->SetValue(4,TRUE);
304 case Aspect_TOM_O_POINT :
305 MyXpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+6) ;
306 MyYpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+6) ;
307 MySpoint = new TColStd_HArray1OfBoolean(1,MAX_O_POINT+6) ;
308 { Standard_Integer i;
309 Standard_Real da = 2. * M_PI / MAX_O_POINT;
310 Standard_Real a = 0.;
311 for( i=1 ; i<= MAX_O_POINT+1 ; i++,a += da ) {
312 MyXpoint->SetValue(i,(float ) Cos(a));
313 MyYpoint->SetValue(i,(float ) Sin(a));
314 MySpoint->SetValue(i,(i > 1) ? TRUE : FALSE);
317 MyXpoint->SetValue(i,1.);
318 MyYpoint->SetValue(i,0.);
320 MyXpoint->SetValue(i+1,-0.25);
321 MyYpoint->SetValue(i+1,-0.25);
322 MySpoint->SetValue(i+1,FALSE);
324 MyXpoint->SetValue(i+2,-0.25);
325 MyYpoint->SetValue(i+2,0.25);
326 MySpoint->SetValue(i+2,TRUE);
328 MyXpoint->SetValue(i+3,0.25);
329 MyYpoint->SetValue(i+3,0.25);
330 MySpoint->SetValue(i+3,TRUE);
332 MyXpoint->SetValue(i+4,0.25);
333 MyYpoint->SetValue(i+4,-0.25);
334 MySpoint->SetValue(i+4,TRUE);
336 MyXpoint->SetValue(i+5,-0.25);
337 MyYpoint->SetValue(i+5,-0.25);
338 MySpoint->SetValue(i+5,TRUE);
341 case Aspect_TOM_O_PLUS :
342 MyXpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+5) ;
343 MyYpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+5) ;
344 MySpoint = new TColStd_HArray1OfBoolean(1,MAX_O_POINT+5) ;
346 { Standard_Integer i;
347 Standard_Real da = 2. * M_PI / MAX_O_POINT;
348 Standard_Real a = 0.;
349 for( i=1 ; i<= MAX_O_POINT+1 ; i++,a += da ) {
350 MyXpoint->SetValue(i,(float ) Cos(a));
351 MyYpoint->SetValue(i,(float ) Sin(a));
352 MySpoint->SetValue(i,(i > 1) ? TRUE : FALSE);
355 MyXpoint->SetValue(i,1.);
356 MyYpoint->SetValue(i,0.);
358 MyXpoint->SetValue(i+1,0.);
359 MyYpoint->SetValue(i+1,-0.5);
360 MySpoint->SetValue(i+1,FALSE);
362 MyXpoint->SetValue(i+2,0.);
363 MyYpoint->SetValue(i+2,0.5);
364 MySpoint->SetValue(i+2,TRUE);
366 MyXpoint->SetValue(i+3,-0.5);
367 MyYpoint->SetValue(i+3,0.);
368 MySpoint->SetValue(i+3,FALSE);
370 MyXpoint->SetValue(i+4,0.5);
371 MyYpoint->SetValue(i+4,0.);
372 MySpoint->SetValue(i+4,TRUE);
375 case Aspect_TOM_O_STAR :
376 MyXpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+9) ;
377 MyYpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+9) ;
378 MySpoint = new TColStd_HArray1OfBoolean(1,MAX_O_POINT+9) ;
380 { Standard_Integer i;
381 Standard_Real da = 2. * M_PI / MAX_O_POINT;
382 Standard_Real a = 0.;
383 for( i=1 ; i<= MAX_O_POINT+1 ; i++,a += da ) {
384 MyXpoint->SetValue(i,(float ) Cos(a));
385 MyYpoint->SetValue(i,(float ) Sin(a));
386 MySpoint->SetValue(i,(i > 1) ? TRUE : FALSE);
389 MyXpoint->SetValue(i,1.);
390 MyYpoint->SetValue(i,0.);
392 MyXpoint->SetValue(i+1, 0.);
393 MyYpoint->SetValue(i+1,-0.5);
394 MySpoint->SetValue(i+1,FALSE);
396 MyXpoint->SetValue(i+2, 0.);
397 MyYpoint->SetValue(i+2,0.5);
398 MySpoint->SetValue(i+2,TRUE);
400 MyXpoint->SetValue(i+3,-0.5);
401 MyYpoint->SetValue(i+3, 0.);
402 MySpoint->SetValue(i+3,FALSE);
404 MyXpoint->SetValue(i+4,0.5);
405 MyYpoint->SetValue(i+4, 0.);
406 MySpoint->SetValue(i+4,TRUE);
408 MyXpoint->SetValue(i+5,(float ) -0.35);
409 MyYpoint->SetValue(i+5,(float ) -0.35);
410 MySpoint->SetValue(i+5,FALSE);
412 MyXpoint->SetValue(i+6,(float ) 0.35);
413 MyYpoint->SetValue(i+6,(float ) 0.35);
414 MySpoint->SetValue(i+6,TRUE);
416 MyXpoint->SetValue(i+7,(float ) 0.35);
417 MyYpoint->SetValue(i+7,(float ) -0.35);
418 MySpoint->SetValue(i+7,FALSE);
420 MyXpoint->SetValue(i+8,(float ) -0.35);
421 MyYpoint->SetValue(i+8,(float ) 0.35);
422 MySpoint->SetValue(i+8,TRUE);
425 case Aspect_TOM_O_X :
426 MyXpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+5) ;
427 MyYpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+5) ;
428 MySpoint = new TColStd_HArray1OfBoolean(1,MAX_O_POINT+5) ;
430 { Standard_Integer i;
431 Standard_Real da = 2. * M_PI / MAX_O_POINT;
432 Standard_Real a = 0.;
433 for( i=1 ; i<= MAX_O_POINT+1 ; i++,a += da ) {
434 MyXpoint->SetValue(i,(float ) Cos(a));
435 MyYpoint->SetValue(i,(float ) Sin(a));
436 MySpoint->SetValue(i,(i > 1) ? TRUE : FALSE);
439 MyXpoint->SetValue(i,1.);
440 MyYpoint->SetValue(i,0.);
442 MyXpoint->SetValue(i+1,(float ) -0.35);
443 MyYpoint->SetValue(i+1,(float ) -0.35);
444 MySpoint->SetValue(i+1,FALSE);
446 MyXpoint->SetValue(i+2,(float ) 0.35);
447 MyYpoint->SetValue(i+2,(float ) 0.35);
448 MySpoint->SetValue(i+2,TRUE);
450 MyXpoint->SetValue(i+3,(float ) 0.35);
451 MyYpoint->SetValue(i+3,(float ) -0.35);
452 MySpoint->SetValue(i+3,FALSE);
454 MyXpoint->SetValue(i+4,(float ) -0.35);
455 MyYpoint->SetValue(i+4,(float ) 0.35);
456 MySpoint->SetValue(i+4,TRUE);
459 case Aspect_TOM_RING1 :
460 MyXpoint = new TShort_HArray1OfShortReal(1,
461 (MAX_BALL_LINE/4)*(MAX_O_POINT+1)) ;
462 MyYpoint = new TShort_HArray1OfShortReal(1,
463 (MAX_BALL_LINE/4)*(MAX_O_POINT+1)) ;
464 MySpoint = new TColStd_HArray1OfBoolean(1,
465 (MAX_BALL_LINE/4)*(MAX_O_POINT+1)) ;
467 { Standard_Integer i,j,n = 0;
468 Standard_Real da = 2. * M_PI / MAX_O_POINT;
469 Standard_Real dr = 1./MAX_BALL_LINE;
470 Standard_Real a,r = 1.;
472 for( i=1 ; i<= MAX_BALL_LINE/4 ; i++ ) {
474 for( j=1 ; j<= MAX_O_POINT+1 ; j++,a += da ) {
476 MyXpoint->SetValue(n,(float )( r*Cos(a)));
477 MyYpoint->SetValue(n,(float )( r*Sin(a)));
478 MySpoint->SetValue(n,(j > 1) ? TRUE : FALSE);
480 MyXpoint->SetValue(n,(float ) r);
481 MyYpoint->SetValue(n,0.);
486 case Aspect_TOM_RING2 :
487 MyXpoint = new TShort_HArray1OfShortReal(1,
488 (MAX_BALL_LINE/3)*(MAX_O_POINT+1)) ;
489 MyYpoint = new TShort_HArray1OfShortReal(1,
490 (MAX_BALL_LINE/3)*(MAX_O_POINT+1)) ;
491 MySpoint = new TColStd_HArray1OfBoolean(1,
492 (MAX_BALL_LINE/3)*(MAX_O_POINT+1)) ;
494 { Standard_Integer i,j,n = 0;
495 Standard_Real da = 2. * M_PI / MAX_O_POINT;
496 Standard_Real dr = 1./MAX_BALL_LINE;
497 Standard_Real a,r = 1.;
499 for( i=1 ; i<= MAX_BALL_LINE/3 ; i++ ) {
501 for( j=1 ; j<= MAX_O_POINT+1 ; j++,a += da ) {
503 MyXpoint->SetValue(n,(float )( r*Cos(a)));
504 MyYpoint->SetValue(n,(float )( r*Sin(a)));
505 MySpoint->SetValue(n,(j > 1) ? TRUE : FALSE);
507 MyXpoint->SetValue(n,(float ) r);
508 MyYpoint->SetValue(n,0.);
513 case Aspect_TOM_RING3 :
514 MyXpoint = new TShort_HArray1OfShortReal(1,
515 (MAX_BALL_LINE)/2*(MAX_O_POINT+1)) ;
516 MyYpoint = new TShort_HArray1OfShortReal(1,
517 (MAX_BALL_LINE)/2*(MAX_O_POINT+1)) ;
518 MySpoint = new TColStd_HArray1OfBoolean(1,
519 (MAX_BALL_LINE)/2*(MAX_O_POINT+1)) ;
521 { Standard_Integer i,j,n = 0;
522 Standard_Real da = 2. * M_PI / MAX_O_POINT;
523 Standard_Real dr = 1./MAX_BALL_LINE;
524 Standard_Real a,r = 1.;
526 for( i=1 ; i<= MAX_BALL_LINE/2 ; i++ ) {
528 for( j=1 ; j<= MAX_O_POINT+1 ; j++,a += da ) {
530 MyXpoint->SetValue(n,(float )( r*Cos(a)));
531 MyYpoint->SetValue(n,(float )( r*Sin(a)));
532 MySpoint->SetValue(n,(j > 1) ? TRUE : FALSE);
534 MyXpoint->SetValue(n,(float ) r);
535 MyYpoint->SetValue(n,0.);
544 Standard_Boolean Aspect_MarkerStyle::IsEqual(const Aspect_MarkerStyle& Other) const
547 (MyMarkerType == Other.MyMarkerType) &&
548 (MyXpoint == Other.MyXpoint) &&
549 (MyYpoint == Other.MyYpoint) &&
550 (MySpoint == Other.MySpoint));
553 Standard_Boolean Aspect_MarkerStyle::IsNotEqual(const Aspect_MarkerStyle& Other) const
555 return !IsEqual(Other);