1 #include <GEOMAlgo_ShapeInfo.ixx>
5 Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType);
7 void DumpKindOfShape(const GEOMAlgo_KindOfShape aKS);
9 void DumpKindOfClosed(const GEOMAlgo_KindOfClosed aKC);
11 void DumpKindOfBounds(const GEOMAlgo_KindOfBounds aKB);
13 void DumpKindOfName(const GEOMAlgo_KindOfName aKS);
15 void DumpPosition(const gp_Ax3& aAx3);
17 void DumpLocation(const gp_Pnt& aP);
19 void DumpDirection(const gp_Dir& aD);
20 //=======================================================================
23 //=======================================================================
24 GEOMAlgo_ShapeInfo::GEOMAlgo_ShapeInfo()
28 //=======================================================================
31 //=======================================================================
32 GEOMAlgo_ShapeInfo::~GEOMAlgo_ShapeInfo()
35 //=======================================================================
38 //=======================================================================
39 void GEOMAlgo_ShapeInfo::Reset()
46 for (i=0; i<myNbTypes; ++i) {
50 myKindOfShape=GEOMAlgo_KS_UNKNOWN;
51 myKindOfBounds=GEOMAlgo_KB_UNKNOWN;
52 myKindOfClosed=GEOMAlgo_KC_UNKNOWN;
53 myKindOfName=GEOMAlgo_KN_UNKNOWN;
55 myLocation.SetCoord(99., 99., 99.);
56 myDirection.SetCoord(1.,0.,0.);
64 //=======================================================================
67 //=======================================================================
68 void GEOMAlgo_ShapeInfo::SetType(const TopAbs_ShapeEnum aType)
72 //=======================================================================
75 //=======================================================================
76 TopAbs_ShapeEnum GEOMAlgo_ShapeInfo::Type() const
80 //=======================================================================
81 //function : SetNbSubShapes
83 //=======================================================================
84 void GEOMAlgo_ShapeInfo::SetNbSubShapes(const TopAbs_ShapeEnum aType,
85 const Standard_Integer aNb)
89 iN=TypeToInteger(aType);
90 if (iN>=0 && iN<myNbTypes) {
91 myNbSubShapes[iN]=aNb;
94 //=======================================================================
95 //function : NbSubShapes
97 //=======================================================================
98 Standard_Integer GEOMAlgo_ShapeInfo::NbSubShapes(const TopAbs_ShapeEnum aType) const
102 iN=TypeToInteger(aType);
103 if (iN>=0 && iN<myNbTypes) {
104 return myNbSubShapes[iN];
108 //=======================================================================
109 //function : SetKindOfShape
111 //=======================================================================
112 void GEOMAlgo_ShapeInfo::SetKindOfShape(const GEOMAlgo_KindOfShape aT)
116 //=======================================================================
117 //function : KindOfShape
119 //=======================================================================
120 GEOMAlgo_KindOfShape GEOMAlgo_ShapeInfo::KindOfShape() const
122 return myKindOfShape;
124 //=======================================================================
125 //function : SetKindOfName
127 //=======================================================================
128 void GEOMAlgo_ShapeInfo::SetKindOfName(const GEOMAlgo_KindOfName aT)
132 //=======================================================================
133 //function : KindOfName
135 //=======================================================================
136 GEOMAlgo_KindOfName GEOMAlgo_ShapeInfo::KindOfName() const
140 //=======================================================================
141 //function : SetKindOfBounds
143 //=======================================================================
144 void GEOMAlgo_ShapeInfo::SetKindOfBounds(const GEOMAlgo_KindOfBounds aT)
148 //=======================================================================
149 //function : KindOfBounds
151 //=======================================================================
152 GEOMAlgo_KindOfBounds GEOMAlgo_ShapeInfo::KindOfBounds() const
154 return myKindOfBounds;
156 //=======================================================================
157 //function : SetKindOfClosed
159 //=======================================================================
160 void GEOMAlgo_ShapeInfo::SetKindOfClosed(const GEOMAlgo_KindOfClosed aT)
164 //=======================================================================
165 //function : KindOfClosed
167 //=======================================================================
168 GEOMAlgo_KindOfClosed GEOMAlgo_ShapeInfo::KindOfClosed() const
170 return myKindOfClosed;
172 //=======================================================================
173 //function : SetLocation
175 //=======================================================================
176 void GEOMAlgo_ShapeInfo::SetLocation(const gp_Pnt& aP)
180 //=======================================================================
181 //function : Location
183 //=======================================================================
184 const gp_Pnt& GEOMAlgo_ShapeInfo::Location() const
188 //=======================================================================
189 //function : SetDirection
191 //=======================================================================
192 void GEOMAlgo_ShapeInfo::SetDirection(const gp_Dir& aD)
196 //=======================================================================
197 //function : Direction
199 //=======================================================================
200 const gp_Dir& GEOMAlgo_ShapeInfo::Direction() const
204 //=======================================================================
205 //function : SetPosition
207 //=======================================================================
208 void GEOMAlgo_ShapeInfo::SetPosition(const gp_Ax2& aAx2)
213 //=======================================================================
214 //function : SetPosition
216 //=======================================================================
217 void GEOMAlgo_ShapeInfo::SetPosition(const gp_Ax3& aAx3)
221 //=======================================================================
222 //function : Position
224 //=======================================================================
225 const gp_Ax3& GEOMAlgo_ShapeInfo::Position() const
230 //=======================================================================
233 //=======================================================================
234 void GEOMAlgo_ShapeInfo::SetPnt1(const gp_Pnt& aP)
238 //=======================================================================
241 //=======================================================================
242 const gp_Pnt& GEOMAlgo_ShapeInfo::Pnt1() const
246 //=======================================================================
249 //=======================================================================
250 void GEOMAlgo_ShapeInfo::SetPnt2(const gp_Pnt& aP)
254 //=======================================================================
257 //=======================================================================
258 const gp_Pnt& GEOMAlgo_ShapeInfo::Pnt2() const
262 //=======================================================================
263 //function : SetRadius1
265 //=======================================================================
266 void GEOMAlgo_ShapeInfo::SetRadius1(const Standard_Real aR)
270 //=======================================================================
273 //=======================================================================
274 Standard_Real GEOMAlgo_ShapeInfo::Radius1() const
278 //=======================================================================
279 //function : SetRadius2
281 //=======================================================================
282 void GEOMAlgo_ShapeInfo::SetRadius2(const Standard_Real aR)
286 //=======================================================================
289 //=======================================================================
290 Standard_Real GEOMAlgo_ShapeInfo::Radius2() const
294 //=======================================================================
295 //function : SetLength
297 //=======================================================================
298 void GEOMAlgo_ShapeInfo::SetLength(const Standard_Real aL)
302 //=======================================================================
305 //=======================================================================
306 Standard_Real GEOMAlgo_ShapeInfo::Length() const
310 //=======================================================================
311 //function : SetWidth
313 //=======================================================================
314 void GEOMAlgo_ShapeInfo::SetWidth(const Standard_Real aW)
318 //=======================================================================
321 //=======================================================================
322 Standard_Real GEOMAlgo_ShapeInfo::Width() const
326 //=======================================================================
327 //function : SetHeight
329 //=======================================================================
330 void GEOMAlgo_ShapeInfo::SetHeight(const Standard_Real aH)
334 //=======================================================================
337 //=======================================================================
338 Standard_Real GEOMAlgo_ShapeInfo::Height() const
342 //=======================================================================
343 //function : TypeToInteger
345 //=======================================================================
346 Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType)
350 iN=(Standard_Integer)aType;
353 //=======================================================================
356 //=======================================================================
357 void GEOMAlgo_ShapeInfo::Dump()const
385 case TopAbs_COMPSOLID:
389 case TopAbs_COMPOUND:
394 printf(" * not implememted yet\n");
398 //=======================================================================
399 //function : DumpCompound
401 //=======================================================================
402 void GEOMAlgo_ShapeInfo::DumpCompound()const
404 Standard_Integer aNbV, aNbE, aNbF, aNbS, aNbC, aNbP;
405 GEOMAlgo_KindOfShape aKS;
406 GEOMAlgo_KindOfName aKN;
407 GEOMAlgo_KindOfBounds aKB;
408 GEOMAlgo_KindOfClosed aKC;
410 aNbV=NbSubShapes(TopAbs_VERTEX);
411 aNbE=NbSubShapes(TopAbs_EDGE);
412 aNbF=NbSubShapes(TopAbs_FACE);
413 aNbS=NbSubShapes(TopAbs_SOLID);
414 aNbC=NbSubShapes(TopAbs_COMPSOLID);
415 aNbP=NbSubShapes(TopAbs_COMPOUND);
421 printf(" *COMPOUND\n");
422 printf(" number of vertices : %d\n", aNbV);
423 printf(" number of edges : %d\n", aNbE);
424 printf(" number of faces : %d\n", aNbF);
425 printf(" number of solids : %d\n", aNbS);
426 printf(" number of compsolids : %d\n", aNbC);
427 printf(" number of compounds : %d\n", aNbP);
428 DumpKindOfShape (aKS);
429 DumpKindOfName (aKN);
430 DumpKindOfBounds(aKB);
431 DumpKindOfClosed(aKC);
433 //=======================================================================
434 //function : DumpCompSolid
436 //=======================================================================
437 void GEOMAlgo_ShapeInfo::DumpCompSolid()const
439 Standard_Integer aNbV, aNbE, aNbF, aNbS;
440 GEOMAlgo_KindOfShape aKS;
441 GEOMAlgo_KindOfName aKN;
442 GEOMAlgo_KindOfBounds aKB;
443 GEOMAlgo_KindOfClosed aKC;
445 aNbV=NbSubShapes(TopAbs_VERTEX);
446 aNbE=NbSubShapes(TopAbs_EDGE);
447 aNbF=NbSubShapes(TopAbs_FACE);
448 aNbS=NbSubShapes(TopAbs_SOLID);
454 printf(" *COMPSOLID\n");
455 printf(" number of vertices: %d\n", aNbV);
456 printf(" number of edges : %d\n", aNbE);
457 printf(" number of faces : %d\n", aNbF);
458 printf(" number of solids : %d\n", aNbS);
459 DumpKindOfShape (aKS);
460 DumpKindOfName (aKN);
461 DumpKindOfBounds(aKB);
462 DumpKindOfClosed(aKC);
465 //=======================================================================
466 //function : DumpSolid
468 //=======================================================================
469 void GEOMAlgo_ShapeInfo::DumpSolid()const
471 Standard_Integer aNbV, aNbE, aNbF;
472 GEOMAlgo_KindOfShape aKS;
473 GEOMAlgo_KindOfName aKN;
474 GEOMAlgo_KindOfBounds aKB;
475 GEOMAlgo_KindOfClosed aKC;
477 aNbV=NbSubShapes(TopAbs_VERTEX);
478 aNbE=NbSubShapes(TopAbs_EDGE);
479 aNbF=NbSubShapes(TopAbs_FACE);
486 printf(" number of vertices: %d\n", aNbV);
487 printf(" number of edges : %d\n", aNbE);
488 printf(" number of faces : %d\n", aNbF);
489 DumpKindOfShape (aKS);
490 DumpKindOfName (aKN);
491 DumpKindOfBounds(aKB);
492 DumpKindOfClosed(aKC);
494 if (aKN==GEOMAlgo_KN_SPHERE) {
495 DumpLocation (myLocation);
496 DumpPosition (myPosition);
497 printf(" Radius1 : %.3lf\n", myRadius1);
499 if (aKN==GEOMAlgo_KN_CYLINDER) {
500 DumpLocation (myLocation);
501 DumpPosition (myPosition);
502 printf(" Radius1 : %.3lf\n", myRadius1);
503 printf(" Height : %.3lf\n", myHeight);
505 else if (aKN==GEOMAlgo_KN_CONE) {
506 DumpLocation (myLocation);
507 DumpPosition (myPosition);
508 printf(" Radius1 : %.3lf\n", myRadius1);
509 printf(" Radius2 : %.3lf\n", myRadius2);
510 printf(" Height : %.3lf\n", myHeight);
512 else if (aKN==GEOMAlgo_KN_TORUS) {
513 DumpLocation (myLocation);
514 DumpPosition (myPosition);
515 printf(" Radius1 : %.3lf\n", myRadius1);
516 printf(" Radius2 : %.3lf\n", myRadius2);
518 else if (aKN==GEOMAlgo_KN_POLYHEDRON) {
519 DumpLocation (myLocation);
520 DumpPosition (myPosition);
522 else if (aKN==GEOMAlgo_KN_BOX) {
523 DumpLocation (myLocation);
524 DumpPosition (myPosition);
525 printf(" Length : %.3lf\n", myLength);
526 printf(" Width : %.3lf\n", myWidth);
527 printf(" Height : %.3lf\n", myHeight);
531 //=======================================================================
532 //function : DumpFace
534 //=======================================================================
535 void GEOMAlgo_ShapeInfo::DumpFace()const
537 Standard_Integer aNbV, aNbE;
538 GEOMAlgo_KindOfShape aKS;
539 GEOMAlgo_KindOfName aKN;
540 GEOMAlgo_KindOfBounds aKB;
541 GEOMAlgo_KindOfClosed aKC;
543 aNbV=NbSubShapes(TopAbs_VERTEX);
544 aNbE=NbSubShapes(TopAbs_EDGE);
551 printf(" number of vertices: %d\n", aNbV);
552 printf(" number of edges : %d\n", aNbE);
553 DumpKindOfShape (aKS);
554 DumpKindOfName (aKN);
555 DumpKindOfBounds(aKB);
556 DumpKindOfClosed(aKC);
559 if (aKN==GEOMAlgo_KN_PLANE) {
560 DumpLocation (myLocation);
561 DumpPosition (myPosition);
563 else if (aKN==GEOMAlgo_KN_DISKCIRCLE) {
564 DumpLocation (myLocation);
565 DumpPosition (myPosition);
566 printf(" Radius1 : %.3lf\n", myRadius1);
568 else if (aKN==GEOMAlgo_KN_DISKELLIPSE) {
569 DumpLocation (myLocation);
570 DumpPosition (myPosition);
571 printf(" Radius1 : %.3lf\n", myRadius1);
572 printf(" Radius2 : %.3lf\n", myRadius2);
574 else if (aKN==GEOMAlgo_KN_RECTANGLE) {
575 DumpLocation (myLocation);
576 DumpPosition (myPosition);
577 printf(" Length : %.3lf\n", myLength);
578 printf(" Width : %.3lf\n", myWidth);
580 else if (aKN==GEOMAlgo_KN_TRIANGLE ||
581 aKN==GEOMAlgo_KN_QUADRANGLE||
582 aKN==GEOMAlgo_KN_POLYGON) {
583 DumpLocation (myLocation);
584 DumpPosition (myPosition);
588 else if (aKN==GEOMAlgo_KN_SPHERE) {
589 DumpLocation (myLocation);
590 DumpPosition (myPosition);
591 printf(" Radius1 : %.3lf", myRadius1);
595 else if (aKN==GEOMAlgo_KN_CYLINDER) {
596 DumpLocation (myLocation);
597 DumpPosition (myPosition);
598 printf(" Radius1 : %.3lf\n", myRadius1);
599 printf(" Height : %.3lf\n", myHeight);
603 else if (aKN==GEOMAlgo_KN_CONE) {
604 DumpLocation (myLocation);
605 DumpPosition (myPosition);
606 printf(" Radius1 : %.3lf\n", myRadius1);
607 printf(" Radius2 : %.3lf\n", myRadius2);
608 printf(" Height : %.3lf\n", myHeight);
612 else if (aKN==GEOMAlgo_KN_TORUS) {
613 DumpLocation (myLocation);
614 DumpPosition (myPosition);
615 printf(" Radius1 : %.3lf\n", myRadius1);
616 printf(" Radius2 : %.3lf\n", myRadius2);
622 //=======================================================================
623 //function : DumpShell
625 //=======================================================================
626 void GEOMAlgo_ShapeInfo::DumpShell()const
628 Standard_Integer aNbV, aNbE, aNbF;
629 GEOMAlgo_KindOfClosed aKC;
633 aNbV=NbSubShapes(TopAbs_VERTEX);
634 aNbE=NbSubShapes(TopAbs_EDGE);
635 aNbF=NbSubShapes(TopAbs_FACE);
636 printf(" number of vertices: %d\n", aNbV);
637 printf(" number of edges : %d\n", aNbE);
638 printf(" number of faces : %d\n", aNbF);
640 DumpKindOfClosed(aKC);
643 //=======================================================================
644 //function : DumpWire
646 //=======================================================================
647 void GEOMAlgo_ShapeInfo::DumpWire()const
649 Standard_Integer aNbV, aNbE;
650 GEOMAlgo_KindOfClosed aKC;
654 aNbV=NbSubShapes(TopAbs_VERTEX);
655 aNbE=NbSubShapes(TopAbs_EDGE);
656 printf(" number of vertices: %d\n", aNbV);
657 printf(" number of edges : %d\n", aNbE);
660 DumpKindOfClosed(aKC);
663 //=======================================================================
664 //function : DumpEdge
666 //=======================================================================
667 void GEOMAlgo_ShapeInfo::DumpEdge()const
669 Standard_Integer aNbV;
670 Standard_Real aX, aY, aZ;
671 GEOMAlgo_KindOfShape aKS;
672 GEOMAlgo_KindOfName aKN;
673 GEOMAlgo_KindOfBounds aKB;
674 GEOMAlgo_KindOfClosed aKC;
676 aNbV=NbSubShapes(TopAbs_VERTEX);
683 printf(" number of vertices: %d\n", aNbV);
684 DumpKindOfShape (aKS);
685 DumpKindOfName (aKN);
686 DumpKindOfBounds(aKB);
687 DumpKindOfClosed(aKC);
690 if (aKN==GEOMAlgo_KN_LINE) {
691 DumpLocation (myLocation);
692 DumpDirection(myDirection);
694 else if (aKN==GEOMAlgo_KN_SEGMENT) {
695 DumpLocation (myLocation);
696 DumpDirection(myDirection);
697 printf(" Length : %.3lf\n", myLength);
698 myPnt1.Coord(aX, aY, aZ);
699 printf(" Pnt1 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
700 myPnt2.Coord(aX, aY, aZ);
701 printf(" Pnt2 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
704 else if (aKN==GEOMAlgo_KN_CIRCLE) {
705 DumpLocation (myLocation);
706 DumpPosition (myPosition);
707 printf(" Radius1 : %.3lf\n", myRadius1);
709 else if (aKN==GEOMAlgo_KN_ARCCIRCLE) {
710 DumpLocation (myLocation);
711 DumpPosition (myPosition);
712 printf(" Radius1 : %.3lf\n", myRadius1);
713 myPnt1.Coord(aX, aY, aZ);
714 printf(" Pnt1 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
715 myPnt2.Coord(aX, aY, aZ);
716 printf(" Pnt2 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
718 else if (aKN==GEOMAlgo_KN_ELLIPSE) {
719 DumpLocation (myLocation);
720 DumpPosition (myPosition);
721 printf(" Radius1 : %.3lf\n", myRadius1);
722 printf(" Radius2 : %.3lf\n", myRadius2);
724 else if (aKN==GEOMAlgo_KN_ARCELLIPSE) {
725 DumpLocation (myLocation);
726 DumpPosition (myPosition);
727 printf(" Radius1 : %.3lf\n", myRadius1);
728 printf(" Radius2 : %.3lf\n", myRadius2);
729 myPnt1.Coord(aX, aY, aZ);
730 printf(" Pnt1 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
731 myPnt2.Coord(aX, aY, aZ);
732 printf(" Pnt2 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
736 //=======================================================================
737 //function : DumpVertex
739 //=======================================================================
740 void GEOMAlgo_ShapeInfo::DumpVertex()const
742 printf(" *VERTEX\n");
743 DumpLocation(myLocation);
745 //=======================================================================
746 //function : DumpLocation
748 //=======================================================================
749 void DumpLocation(const gp_Pnt& aP)
751 Standard_Real aX, aY, aZ;
753 aP.Coord(aX, aY, aZ);
754 printf(" Location : %.3lf %.3lf %.3lf \n", aX, aY, aZ);
756 //=======================================================================
757 //function : DumpDirection
759 //=======================================================================
760 void DumpDirection(const gp_Dir& aD)
762 Standard_Real aX, aY, aZ;
764 aD.Coord(aX, aY, aZ);
765 printf(" Direction: %.3lf %.3lf %.3lf \n", aX, aY, aZ);
767 //=======================================================================
768 //function : DumpPosition
770 //=======================================================================
771 void DumpPosition(const gp_Ax3& aAx3)
773 const gp_Dir& aDZ=aAx3.Axis().Direction();
774 const gp_Dir& aDX=aAx3.XDirection();
775 const gp_Dir& aDY=aAx3.YDirection();
776 printf(" Position:\n");
777 printf(" Axis: %.3lf %.3lf %.3lf \n", aDZ.X(), aDZ.Y(), aDZ.Z());
778 printf(" X : %.3lf %.3lf %.3lf \n", aDX.X(), aDX.Y(), aDX.Z());
779 printf(" Y : %.3lf %.3lf %.3lf \n", aDY.X(), aDY.Y(), aDY.Z());
781 //=======================================================================
782 //function : DumpKindOfBounds
784 //=======================================================================
785 void DumpKindOfBounds(const GEOMAlgo_KindOfBounds aKB)
794 i=(Standard_Integer)aKB;
795 printf(" KindOfBounds: %s\n", pStr[i]);
798 //=======================================================================
799 //function : DumpKindOfClosed
801 //=======================================================================
802 void DumpKindOfClosed(const GEOMAlgo_KindOfClosed aKC)
811 i=(Standard_Integer)aKC;
812 printf(" KindOfClosed: %s\n", pStr[i]);
815 //=======================================================================
816 //function : DumpKindOfShape
818 //=======================================================================
819 void DumpKindOfShape(const GEOMAlgo_KindOfShape aKS)
836 i=(Standard_Integer)aKS;
837 printf(" KindOfShape : %s\n", pStr[i]);
839 //=======================================================================
840 //function : DumpKindOfName
842 //=======================================================================
843 void DumpKindOfName(const GEOMAlgo_KindOfName aKS)
869 i=(Standard_Integer)aKS;
870 printf(" KindOfName : %s\n", pStr[i]);