Salome HOME
[bos #37951][EDF 25230] SIGSEGV with MakeVertexInsideFace. Added check for an uniniti...
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_ShapeInfo.cxx
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include <GEOMAlgo_ShapeInfo.hxx>
21
22 static
23   Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType);
24 static
25   void DumpKindOfShape(const GEOMAlgo_KindOfShape aKS);
26 static
27   void DumpKindOfClosed(const GEOMAlgo_KindOfClosed aKC);
28 static
29   void DumpKindOfBounds(const GEOMAlgo_KindOfBounds aKB);
30 static
31   void DumpKindOfName(const GEOMAlgo_KindOfName aKS);
32 static
33   void DumpKindOfDef(const GEOMAlgo_KindOfDef aKD);
34 static
35   void DumpKindOfPeriod(const GEOMAlgo_KindOfPeriod aKP);
36 static
37   void DumpPosition(const gp_Ax3& aAx3);
38 static
39   void DumpLocation(const gp_Pnt& aP);
40 static
41   void DumpDirection(const gp_Dir& aD);
42 //=======================================================================
43 //function :
44 //purpose  :
45 //=======================================================================
46 GEOMAlgo_ShapeInfo::GEOMAlgo_ShapeInfo()
47 {
48   Reset();
49 }
50 //=======================================================================
51 //function : ~
52 //purpose  :
53 //=======================================================================
54 GEOMAlgo_ShapeInfo::~GEOMAlgo_ShapeInfo()
55 {
56 }
57 //=======================================================================
58 //function : Reset
59 //purpose  :
60 //=======================================================================
61 void GEOMAlgo_ShapeInfo::Reset()
62 {
63   Standard_Integer i;
64   //
65   myType=TopAbs_SHAPE;
66   //
67   myNbTypes=9;
68   for (i=0; i<myNbTypes; ++i) {
69     myNbSubShapes[i]=0;
70   }
71   //
72   myKindOfShape=GEOMAlgo_KS_UNKNOWN;
73   myKindOfBounds=GEOMAlgo_KB_UNKNOWN;
74   myKindOfClosed=GEOMAlgo_KC_UNKNOWN;
75   myKindOfName=GEOMAlgo_KN_UNKNOWN;
76   myKindOfDef=GEOMAlgo_KD_UNKNOWN;
77   myKindOfPeriod=GEOMAlgo_KP_UNKNOWN;
78   //
79   myLocation.SetCoord(99., 99., 99.);
80   myDirection.SetCoord(1.,0.,0.);
81   //
82   myRadius1=-1.;
83   myRadius2=-2.;
84   myLength=-3.;
85   myWidth=-3.;
86   myHeight=-3.;
87   myDegree=0;
88   myNbPoles=0;
89   myNbKnots=0;
90   myNbWeights=0;
91   myNbMultiplicities=0;
92   myPoles = Handle(TColgp_HArray1OfPnt)();
93   myKnots = Handle(TColStd_HArray1OfReal)();
94   myWeights = Handle(TColStd_HArray1OfReal)();
95   myMultiplicities = Handle(TColStd_HArray1OfInteger)();
96 }
97 //=======================================================================
98 //function : SetType
99 //purpose  :
100 //=======================================================================
101 void GEOMAlgo_ShapeInfo::SetType(const TopAbs_ShapeEnum aType)
102 {
103   myType=aType;
104 }
105 //=======================================================================
106 //function : Type
107 //purpose  :
108 //=======================================================================
109 TopAbs_ShapeEnum GEOMAlgo_ShapeInfo::Type() const
110 {
111   return myType;
112 }
113 //=======================================================================
114 //function : SetNbSubShapes
115 //purpose  :
116 //=======================================================================
117 void GEOMAlgo_ShapeInfo::SetNbSubShapes(const TopAbs_ShapeEnum aType,
118                                         const Standard_Integer aNb)
119 {
120   Standard_Integer iN;
121
122   iN=TypeToInteger(aType);
123   if (iN>=0 && iN<myNbTypes) {
124     myNbSubShapes[iN]=aNb;
125   }
126 }
127 //=======================================================================
128 //function : NbSubShapes
129 //purpose  :
130 //=======================================================================
131 Standard_Integer GEOMAlgo_ShapeInfo::NbSubShapes
132   (const TopAbs_ShapeEnum aType) const
133 {
134   Standard_Integer iN;
135
136   iN=TypeToInteger(aType);
137   if (iN>=0 && iN<myNbTypes) {
138     return myNbSubShapes[iN];
139   }
140   return 0;
141 }
142 //=======================================================================
143 //function : SetKindOfShape
144 //purpose  :
145 //=======================================================================
146 void GEOMAlgo_ShapeInfo::SetKindOfShape(const GEOMAlgo_KindOfShape aT)
147 {
148   myKindOfShape=aT;
149 }
150 //=======================================================================
151 //function : KindOfShape
152 //purpose  :
153 //=======================================================================
154 GEOMAlgo_KindOfShape GEOMAlgo_ShapeInfo::KindOfShape() const
155 {
156   return myKindOfShape;
157 }
158 //=======================================================================
159 //function : SetKindOfName
160 //purpose  :
161 //=======================================================================
162 void GEOMAlgo_ShapeInfo::SetKindOfName(const GEOMAlgo_KindOfName aT)
163 {
164   myKindOfName=aT;
165 }
166 //=======================================================================
167 //function : KindOfName
168 //purpose  :
169 //=======================================================================
170 GEOMAlgo_KindOfName GEOMAlgo_ShapeInfo::KindOfName() const
171 {
172   return myKindOfName;
173 }
174 //=======================================================================
175 //function : SetKindOfBounds
176 //purpose  :
177 //=======================================================================
178 void GEOMAlgo_ShapeInfo::SetKindOfBounds(const GEOMAlgo_KindOfBounds aT)
179 {
180   myKindOfBounds=aT;
181 }
182 //=======================================================================
183 //function : KindOfBounds
184 //purpose  :
185 //=======================================================================
186 GEOMAlgo_KindOfBounds GEOMAlgo_ShapeInfo::KindOfBounds() const
187 {
188   return myKindOfBounds;
189 }
190 //=======================================================================
191 //function : SetKindOfClosed
192 //purpose  :
193 //=======================================================================
194 void GEOMAlgo_ShapeInfo::SetKindOfClosed(const GEOMAlgo_KindOfClosed aT)
195 {
196   myKindOfClosed=aT;
197 }
198 //=======================================================================
199 //function : KindOfClosed
200 //purpose  :
201 //=======================================================================
202 GEOMAlgo_KindOfClosed GEOMAlgo_ShapeInfo::KindOfClosed() const
203 {
204   return myKindOfClosed;
205 }
206 //=======================================================================
207 //function : SetKindOfDef
208 //purpose  :
209 //=======================================================================
210 void GEOMAlgo_ShapeInfo::SetKindOfDef(const GEOMAlgo_KindOfDef aT)
211 {
212   myKindOfDef=aT;
213 }
214 //=======================================================================
215 //function : KindOfDef
216 //purpose  :
217 //=======================================================================
218 GEOMAlgo_KindOfDef GEOMAlgo_ShapeInfo::KindOfDef() const
219 {
220   return myKindOfDef;
221 }
222 //=======================================================================
223 //function : SetKindOfPeriod
224 //purpose  :
225 //=======================================================================
226 void GEOMAlgo_ShapeInfo::SetKindOfPeriod(const GEOMAlgo_KindOfPeriod aT)
227 {
228   myKindOfPeriod=aT;
229 }
230 //=======================================================================
231 //function : KindOfPeriod
232 //purpose  :
233 //=======================================================================
234 GEOMAlgo_KindOfPeriod GEOMAlgo_ShapeInfo::KindOfPeriod() const
235 {
236   return myKindOfPeriod;
237 }
238 //=======================================================================
239 //function : SetLocation
240 //purpose  :
241 //=======================================================================
242 void GEOMAlgo_ShapeInfo::SetLocation(const gp_Pnt& aP)
243 {
244   myLocation=aP;
245 }
246 //=======================================================================
247 //function : Location
248 //purpose  :
249 //=======================================================================
250 const gp_Pnt& GEOMAlgo_ShapeInfo::Location() const
251 {
252   return myLocation;
253 }
254 //=======================================================================
255 //function : SetDirection
256 //purpose  :
257 //=======================================================================
258 void GEOMAlgo_ShapeInfo::SetDirection(const gp_Dir& aD)
259 {
260   myDirection=aD;
261 }
262 //=======================================================================
263 //function : Direction
264 //purpose  :
265 //=======================================================================
266 const gp_Dir& GEOMAlgo_ShapeInfo::Direction() const
267 {
268   return myDirection;
269 }
270 //=======================================================================
271 //function : SetPosition
272 //purpose  :
273 //=======================================================================
274 void GEOMAlgo_ShapeInfo::SetPosition(const gp_Ax2& aAx2)
275 {
276   gp_Ax3 aAx3(aAx2);
277   SetPosition(aAx3);
278 }
279 //=======================================================================
280 //function : SetPosition
281 //purpose  :
282 //=======================================================================
283 void GEOMAlgo_ShapeInfo::SetPosition(const gp_Ax3& aAx3)
284 {
285   myPosition=aAx3;
286 }
287 //=======================================================================
288 //function : Position
289 //purpose  :
290 //=======================================================================
291 const gp_Ax3& GEOMAlgo_ShapeInfo::Position() const
292 {
293   return myPosition;
294 }
295
296 //=======================================================================
297 //function : SetPnt1
298 //purpose  :
299 //=======================================================================
300 void GEOMAlgo_ShapeInfo::SetPnt1(const gp_Pnt& aP)
301 {
302   myPnt1=aP;
303 }
304 //=======================================================================
305 //function : Pnt1
306 //purpose  :
307 //=======================================================================
308 const gp_Pnt& GEOMAlgo_ShapeInfo::Pnt1() const
309 {
310   return myPnt1;
311 }
312 //=======================================================================
313 //function : SetPnt2
314 //purpose  :
315 //=======================================================================
316 void GEOMAlgo_ShapeInfo::SetPnt2(const gp_Pnt& aP)
317 {
318   myPnt2=aP;
319 }
320 //=======================================================================
321 //function : Pnt2
322 //purpose  :
323 //=======================================================================
324 const gp_Pnt& GEOMAlgo_ShapeInfo::Pnt2() const
325 {
326   return myPnt2;
327 }
328 //=======================================================================
329 //function : SetRadius1
330 //purpose  :
331 //=======================================================================
332 void GEOMAlgo_ShapeInfo::SetRadius1(const Standard_Real aR)
333 {
334   myRadius1=aR;
335 }
336 //=======================================================================
337 //function : Radius1
338 //purpose  :
339 //=======================================================================
340 Standard_Real GEOMAlgo_ShapeInfo::Radius1() const
341 {
342   return myRadius1;
343 }
344 //=======================================================================
345 //function : SetRadius2
346 //purpose  :
347 //=======================================================================
348 void GEOMAlgo_ShapeInfo::SetRadius2(const Standard_Real aR)
349 {
350   myRadius2=aR;
351 }
352 //=======================================================================
353 //function : Radius2
354 //purpose  :
355 //=======================================================================
356 Standard_Real GEOMAlgo_ShapeInfo::Radius2() const
357 {
358   return myRadius2;
359 }
360 //=======================================================================
361 //function : SetLength
362 //purpose  :
363 //=======================================================================
364 void GEOMAlgo_ShapeInfo::SetLength(const Standard_Real aL)
365 {
366   myLength=aL;
367 }
368 //=======================================================================
369 //function : Length
370 //purpose  :
371 //=======================================================================
372 Standard_Real GEOMAlgo_ShapeInfo::Length() const
373 {
374   return myLength;
375 }
376 //=======================================================================
377 //function : SetWidth
378 //purpose  :
379 //=======================================================================
380 void GEOMAlgo_ShapeInfo::SetWidth(const Standard_Real aW)
381 {
382   myWidth=aW;
383 }
384 //=======================================================================
385 //function : Width
386 //purpose  :
387 //=======================================================================
388 Standard_Real GEOMAlgo_ShapeInfo::Width() const
389 {
390   return myWidth;
391 }
392 //=======================================================================
393 //function : SetHeight
394 //purpose  :
395 //=======================================================================
396 void GEOMAlgo_ShapeInfo::SetHeight(const Standard_Real aH)
397 {
398   myHeight=aH;
399 }
400 //=======================================================================
401 //function : Height
402 //purpose  :
403 //=======================================================================
404 Standard_Real GEOMAlgo_ShapeInfo::Height() const
405 {
406   return myHeight;
407 }
408 //=======================================================================
409 //function : SetDegree
410 //purpose  :
411 //=======================================================================
412 void GEOMAlgo_ShapeInfo::SetDegree(const Standard_Integer aD)
413 {
414   myDegree=aD;
415 }
416 //=======================================================================
417 //function : Degree
418 //purpose  :
419 //=======================================================================
420 Standard_Integer GEOMAlgo_ShapeInfo::Degree() const
421 {
422   return myDegree;
423 }
424 //=======================================================================
425 //function : SetNbPoles
426 //purpose  :
427 //=======================================================================
428 void GEOMAlgo_ShapeInfo::SetNbPoles(const Standard_Integer aNb)
429 {
430   myNbPoles=aNb;
431 }
432 //=======================================================================
433 //function : NbPoles
434 //purpose  :
435 //=======================================================================
436 Standard_Integer GEOMAlgo_ShapeInfo::NbPoles() const
437 {
438   return myNbPoles;
439 }
440 //=======================================================================
441 //function : SetNbKnots
442 //purpose  :
443 //=======================================================================
444 void GEOMAlgo_ShapeInfo::SetNbKnots(const Standard_Integer aNb)
445 {
446   myNbKnots=aNb;
447 }
448 //=======================================================================
449 //function : NbKnots
450 //purpose  :
451 //=======================================================================
452 Standard_Integer GEOMAlgo_ShapeInfo::NbKnots() const
453 {
454   return myNbKnots;
455 }
456 //=======================================================================
457 //function : SetNbWeights
458 //purpose  :
459 //=======================================================================
460 void GEOMAlgo_ShapeInfo::SetNbWeights(const Standard_Integer aNb)
461 {
462   myNbWeights=aNb;
463 }
464 //=======================================================================
465 //function : NbWeights
466 //purpose  :
467 //=======================================================================
468 Standard_Integer GEOMAlgo_ShapeInfo::NbWeights() const
469 {
470   return myNbWeights;
471 }
472 //=======================================================================
473 //function : SetNbMultiplicities
474 //purpose  :
475 //=======================================================================
476 void GEOMAlgo_ShapeInfo::SetNbMultiplicities(const Standard_Integer aNb)
477 {
478   myNbMultiplicities=aNb;
479 }
480 //=======================================================================
481 //function : NbWeights
482 //purpose  :
483 //=======================================================================
484 Standard_Integer GEOMAlgo_ShapeInfo::NbMultiplicities() const
485 {
486   return myNbMultiplicities;
487 }
488 //=======================================================================
489 //function : SetPoles
490 //purpose  :
491 //=======================================================================
492 void GEOMAlgo_ShapeInfo::SetPoles(Handle(TColgp_HArray1OfPnt) P)
493 {
494   myPoles = P;
495 }
496 //=======================================================================
497 //function : Poles
498 //purpose  :
499 //=======================================================================
500 Handle(TColgp_HArray1OfPnt) GEOMAlgo_ShapeInfo::Poles() const
501 {
502   return myPoles;
503 }
504 //=======================================================================
505 //function : SetKnots
506 //purpose  :
507 //=======================================================================
508 void GEOMAlgo_ShapeInfo::SetKnots(Handle(TColStd_HArray1OfReal) K)
509 {
510   myKnots = K;
511 }
512 //=======================================================================
513 //function : Knots
514 //purpose  :
515 //=======================================================================
516 Handle(TColStd_HArray1OfReal) GEOMAlgo_ShapeInfo::Knots() const
517 {
518   return myKnots;
519 }
520 //=======================================================================
521 //function : SetWeights
522 //purpose  :
523 //=======================================================================
524 void GEOMAlgo_ShapeInfo::SetWeights(Handle(TColStd_HArray1OfReal) W)
525 {
526   myWeights = W;
527 }
528 //=======================================================================
529 //function : Weights
530 //purpose  :
531 //=======================================================================
532 Handle(TColStd_HArray1OfReal) GEOMAlgo_ShapeInfo::Weights() const
533 {
534   return myWeights;
535 }
536 //=======================================================================
537 //function : SetMultiplicities
538 //purpose  :
539 //=======================================================================
540 void GEOMAlgo_ShapeInfo::SetMultiplicities(Handle(TColStd_HArray1OfInteger) M)
541 {
542   myMultiplicities = M;
543 }
544 //=======================================================================
545 //function : Multiplicities
546 //purpose  :
547 //=======================================================================
548 Handle(TColStd_HArray1OfInteger) GEOMAlgo_ShapeInfo::Multiplicities() const
549 {
550   return myMultiplicities;
551 }
552 //=======================================================================
553 //function : TypeToInteger
554 //purpose  :
555 //=======================================================================
556 Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType)
557 {
558   Standard_Integer iN;
559   //
560   iN=(Standard_Integer)aType;
561   return iN;
562 }
563 //=======================================================================
564 //function : Dump
565 //purpose  :
566 //=======================================================================
567 void GEOMAlgo_ShapeInfo::Dump()const
568 {
569   switch (myType) {
570     //
571   case TopAbs_VERTEX:
572     DumpVertex();
573     break;
574     //
575   case TopAbs_EDGE:
576     DumpEdge();
577     break;
578     //
579   case TopAbs_WIRE:
580     DumpWire();
581     break;
582     //
583   case TopAbs_FACE:
584     DumpFace();
585     break;
586     //
587   case TopAbs_SHELL:
588     DumpShell();
589     break;
590     //
591   case TopAbs_SOLID:
592     DumpSolid();
593     break;
594     //
595   case TopAbs_COMPSOLID:
596     DumpCompSolid();
597     break;
598     //
599   case TopAbs_COMPOUND:
600     DumpCompound();
601     break;
602     //
603   default:
604     printf(" * not implemented yet\n");
605     break;
606   }
607 }
608 //=======================================================================
609 //function : DumpCompound
610 //purpose  :
611 //=======================================================================
612 void GEOMAlgo_ShapeInfo::DumpCompound()const
613 {
614   Standard_Integer aNbV, aNbE, aNbF, aNbS, aNbC, aNbP;
615   GEOMAlgo_KindOfShape aKS;
616   GEOMAlgo_KindOfName aKN;
617   GEOMAlgo_KindOfBounds aKB;
618   GEOMAlgo_KindOfClosed aKC;
619   //
620   aNbV=NbSubShapes(TopAbs_VERTEX);
621   aNbE=NbSubShapes(TopAbs_EDGE);
622   aNbF=NbSubShapes(TopAbs_FACE);
623   aNbS=NbSubShapes(TopAbs_SOLID);
624   aNbC=NbSubShapes(TopAbs_COMPSOLID);
625   aNbP=NbSubShapes(TopAbs_COMPOUND);
626   aKS=KindOfShape();
627   aKN=KindOfName();
628   aKB=KindOfBounds();
629   aKC=KindOfClosed();
630   //
631   printf(" *COMPOUND\n");
632   printf("  number of vertices    : %d\n", aNbV);
633   printf("  number of edges       : %d\n", aNbE);
634   printf("  number of faces       : %d\n", aNbF);
635   printf("  number of solids      : %d\n", aNbS);
636   printf("  number of compsolids  : %d\n", aNbC);
637   printf("  number of compounds   : %d\n", aNbP);
638   DumpKindOfShape (aKS);
639   DumpKindOfName (aKN);
640   DumpKindOfBounds(aKB);
641   DumpKindOfClosed(aKC);
642 }
643 //=======================================================================
644 //function : DumpCompSolid
645 //purpose  :
646 //=======================================================================
647 void GEOMAlgo_ShapeInfo::DumpCompSolid()const
648 {
649   Standard_Integer aNbV, aNbE, aNbF, aNbS;
650   GEOMAlgo_KindOfShape aKS;
651   GEOMAlgo_KindOfName aKN;
652   GEOMAlgo_KindOfBounds aKB;
653   GEOMAlgo_KindOfClosed aKC;
654   //
655   aNbV=NbSubShapes(TopAbs_VERTEX);
656   aNbE=NbSubShapes(TopAbs_EDGE);
657   aNbF=NbSubShapes(TopAbs_FACE);
658   aNbS=NbSubShapes(TopAbs_SOLID);
659   aKS=KindOfShape();
660   aKN=KindOfName();
661   aKB=KindOfBounds();
662   aKC=KindOfClosed();
663   //
664   printf(" *COMPSOLID\n");
665   printf("  number of vertices: %d\n", aNbV);
666   printf("  number of edges   : %d\n", aNbE);
667   printf("  number of faces   : %d\n", aNbF);
668   printf("  number of solids  : %d\n", aNbS);
669   DumpKindOfShape (aKS);
670   DumpKindOfName (aKN);
671   DumpKindOfBounds(aKB);
672   DumpKindOfClosed(aKC);
673 }
674 //=======================================================================
675 //function : DumpSolid
676 //purpose  :
677 //=======================================================================
678 void GEOMAlgo_ShapeInfo::DumpSolid()const
679 {
680   Standard_Integer aNbV, aNbE, aNbF;
681   GEOMAlgo_KindOfShape aKS;
682   GEOMAlgo_KindOfName aKN;
683   GEOMAlgo_KindOfBounds aKB;
684   GEOMAlgo_KindOfClosed aKC;
685   //
686   aNbV=NbSubShapes(TopAbs_VERTEX);
687   aNbE=NbSubShapes(TopAbs_EDGE);
688   aNbF=NbSubShapes(TopAbs_FACE);
689   aKS=KindOfShape();
690   aKN=KindOfName();
691   aKB=KindOfBounds();
692   aKC=KindOfClosed();
693   //
694   printf(" *SOLID\n");
695   printf("  number of vertices: %d\n", aNbV);
696   printf("  number of edges   : %d\n", aNbE);
697   printf("  number of faces   : %d\n", aNbF);
698   DumpKindOfShape (aKS);
699   DumpKindOfName (aKN);
700   DumpKindOfBounds(aKB);
701   DumpKindOfClosed(aKC);
702   //
703   if (aKN==GEOMAlgo_KN_SPHERE) {
704     DumpLocation (myLocation);
705     DumpPosition (myPosition);
706     printf("  Radius1   : %.3lf\n", myRadius1);
707   }
708   if (aKN==GEOMAlgo_KN_CYLINDER) {
709     DumpLocation (myLocation);
710     DumpPosition (myPosition);
711     printf("  Radius1   : %.3lf\n", myRadius1);
712     printf("  Height    : %.3lf\n", myHeight);
713   }
714   else if (aKN==GEOMAlgo_KN_CONE) {
715     DumpLocation (myLocation);
716     DumpPosition (myPosition);
717     printf("  Radius1   : %.3lf\n", myRadius1);
718     printf("  Radius2   : %.3lf\n", myRadius2);
719     printf("  Height    : %.3lf\n", myHeight);
720   }
721   else if (aKN==GEOMAlgo_KN_TORUS) {
722     DumpLocation (myLocation);
723     DumpPosition (myPosition);
724     printf("  Radius1   : %.3lf\n", myRadius1);
725     printf("  Radius2   : %.3lf\n", myRadius2);
726   }
727   else if (aKN==GEOMAlgo_KN_POLYHEDRON) {
728     DumpLocation (myLocation);
729     DumpPosition (myPosition);
730   }
731   else if (aKN==GEOMAlgo_KN_BOX) {
732     DumpLocation (myLocation);
733     DumpPosition (myPosition);
734     printf("  Length    : %.3lf\n", myLength);
735     printf("  Width     : %.3lf\n", myWidth);
736     printf("  Height    : %.3lf\n", myHeight);
737   }
738 }
739 //=======================================================================
740 //function : DumpFace
741 //purpose  :
742 //=======================================================================
743 void GEOMAlgo_ShapeInfo::DumpFace()const
744 {
745   Standard_Integer aNbV, aNbE;
746   GEOMAlgo_KindOfShape aKS;
747   GEOMAlgo_KindOfName aKN;
748   GEOMAlgo_KindOfBounds aKB;
749   GEOMAlgo_KindOfClosed aKC;
750   GEOMAlgo_KindOfDef aKD;
751   //
752   aNbV=NbSubShapes(TopAbs_VERTEX);
753   aNbE=NbSubShapes(TopAbs_EDGE);
754   aKS=KindOfShape();
755   aKN=KindOfName();
756   aKB=KindOfBounds();
757   aKC=KindOfClosed();
758   aKD=KindOfDef();
759   //
760   printf(" *FACE\n");
761   printf("  number of vertices: %d\n", aNbV);
762   printf("  number of edges   : %d\n", aNbE);
763   DumpKindOfShape (aKS);
764   DumpKindOfName (aKN);
765   DumpKindOfBounds(aKB);
766   DumpKindOfClosed(aKC);
767   DumpKindOfDef(aKD);
768   //
769   // PLANE
770   if (aKN==GEOMAlgo_KN_PLANE) {
771     DumpLocation (myLocation);
772     DumpPosition (myPosition);
773   }
774   else if (aKN==GEOMAlgo_KN_DISKCIRCLE) {
775     DumpLocation (myLocation);
776     DumpPosition (myPosition);
777     printf("  Radius1   : %.3lf\n", myRadius1);
778   }
779   else if (aKN==GEOMAlgo_KN_DISKELLIPSE) {
780     DumpLocation (myLocation);
781     DumpPosition (myPosition);
782     printf("  Radius1   : %.3lf\n", myRadius1);
783     printf("  Radius2   : %.3lf\n", myRadius2);
784   }
785   else if (aKN==GEOMAlgo_KN_RECTANGLE) {
786     DumpLocation (myLocation);
787     DumpPosition (myPosition);
788     printf("  Length    : %.3lf\n", myLength);
789     printf("  Width     : %.3lf\n", myWidth);
790   }
791   else if (aKN==GEOMAlgo_KN_TRIANGLE ||
792            aKN==GEOMAlgo_KN_QUADRANGLE||
793            aKN==GEOMAlgo_KN_POLYGON) {
794     DumpLocation (myLocation);
795     DumpPosition (myPosition);
796   }
797   //
798   // SPHERE
799   else if (aKN==GEOMAlgo_KN_SPHERE) {
800     DumpLocation (myLocation);
801     DumpPosition (myPosition);
802     printf("  Radius1   : %.3lf", myRadius1);
803   }
804   //
805   // CYLINDER
806   else if (aKN==GEOMAlgo_KN_CYLINDER) {
807     DumpLocation (myLocation);
808     DumpPosition (myPosition);
809     printf("  Radius1   : %.3lf\n", myRadius1);
810     printf("  Height    : %.3lf\n", myHeight);
811   }
812   //
813   // CONE
814   else if (aKN==GEOMAlgo_KN_CONE) {
815     DumpLocation (myLocation);
816     DumpPosition (myPosition);
817     printf("  Radius1   : %.3lf\n", myRadius1);
818     printf("  Radius2   : %.3lf\n", myRadius2);
819     printf("  Height    : %.3lf\n", myHeight);
820   }
821   //
822   // TORUS
823   else if (aKN==GEOMAlgo_KN_TORUS) {
824     DumpLocation (myLocation);
825     DumpPosition (myPosition);
826     printf("  Radius1   : %.3lf\n", myRadius1);
827     printf("  Radius2   : %.3lf\n", myRadius2);
828   }
829
830
831   printf("\n");
832 }
833 //=======================================================================
834 //function : DumpShell
835 //purpose  :
836 //=======================================================================
837 void GEOMAlgo_ShapeInfo::DumpShell()const
838 {
839   Standard_Integer aNbV, aNbE, aNbF;
840   GEOMAlgo_KindOfClosed aKC;
841   //
842   printf(" *SHELL\n");
843   //
844   aNbV=NbSubShapes(TopAbs_VERTEX);
845   aNbE=NbSubShapes(TopAbs_EDGE);
846   aNbF=NbSubShapes(TopAbs_FACE);
847   printf("  number of vertices: %d\n", aNbV);
848   printf("  number of edges   : %d\n", aNbE);
849   printf("  number of faces   : %d\n", aNbF);
850   aKC=KindOfClosed();
851   DumpKindOfClosed(aKC);
852   printf("\n");
853 }
854 //=======================================================================
855 //function : DumpWire
856 //purpose  :
857 //=======================================================================
858 void GEOMAlgo_ShapeInfo::DumpWire()const
859 {
860   Standard_Integer aNbV, aNbE;
861   GEOMAlgo_KindOfClosed aKC;
862   //
863   printf(" *WIRE\n");
864   //
865   aNbV=NbSubShapes(TopAbs_VERTEX);
866   aNbE=NbSubShapes(TopAbs_EDGE);
867   printf("  number of vertices: %d\n", aNbV);
868   printf("  number of edges   : %d\n", aNbE);
869
870   aKC=KindOfClosed();
871   DumpKindOfClosed(aKC);
872   printf("\n");
873 }
874 //=======================================================================
875 //function : DumpEdge
876 //purpose  :
877 //=======================================================================
878 void GEOMAlgo_ShapeInfo::DumpEdge()const
879 {
880   Standard_Integer aNbV;
881   Standard_Real aX, aY, aZ;
882   GEOMAlgo_KindOfShape aKS;
883   GEOMAlgo_KindOfName aKN;
884   GEOMAlgo_KindOfBounds aKB;
885   GEOMAlgo_KindOfClosed aKC;
886   GEOMAlgo_KindOfPeriod aKP;
887   //
888   aNbV=NbSubShapes(TopAbs_VERTEX);
889   aKS=KindOfShape();
890   aKN=KindOfName();
891   aKB=KindOfBounds();
892   aKC=KindOfClosed();
893   //
894   printf(" *EDGE\n");
895   printf("  number of vertices: %d\n", aNbV);
896   DumpKindOfShape (aKS);
897   DumpKindOfName (aKN);
898   DumpKindOfBounds(aKB);
899   DumpKindOfClosed(aKC);
900   //
901   // LINE
902   if (aKN==GEOMAlgo_KN_LINE) {
903     DumpLocation (myLocation);
904     DumpDirection(myDirection);
905   }
906   else if (aKN==GEOMAlgo_KN_SEGMENT) {
907     DumpLocation (myLocation);
908     DumpDirection(myDirection);
909     printf("  Length    : %.3lf\n", myLength);
910     myPnt1.Coord(aX, aY, aZ);
911     printf("  Pnt1 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
912     myPnt2.Coord(aX, aY, aZ);
913     printf("  Pnt2 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
914
915   }
916   else if (aKN==GEOMAlgo_KN_CIRCLE) {
917     DumpLocation (myLocation);
918     DumpPosition (myPosition);
919     printf("  Radius1   : %.3lf\n", myRadius1);
920   }
921   else if (aKN==GEOMAlgo_KN_ARCCIRCLE) {
922     DumpLocation (myLocation);
923     DumpPosition (myPosition);
924     printf("  Radius1   : %.3lf\n", myRadius1);
925     myPnt1.Coord(aX, aY, aZ);
926     printf("  Pnt1 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
927     myPnt2.Coord(aX, aY, aZ);
928     printf("  Pnt2 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
929   }
930   else if (aKN==GEOMAlgo_KN_ELLIPSE) {
931     DumpLocation (myLocation);
932     DumpPosition (myPosition);
933     printf("  Radius1   : %.3lf\n", myRadius1);
934     printf("  Radius2   : %.3lf\n", myRadius2);
935   }
936   else if (aKN==GEOMAlgo_KN_ARCELLIPSE) {
937     DumpLocation (myLocation);
938     DumpPosition (myPosition);
939     printf("  Radius1   : %.3lf\n", myRadius1);
940     printf("  Radius2   : %.3lf\n", myRadius2);
941     myPnt1.Coord(aX, aY, aZ);
942     printf("  Pnt1 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
943     myPnt2.Coord(aX, aY, aZ);
944     printf("  Pnt2 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
945   }
946   else if (aKN==GEOMAlgo_KN_CURVEBSPLINE) {
947     aKP=KindOfPeriod();
948     DumpKindOfPeriod(aKP);
949     printf("  Degree    : %d\n", myDegree);
950     printf("  NbPoles   : %d\n", myNbPoles);
951     printf("  NbKnots   : %d\n", myNbKnots);
952     printf("  NbWeights : %d\n", myNbWeights);
953     printf("  NbMultis  : %d\n", myNbMultiplicities);
954
955     if (aKB == GEOMAlgo_KB_TRIMMED) {
956       myPnt1.Coord(aX, aY, aZ);
957       printf("  Pnt1 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
958       myPnt2.Coord(aX, aY, aZ);
959       printf("  Pnt2 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
960     }
961
962     Standard_Integer i;
963     if (myNbPoles > 0 && !myPoles.IsNull() && myPoles->Length() == myNbPoles) {
964       bool aHasWeight = (myNbWeights == myNbPoles);
965       printf("  Poles\n");
966       for (i=1; i<=myNbPoles; i++) {
967         const gp_Pnt &aP = myPoles->Value(i);
968         if (aHasWeight)
969           printf("  %3d : %.3lf %.3lf %.3lf  %.3lf\n", i, aP.X(), aP.Y(), aP.Z(), myWeights->Value(i));
970         else
971           printf("  %3d : %.3lf %.3lf %.3lf\n", i, aP.X(), aP.Y(), aP.Z());
972       }
973     }
974
975     if (myNbKnots > 0 && !myKnots.IsNull() && myKnots->Length() == myNbKnots) {
976       bool aHasMulti = (myNbMultiplicities == myNbKnots);
977       printf("  Knots\n");
978       for (i=1; i<=myNbKnots; i++) {
979         if (aHasMulti)
980           printf("  %3d : %.3lf  %.3lf\n", i, myKnots->Value(i), myMultiplicities->Value(i));
981         else
982           printf("  %3d : %.3lf\n", i, myKnots->Value(i));
983       }
984     }
985     
986   }
987   else if (aKN==GEOMAlgo_KN_CURVEBEZIER) {
988     aKP=KindOfPeriod();
989     DumpKindOfPeriod(aKP);
990     printf("  Degree    : %d\n", myDegree);
991     printf("  NbPoles   : %d\n", myNbPoles);
992     printf("  NbWeights : %d\n", myNbWeights);
993     if (aKB == GEOMAlgo_KB_TRIMMED) {
994       myPnt1.Coord(aX, aY, aZ);
995       printf("  Pnt1 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
996       myPnt2.Coord(aX, aY, aZ);
997       printf("  Pnt2 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
998     }
999
1000     Standard_Integer i;
1001     if (myNbPoles > 0 && !myPoles.IsNull() && myPoles->Length() == myNbPoles) {
1002       bool aHasWeight = (myNbWeights == myNbPoles);
1003       printf("  Poles\n");
1004       for (i=1; i<=myNbPoles; i++) {
1005         const gp_Pnt &aP = myPoles->Value(i);
1006         if (aHasWeight)
1007           printf("  %3d : %.3lf %.3lf %.3lf  %.3lf\n", i, aP.X(), aP.Y(), aP.Z(), myWeights->Value(i));
1008         else
1009           printf("  %3d : %.3lf %.3lf %.3lf\n", i, aP.X(), aP.Y(), aP.Z());
1010       }
1011     }
1012   }
1013   else if (aKN==GEOMAlgo_KN_HYPERBOLA) {
1014     DumpLocation (myLocation);
1015     DumpPosition (myPosition);
1016     printf("  Radius1   : %.3lf\n", myRadius1);
1017     printf("  Radius2   : %.3lf\n", myRadius2);
1018   }
1019   else if (aKN==GEOMAlgo_KN_PARABOLA) {
1020     DumpLocation (myLocation);
1021     DumpPosition (myPosition);
1022     printf("  Focal     : %.3lf\n", myRadius1);
1023   }
1024   printf("\n");
1025 }
1026 //=======================================================================
1027 //function : DumpVertex
1028 //purpose  :
1029 //=======================================================================
1030 void GEOMAlgo_ShapeInfo::DumpVertex()const
1031 {
1032   printf(" *VERTEX\n");
1033   DumpLocation(myLocation);
1034 }
1035 //=======================================================================
1036 //function : DumpLocation
1037 //purpose  :
1038 //=======================================================================
1039 void DumpLocation(const gp_Pnt& aP)
1040 {
1041   Standard_Real aX, aY, aZ;
1042   //
1043   aP.Coord(aX, aY, aZ);
1044   printf("  Location : %.3lf %.3lf %.3lf \n", aX, aY, aZ);
1045 }
1046 //=======================================================================
1047 //function : DumpDirection
1048 //purpose  :
1049 //=======================================================================
1050 void DumpDirection(const gp_Dir& aD)
1051 {
1052   Standard_Real aX, aY, aZ;
1053   //
1054   aD.Coord(aX, aY, aZ);
1055   printf("  Direction: %.3lf %.3lf %.3lf \n", aX, aY, aZ);
1056 }
1057 //=======================================================================
1058 //function : DumpPosition
1059 //purpose  :
1060 //=======================================================================
1061 void DumpPosition(const gp_Ax3& aAx3)
1062 {
1063   const gp_Dir& aDZ=aAx3.Axis().Direction();
1064   const gp_Dir& aDX=aAx3.XDirection();
1065   const gp_Dir& aDY=aAx3.YDirection();
1066   printf("  Position:\n");
1067   printf("  Axis: %.3lf %.3lf %.3lf \n", aDZ.X(), aDZ.Y(), aDZ.Z());
1068   printf("  X   : %.3lf %.3lf %.3lf \n", aDX.X(), aDX.Y(), aDX.Z());
1069   printf("  Y   : %.3lf %.3lf %.3lf \n", aDY.X(), aDY.Y(), aDY.Z());
1070 }
1071 //=======================================================================
1072 //function : DumpKindOfBounds
1073 //purpose  :
1074 //=======================================================================
1075 void DumpKindOfBounds(const GEOMAlgo_KindOfBounds aKB)
1076 {
1077   const char *pStr[]={
1078     "KB_UNKNOWN",
1079     "KB_TRIMMED",
1080     "KB_INFINITE"
1081   };
1082   int i;
1083   //
1084   i=(Standard_Integer)aKB;
1085   printf(" KindOfBounds: %s\n", pStr[i]);
1086
1087 }
1088 //=======================================================================
1089 //function : DumpKindOfClosed
1090 //purpose  :
1091 //=======================================================================
1092 void DumpKindOfClosed(const GEOMAlgo_KindOfClosed aKC)
1093 {
1094   const char *pStr[]={
1095     "KC_UNKNOWN",
1096     "KC_CLOSED",
1097     "KC_NOTCLOSED"
1098   };
1099   int i;
1100   //
1101   i=(Standard_Integer)aKC;
1102   printf(" KindOfClosed: %s\n", pStr[i]);
1103
1104 }
1105 //=======================================================================
1106 //function : DumpKindOfShape
1107 //purpose  :
1108 //=======================================================================
1109 void DumpKindOfShape(const GEOMAlgo_KindOfShape aKS)
1110 {
1111   const char *pStr[]={
1112     "KS_UNKNOWN",
1113     "KS_SPHERE",
1114     "KS_CYLINDER",
1115     "KS_BOX",
1116     "KS_TORUS",
1117     "KS_CONE",
1118     "KS_ELLIPSE",
1119     "KS_PLANE",
1120     "KS_CIRCLE",
1121     "KS_LINE",
1122     "KS_DEGENERATED",
1123     "KS_BSPLINE",
1124     "KS_BEZIER",
1125     "KS_HYPERBOLA",
1126     "KS_PARABOLA"
1127     };
1128   int i;
1129   //
1130   i=(Standard_Integer)aKS;
1131   printf(" KindOfShape : %s\n", pStr[i]);
1132 }
1133 //=======================================================================
1134 //function : DumpKindOfName
1135 //purpose  :
1136 //=======================================================================
1137 void DumpKindOfName(const GEOMAlgo_KindOfName aKS)
1138 {
1139   const char *pStr[]={
1140     "KN_UNKNOWN",
1141     "KN_SPHERE",
1142     "KN_CYLINDER",
1143     "KN_TORUS",
1144     "KN_CONE",
1145     "KN_ELLIPSE",
1146     "KN_CIRCLE",
1147     "KN_PLANE",
1148     "KN_LINE",
1149     "KN_BOX",
1150     "KN_SEGMENT",
1151     "KN_ARCCIRCLE",
1152     "KN_POLYGON",
1153     "KN_POLYHEDRON",
1154     "KN_DISKCIRCLE",
1155     "KN_DISKELLIPSE",
1156     "KN_RECTANGLE",
1157     "KN_TRIANGLE",
1158     "KN_QUADRANGLE",
1159     "KN_ARCELLIPSE",
1160     "KN_SOLID",
1161     "KN_CURVEBSPLINE",
1162     "KN_CURVEBEZIER",
1163     "KN_HYPERBOLA",
1164     "KN_PARABOLA"
1165     };
1166   int i;
1167   //
1168   i=(Standard_Integer)aKS;
1169   printf(" KindOfName  : %s\n", pStr[i]);
1170 }
1171 //=======================================================================
1172 //function : DumpKindOfDef
1173 //purpose  :
1174 //=======================================================================
1175 void DumpKindOfDef(const GEOMAlgo_KindOfDef aKD)
1176 {
1177   const char *pStr[]={
1178     "KD_UNKNOWN",
1179     "KD_SPECIFIED",
1180     "KD_ARBITRARY"
1181   };
1182   int i;
1183   //
1184   i=(Standard_Integer)aKD;
1185   printf(" KindOfDef: %s\n", pStr[i]);
1186 }
1187 //=======================================================================
1188 //function : DumpKindOfPeriod
1189 //purpose  :
1190 //=======================================================================
1191 void DumpKindOfPeriod(const GEOMAlgo_KindOfPeriod aKP)
1192 {
1193   const char *pStr[]={
1194     "KP_UNKNOWN",
1195     "KP_PERIODIC",
1196     "KP_NONPERIODIC"
1197   };
1198   int i;
1199   //
1200   i=(Standard_Integer)aKP;
1201   printf(" KindOfPeriod: %s\n", pStr[i]);
1202 }