2 // File Aspect_MarkerStyle.cxx
3 // Created Janvier 1995
5 // Modified 23/02/98 : FMN ; Remplacement PI par Standard_PI
6 // JR 02.01.100 : Implicit conversions
8 //-Copyright MatraDatavision 1991,1992
12 //-Design Declaration des variables specifiques aux Type de markers
14 //-Warning Un style est definie, soit par son type predefini TOM_...
15 // soit par sa description dans l'espace -1,+1
24 #include <Aspect_MarkerStyle.ixx>
28 //-Global data definitions
30 // MyMarkerType : TypeOfMarker from Aspect;
31 // MyXpoint : Array1OfShortReal from TShort;
32 // MyYpoint : Array1OfShortReal from TShort;
33 // MySpoint : Array1OfBoolean from TColStd;
41 Aspect_MarkerStyle::Aspect_MarkerStyle () : MyMarkerType(Aspect_TOM_POINT) {
45 Aspect_MarkerStyle::Aspect_MarkerStyle (
46 const Aspect_TypeOfMarker aType) : MyMarkerType(aType) {
50 Aspect_MarkerStyle::Aspect_MarkerStyle (const TColStd_Array1OfReal& aXpoint,
51 const TColStd_Array1OfReal& aYpoint)
52 : MyMarkerType(Aspect_TOM_USERDEFINED) {
53 Standard_Integer i,j=1;
55 MyXpoint = new TShort_HArray1OfShortReal(1,aXpoint.Length());
56 MyYpoint = new TShort_HArray1OfShortReal(1,aXpoint.Length());
57 MySpoint = new TColStd_HArray1OfBoolean(1,aXpoint.Length());
59 if( aXpoint.Length() != aYpoint.Length() ) {
60 Aspect_MarkerStyleDefinitionError::Raise ("Bad Descriptor length") ;
63 for( i=aXpoint.Lower() ; i<=aXpoint.Upper() ; i++,j++ ) {
64 Standard_ShortReal X = (Standard_ShortReal ) aXpoint(i);
65 Standard_ShortReal Y = (Standard_ShortReal ) aYpoint(i);
66 if( X < -1. || X > 1. || Y < -1. || Y > 1. ) {
67 Aspect_MarkerStyleDefinitionError::Raise ("Bad Descriptor value") ;
69 MyXpoint->SetValue(j,X);
70 MyYpoint->SetValue(j,Y);
71 MySpoint->SetValue(j,(j > 1) ? Standard_True : Standard_False);
75 Aspect_MarkerStyle::Aspect_MarkerStyle (const TColStd_Array1OfReal& aXpoint,
76 const TColStd_Array1OfReal& aYpoint,
77 const TColStd_Array1OfBoolean& aSpoint)
78 : MyMarkerType(Aspect_TOM_USERDEFINED) {
79 Standard_Integer i,j=1;
81 MyXpoint = new TShort_HArray1OfShortReal(1,aXpoint.Length());
82 MyYpoint = new TShort_HArray1OfShortReal(1,aXpoint.Length());
83 MySpoint = new TColStd_HArray1OfBoolean(1,aXpoint.Length());
85 if( (aXpoint.Length() != aYpoint.Length()) ||
86 (aXpoint.Length() != aSpoint.Length()) ) {
87 Aspect_MarkerStyleDefinitionError::Raise ("Bad Descriptor length") ;
90 for( i=aXpoint.Lower() ; i<=aXpoint.Upper() ; i++,j++ ) {
91 Standard_ShortReal X = (Standard_ShortReal ) aXpoint(i);
92 Standard_ShortReal Y = (Standard_ShortReal ) aYpoint(i);
93 Standard_Boolean S = aSpoint(i);
94 if( X < -1. || X > 1. || Y < -1. || Y > 1. ) {
95 Aspect_MarkerStyleDefinitionError::Raise ("Bad Descriptor value") ;
97 MyXpoint->SetValue(j,X);
98 MyYpoint->SetValue(j,Y);
99 MySpoint->SetValue(j,S);
100 MySpoint->SetValue(j,(j > 1) ? S : Standard_False);
104 Aspect_MarkerStyle& Aspect_MarkerStyle::Assign (const Aspect_MarkerStyle& Other) {
106 MyMarkerType = Other.MyMarkerType ;
107 MyXpoint = Other.MyXpoint ;
108 MyYpoint = Other.MyYpoint ;
109 MySpoint = Other.MySpoint ;
115 Aspect_TypeOfMarker Aspect_MarkerStyle::Type () const {
120 Standard_Integer Aspect_MarkerStyle::Length () const {
122 return MyXpoint->Length();
125 Standard_Boolean Aspect_MarkerStyle::Values (const Standard_Integer aRank,
126 Standard_Real &X,Standard_Real &Y) const {
128 if( aRank < 1 || aRank > Length() ) {
129 Aspect_MarkerStyleDefinitionError::Raise ("Bad Descriptor rank") ;
132 X = MyXpoint->Value(aRank);
133 Y = MyYpoint->Value(aRank);
134 return MySpoint->Value(aRank);
137 const TShort_Array1OfShortReal& Aspect_MarkerStyle::XValues () const {
139 return MyXpoint->Array1();
142 const TShort_Array1OfShortReal& Aspect_MarkerStyle::YValues () const {
144 return MyYpoint->Array1();
147 const TColStd_Array1OfBoolean& Aspect_MarkerStyle::SValues () const {
149 return MySpoint->Array1();
152 #define MAX_O_POINT 12
153 #define MAX_BALL_LINE 12
155 #define FALSE Standard_False
156 #define TRUE Standard_True
159 void Aspect_MarkerStyle::SetPredefinedStyle() {
161 switch ( MyMarkerType ) {
162 case Aspect_TOM_USERDEFINED :
163 Aspect_MarkerStyleDefinitionError::Raise
164 ("Bad Marker Type Style");
166 case Aspect_TOM_POINT :
167 MyXpoint = new TShort_HArray1OfShortReal(1,5) ;
168 MyYpoint = new TShort_HArray1OfShortReal(1,5) ;
169 MySpoint = new TColStd_HArray1OfBoolean(1,5) ;
171 MyXpoint->SetValue(1,-1.);
172 MyYpoint->SetValue(1,-1.);
173 MySpoint->SetValue(1,FALSE);
175 MyXpoint->SetValue(2,-1.);
176 MyYpoint->SetValue(2,1.);
177 MySpoint->SetValue(2,TRUE);
179 MyXpoint->SetValue(3,1.);
180 MyYpoint->SetValue(3,1.);
181 MySpoint->SetValue(3,TRUE);
183 MyXpoint->SetValue(4,1.);
184 MyYpoint->SetValue(4,-1.);
185 MySpoint->SetValue(4,TRUE);
187 MyXpoint->SetValue(5,-1.);
188 MyYpoint->SetValue(5,-1.);
189 MySpoint->SetValue(5,TRUE);
191 case Aspect_TOM_PLUS :
192 MyXpoint = new TShort_HArray1OfShortReal(1,4) ;
193 MyYpoint = new TShort_HArray1OfShortReal(1,4) ;
194 MySpoint = new TColStd_HArray1OfBoolean(1,4) ;
196 MyXpoint->SetValue(1, 0.);
197 MyYpoint->SetValue(1,-1.);
198 MySpoint->SetValue(1,FALSE);
200 MyXpoint->SetValue(2, 0.);
201 MyYpoint->SetValue(2, 1.);
202 MySpoint->SetValue(2,TRUE);
204 MyXpoint->SetValue(3,-1.);
205 MyYpoint->SetValue(3, 0.);
206 MySpoint->SetValue(3,FALSE);
208 MyXpoint->SetValue(4, 1.);
209 MyYpoint->SetValue(4, 0.);
210 MySpoint->SetValue(4,TRUE);
212 case Aspect_TOM_STAR :
213 MyXpoint = new TShort_HArray1OfShortReal(1,8) ;
214 MyYpoint = new TShort_HArray1OfShortReal(1,8) ;
215 MySpoint = new TColStd_HArray1OfBoolean(1,8) ;
217 MyXpoint->SetValue(1, 0.);
218 MyYpoint->SetValue(1,-1.);
219 MySpoint->SetValue(1,FALSE);
221 MyXpoint->SetValue(2, 0.);
222 MyYpoint->SetValue(2, 1.);
223 MySpoint->SetValue(2,TRUE);
225 MyXpoint->SetValue(3,-1.);
226 MyYpoint->SetValue(3, 0.);
227 MySpoint->SetValue(3,FALSE);
229 MyXpoint->SetValue(4, 1.);
230 MyYpoint->SetValue(4, 0.);
231 MySpoint->SetValue(4,TRUE);
233 MyXpoint->SetValue(5,(float ) -0.7);
234 MyYpoint->SetValue(5,(float ) -0.7);
235 MySpoint->SetValue(5,FALSE);
237 MyXpoint->SetValue(6,(float ) 0.7);
238 MyYpoint->SetValue(6,(float ) 0.7);
239 MySpoint->SetValue(6,TRUE);
241 MyXpoint->SetValue(7,(float ) 0.7);
242 MyYpoint->SetValue(7,(float ) -0.7);
243 MySpoint->SetValue(7,FALSE);
245 MyXpoint->SetValue(8,(float ) -0.7);
246 MyYpoint->SetValue(8,(float ) 0.7);
247 MySpoint->SetValue(8,TRUE);
250 MyXpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+1) ;
251 MyYpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+1) ;
252 MySpoint = new TColStd_HArray1OfBoolean(1,MAX_O_POINT+1) ;
254 { Standard_Integer i;
255 Standard_Real da = 2.*Standard_PI/MAX_O_POINT;
256 Standard_Real a = 0.;
257 for( i=1 ; i<= MAX_O_POINT+1 ; i++,a += da ) {
258 MyXpoint->SetValue(i,(float ) Cos(a));
259 MyYpoint->SetValue(i,(float ) Sin(a));
260 MySpoint->SetValue(i,(i > 1) ? TRUE : FALSE);
263 MyXpoint->SetValue(i,1.);
264 MyYpoint->SetValue(i,0.);
268 MyXpoint = new TShort_HArray1OfShortReal(1,4) ;
269 MyYpoint = new TShort_HArray1OfShortReal(1,4) ;
270 MySpoint = new TColStd_HArray1OfBoolean(1,4) ;
272 MyXpoint->SetValue(1,(float ) -0.7);
273 MyYpoint->SetValue(1,(float ) -0.7);
274 MySpoint->SetValue(1,FALSE);
276 MyXpoint->SetValue(2,(float ) 0.7);
277 MyYpoint->SetValue(2,(float ) 0.7);
278 MySpoint->SetValue(2,TRUE);
280 MyXpoint->SetValue(3,(float ) 0.7);
281 MyYpoint->SetValue(3,(float ) -0.7);
282 MySpoint->SetValue(3,FALSE);
284 MyXpoint->SetValue(4,(float ) -0.7);
285 MyYpoint->SetValue(4,(float ) 0.7);
286 MySpoint->SetValue(4,TRUE);
288 case Aspect_TOM_O_POINT :
289 MyXpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+6) ;
290 MyYpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+6) ;
291 MySpoint = new TColStd_HArray1OfBoolean(1,MAX_O_POINT+6) ;
292 { Standard_Integer i;
293 Standard_Real da = 2.*Standard_PI/MAX_O_POINT;
294 Standard_Real a = 0.;
295 for( i=1 ; i<= MAX_O_POINT+1 ; i++,a += da ) {
296 MyXpoint->SetValue(i,(float ) Cos(a));
297 MyYpoint->SetValue(i,(float ) Sin(a));
298 MySpoint->SetValue(i,(i > 1) ? TRUE : FALSE);
301 MyXpoint->SetValue(i,1.);
302 MyYpoint->SetValue(i,0.);
304 MyXpoint->SetValue(i+1,-0.25);
305 MyYpoint->SetValue(i+1,-0.25);
306 MySpoint->SetValue(i+1,FALSE);
308 MyXpoint->SetValue(i+2,-0.25);
309 MyYpoint->SetValue(i+2,0.25);
310 MySpoint->SetValue(i+2,TRUE);
312 MyXpoint->SetValue(i+3,0.25);
313 MyYpoint->SetValue(i+3,0.25);
314 MySpoint->SetValue(i+3,TRUE);
316 MyXpoint->SetValue(i+4,0.25);
317 MyYpoint->SetValue(i+4,-0.25);
318 MySpoint->SetValue(i+4,TRUE);
320 MyXpoint->SetValue(i+5,-0.25);
321 MyYpoint->SetValue(i+5,-0.25);
322 MySpoint->SetValue(i+5,TRUE);
325 case Aspect_TOM_O_PLUS :
326 MyXpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+5) ;
327 MyYpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+5) ;
328 MySpoint = new TColStd_HArray1OfBoolean(1,MAX_O_POINT+5) ;
330 { Standard_Integer i;
331 Standard_Real da = 2.*Standard_PI/MAX_O_POINT;
332 Standard_Real a = 0.;
333 for( i=1 ; i<= MAX_O_POINT+1 ; i++,a += da ) {
334 MyXpoint->SetValue(i,(float ) Cos(a));
335 MyYpoint->SetValue(i,(float ) Sin(a));
336 MySpoint->SetValue(i,(i > 1) ? TRUE : FALSE);
339 MyXpoint->SetValue(i,1.);
340 MyYpoint->SetValue(i,0.);
342 MyXpoint->SetValue(i+1,0.);
343 MyYpoint->SetValue(i+1,-0.5);
344 MySpoint->SetValue(i+1,FALSE);
346 MyXpoint->SetValue(i+2,0.);
347 MyYpoint->SetValue(i+2,0.5);
348 MySpoint->SetValue(i+2,TRUE);
350 MyXpoint->SetValue(i+3,-0.5);
351 MyYpoint->SetValue(i+3,0.);
352 MySpoint->SetValue(i+3,FALSE);
354 MyXpoint->SetValue(i+4,0.5);
355 MyYpoint->SetValue(i+4,0.);
356 MySpoint->SetValue(i+4,TRUE);
359 case Aspect_TOM_O_STAR :
360 MyXpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+9) ;
361 MyYpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+9) ;
362 MySpoint = new TColStd_HArray1OfBoolean(1,MAX_O_POINT+9) ;
364 { Standard_Integer i;
365 Standard_Real da = 2.*Standard_PI/MAX_O_POINT;
366 Standard_Real a = 0.;
367 for( i=1 ; i<= MAX_O_POINT+1 ; i++,a += da ) {
368 MyXpoint->SetValue(i,(float ) Cos(a));
369 MyYpoint->SetValue(i,(float ) Sin(a));
370 MySpoint->SetValue(i,(i > 1) ? TRUE : FALSE);
373 MyXpoint->SetValue(i,1.);
374 MyYpoint->SetValue(i,0.);
376 MyXpoint->SetValue(i+1, 0.);
377 MyYpoint->SetValue(i+1,-0.5);
378 MySpoint->SetValue(i+1,FALSE);
380 MyXpoint->SetValue(i+2, 0.);
381 MyYpoint->SetValue(i+2,0.5);
382 MySpoint->SetValue(i+2,TRUE);
384 MyXpoint->SetValue(i+3,-0.5);
385 MyYpoint->SetValue(i+3, 0.);
386 MySpoint->SetValue(i+3,FALSE);
388 MyXpoint->SetValue(i+4,0.5);
389 MyYpoint->SetValue(i+4, 0.);
390 MySpoint->SetValue(i+4,TRUE);
392 MyXpoint->SetValue(i+5,(float ) -0.35);
393 MyYpoint->SetValue(i+5,(float ) -0.35);
394 MySpoint->SetValue(i+5,FALSE);
396 MyXpoint->SetValue(i+6,(float ) 0.35);
397 MyYpoint->SetValue(i+6,(float ) 0.35);
398 MySpoint->SetValue(i+6,TRUE);
400 MyXpoint->SetValue(i+7,(float ) 0.35);
401 MyYpoint->SetValue(i+7,(float ) -0.35);
402 MySpoint->SetValue(i+7,FALSE);
404 MyXpoint->SetValue(i+8,(float ) -0.35);
405 MyYpoint->SetValue(i+8,(float ) 0.35);
406 MySpoint->SetValue(i+8,TRUE);
409 case Aspect_TOM_O_X :
410 MyXpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+5) ;
411 MyYpoint = new TShort_HArray1OfShortReal(1,MAX_O_POINT+5) ;
412 MySpoint = new TColStd_HArray1OfBoolean(1,MAX_O_POINT+5) ;
414 { Standard_Integer i;
415 Standard_Real da = 2.*Standard_PI/MAX_O_POINT;
416 Standard_Real a = 0.;
417 for( i=1 ; i<= MAX_O_POINT+1 ; i++,a += da ) {
418 MyXpoint->SetValue(i,(float ) Cos(a));
419 MyYpoint->SetValue(i,(float ) Sin(a));
420 MySpoint->SetValue(i,(i > 1) ? TRUE : FALSE);
423 MyXpoint->SetValue(i,1.);
424 MyYpoint->SetValue(i,0.);
426 MyXpoint->SetValue(i+1,(float ) -0.35);
427 MyYpoint->SetValue(i+1,(float ) -0.35);
428 MySpoint->SetValue(i+1,FALSE);
430 MyXpoint->SetValue(i+2,(float ) 0.35);
431 MyYpoint->SetValue(i+2,(float ) 0.35);
432 MySpoint->SetValue(i+2,TRUE);
434 MyXpoint->SetValue(i+3,(float ) 0.35);
435 MyYpoint->SetValue(i+3,(float ) -0.35);
436 MySpoint->SetValue(i+3,FALSE);
438 MyXpoint->SetValue(i+4,(float ) -0.35);
439 MyYpoint->SetValue(i+4,(float ) 0.35);
440 MySpoint->SetValue(i+4,TRUE);
443 case Aspect_TOM_BALL :
444 MyXpoint = new TShort_HArray1OfShortReal(1,
445 MAX_BALL_LINE*(MAX_O_POINT+1)) ;
446 MyYpoint = new TShort_HArray1OfShortReal(1,
447 MAX_BALL_LINE*(MAX_O_POINT+1)) ;
448 MySpoint = new TColStd_HArray1OfBoolean(1,
449 MAX_BALL_LINE*(MAX_O_POINT+1)) ;
451 { Standard_Integer i,j,n = 0;
452 Standard_Real da = 2.*Standard_PI/MAX_O_POINT;
453 Standard_Real dr = 1./MAX_BALL_LINE;
454 Standard_Real a,r = 1.;
456 for( i=1 ; i<= MAX_BALL_LINE ; i++ ) {
458 for( j=1 ; j<= MAX_O_POINT+1 ; j++,a += da ) {
460 MyXpoint->SetValue(n,(float )( r*Cos(a)));
461 MyYpoint->SetValue(n,(float )( r*Sin(a)));
462 MySpoint->SetValue(n,(j > 1) ? TRUE : FALSE);
464 MyXpoint->SetValue(n,(float ) r);
465 MyYpoint->SetValue(n,0.);
470 case Aspect_TOM_RING1 :
471 MyXpoint = new TShort_HArray1OfShortReal(1,
472 (MAX_BALL_LINE/4)*(MAX_O_POINT+1)) ;
473 MyYpoint = new TShort_HArray1OfShortReal(1,
474 (MAX_BALL_LINE/4)*(MAX_O_POINT+1)) ;
475 MySpoint = new TColStd_HArray1OfBoolean(1,
476 (MAX_BALL_LINE/4)*(MAX_O_POINT+1)) ;
478 { Standard_Integer i,j,n = 0;
479 Standard_Real da = 2.*Standard_PI/MAX_O_POINT;
480 Standard_Real dr = 1./MAX_BALL_LINE;
481 Standard_Real a,r = 1.;
483 for( i=1 ; i<= MAX_BALL_LINE/4 ; i++ ) {
485 for( j=1 ; j<= MAX_O_POINT+1 ; j++,a += da ) {
487 MyXpoint->SetValue(n,(float )( r*Cos(a)));
488 MyYpoint->SetValue(n,(float )( r*Sin(a)));
489 MySpoint->SetValue(n,(j > 1) ? TRUE : FALSE);
491 MyXpoint->SetValue(n,(float ) r);
492 MyYpoint->SetValue(n,0.);
497 case Aspect_TOM_RING2 :
498 MyXpoint = new TShort_HArray1OfShortReal(1,
499 (MAX_BALL_LINE/3)*(MAX_O_POINT+1)) ;
500 MyYpoint = new TShort_HArray1OfShortReal(1,
501 (MAX_BALL_LINE/3)*(MAX_O_POINT+1)) ;
502 MySpoint = new TColStd_HArray1OfBoolean(1,
503 (MAX_BALL_LINE/3)*(MAX_O_POINT+1)) ;
505 { Standard_Integer i,j,n = 0;
506 Standard_Real da = 2.*Standard_PI/MAX_O_POINT;
507 Standard_Real dr = 1./MAX_BALL_LINE;
508 Standard_Real a,r = 1.;
510 for( i=1 ; i<= MAX_BALL_LINE/3 ; i++ ) {
512 for( j=1 ; j<= MAX_O_POINT+1 ; j++,a += da ) {
514 MyXpoint->SetValue(n,(float )( r*Cos(a)));
515 MyYpoint->SetValue(n,(float )( r*Sin(a)));
516 MySpoint->SetValue(n,(j > 1) ? TRUE : FALSE);
518 MyXpoint->SetValue(n,(float ) r);
519 MyYpoint->SetValue(n,0.);
524 case Aspect_TOM_RING3 :
525 MyXpoint = new TShort_HArray1OfShortReal(1,
526 (MAX_BALL_LINE)/2*(MAX_O_POINT+1)) ;
527 MyYpoint = new TShort_HArray1OfShortReal(1,
528 (MAX_BALL_LINE)/2*(MAX_O_POINT+1)) ;
529 MySpoint = new TColStd_HArray1OfBoolean(1,
530 (MAX_BALL_LINE)/2*(MAX_O_POINT+1)) ;
532 { Standard_Integer i,j,n = 0;
533 Standard_Real da = 2.*Standard_PI/MAX_O_POINT;
534 Standard_Real dr = 1./MAX_BALL_LINE;
535 Standard_Real a,r = 1.;
537 for( i=1 ; i<= MAX_BALL_LINE/2 ; i++ ) {
539 for( j=1 ; j<= MAX_O_POINT+1 ; j++,a += da ) {
541 MyXpoint->SetValue(n,(float )( r*Cos(a)));
542 MyYpoint->SetValue(n,(float )( r*Sin(a)));
543 MySpoint->SetValue(n,(j > 1) ? TRUE : FALSE);
545 MyXpoint->SetValue(n,(float ) r);
546 MyYpoint->SetValue(n,0.);
555 Standard_Boolean Aspect_MarkerStyle::IsEqual(const Aspect_MarkerStyle& Other) const
558 (MyMarkerType == Other.MyMarkerType) &&
559 (MyXpoint == Other.MyXpoint) &&
560 (MyYpoint == Other.MyYpoint) &&
561 (MySpoint == Other.MySpoint));
564 Standard_Boolean Aspect_MarkerStyle::IsNotEqual(const Aspect_MarkerStyle& Other) const
566 return !IsEqual(Other);