1 // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <GEOMAlgo_ShapeInfoFiller.hxx>
22 #include <Precision.hxx>
27 #include <gp_Circ.hxx>
29 #include <gp_Elips.hxx>
30 #include <gp_Sphere.hxx>
32 #include <gp_Cylinder.hxx>
33 #include <gp_Cone.hxx>
34 #include <gp_Torus.hxx>
36 #include <gp_Hypr.hxx>
37 #include <gp_Parab.hxx>
39 #include <Geom_Curve.hxx>
40 #include <Geom_Surface.hxx>
41 #include <Geom_BSplineCurve.hxx>
42 #include <Geom_BezierCurve.hxx>
44 #include <GeomAdaptor_Curve.hxx>
45 #include <GeomAdaptor_Surface.hxx>
48 #include <TopoDS_Edge.hxx>
49 #include <TopoDS_Solid.hxx>
50 #include <TopoDS_Vertex.hxx>
51 #include <TopoDS_Iterator.hxx>
52 #include <TopoDS_Wire.hxx>
53 #include <TopoDS_Face.hxx>
55 #include <BRep_Tool.hxx>
57 #include <BRepTools.hxx>
59 #include <TopTools_IndexedMapOfShape.hxx>
61 //=======================================================================
64 //=======================================================================
65 GEOMAlgo_ShapeInfoFiller::GEOMAlgo_ShapeInfoFiller()
71 //=======================================================================
74 //=======================================================================
75 GEOMAlgo_ShapeInfoFiller::~GEOMAlgo_ShapeInfoFiller()
78 //=======================================================================
79 //function : SetTolerance
81 //=======================================================================
82 void GEOMAlgo_ShapeInfoFiller::SetTolerance(const Standard_Real aT)
86 //=======================================================================
87 //function : Tolerance
89 //=======================================================================
90 Standard_Real GEOMAlgo_ShapeInfoFiller::Tolerance()const
94 //=======================================================================
97 //=======================================================================
98 void GEOMAlgo_ShapeInfoFiller::SetShape(const TopoDS_Shape& aS)
102 //=======================================================================
105 //=======================================================================
106 const TopoDS_Shape& GEOMAlgo_ShapeInfoFiller::Shape() const
110 //=======================================================================
113 //=======================================================================
114 const GEOMAlgo_ShapeInfo& GEOMAlgo_ShapeInfoFiller::Info() const
116 return Info(myShape);
118 //=======================================================================
121 //=======================================================================
122 const GEOMAlgo_ShapeInfo& GEOMAlgo_ShapeInfoFiller::Info
123 (const TopoDS_Shape& aS) const
126 if (myMapInfo.Contains(aS)) {
127 const GEOMAlgo_ShapeInfo& aInfo=myMapInfo.FindFromKey(aS);
134 //=======================================================================
135 //function : CheckData
137 //=======================================================================
138 void GEOMAlgo_ShapeInfoFiller::CheckData()
142 if (myShape.IsNull()) {
147 //=======================================================================
150 //=======================================================================
151 void GEOMAlgo_ShapeInfoFiller::Perform()
164 //=======================================================================
165 //function :FillShape
167 //=======================================================================
168 void GEOMAlgo_ShapeInfoFiller::FillShape(const TopoDS_Shape& aS)
170 TopAbs_ShapeEnum aType;
172 aType=aS.ShapeType();
193 case TopAbs_COMPSOLID:
194 case TopAbs_COMPOUND:
202 //=======================================================================
203 //function :FillSubShapes
205 //=======================================================================
206 void GEOMAlgo_ShapeInfoFiller::FillSubShapes(const TopoDS_Shape& aS)
211 for (; aIt.More(); aIt.Next()) {
212 const TopoDS_Shape& aSx=aIt.Value();
216 //=======================================================================
217 //function : FillContainer
219 //=======================================================================
220 void GEOMAlgo_ShapeInfoFiller::FillContainer(const TopoDS_Shape& aS)
224 Standard_Boolean bIsClosed;
225 TopAbs_ShapeEnum aType;
226 GEOMAlgo_KindOfClosed aKC;
228 aType=aS.ShapeType();
229 //----------------------------------------------------
230 if (myMapInfo.Contains(aS)) {
234 GEOMAlgo_ShapeInfo aInfoX;
235 myMapInfo.Add(aS, aInfoX);
237 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aS);
238 //----------------------------------------------------
239 aInfo.SetType(aType);
240 FillNbSubShapes(aS, aInfo);
242 if (aType==TopAbs_SHELL) {
243 bIsClosed=BRep_Tool::IsClosed(aS);
244 aKC=(bIsClosed) ? GEOMAlgo_KC_CLOSED :GEOMAlgo_KC_NOTCLOSED;
245 aInfo.SetKindOfClosed(aKC);
247 else if (aType==TopAbs_WIRE) {
249 TopoDS_Vertex aV1, aV2;
252 TopExp::Vertices(aW, aV1, aV2);
254 bIsClosed=aV1.IsSame(aV2);
255 aKC=(bIsClosed) ? GEOMAlgo_KC_CLOSED :GEOMAlgo_KC_NOTCLOSED;
256 aInfo.SetKindOfClosed(aKC);
261 //=======================================================================
262 //function : FillSolid
264 //=======================================================================
265 void GEOMAlgo_ShapeInfoFiller::FillSolid(const TopoDS_Shape& aS)
270 //----------------------------------------------------
271 if (myMapInfo.Contains(aS)) {
275 GEOMAlgo_ShapeInfo aInfoX;
276 myMapInfo.Add(aS, aInfoX);
278 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aS);
279 //----------------------------------------------------
280 aInfo.SetType(TopAbs_SOLID);
281 FillNbSubShapes(aS, aInfo);
284 aSd=TopoDS::Solid(aS);
288 //=======================================================================
291 //=======================================================================
292 void GEOMAlgo_ShapeInfoFiller::FillFace(const TopoDS_Shape& aS)
295 if (myMapInfo.Contains(aS)) {
299 Standard_Boolean bIsAllowedType;
300 Standard_Boolean bInf, bInfU1, bInfU2, bInfV1, bInfV2;
301 Standard_Real aUMin, aUMax, aVMin, aVMax, aR1, aR2, dV;
305 GeomAbs_SurfaceType aST;
306 Handle(Geom_Surface) aSurf;
308 //----------------------------------------------------
309 GEOMAlgo_ShapeInfo aInfoX;
310 myMapInfo.Add(aS, aInfoX);
312 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aS);
313 //----------------------------------------------------
314 aInfo.SetType(TopAbs_FACE);
316 FillNbSubShapes(aS, aInfo);
322 aSurf=BRep_Tool::Surface(aF);
323 GeomAdaptor_Surface aGAS(aSurf);
325 bIsAllowedType=GEOMAlgo_ShapeInfoFiller::IsAllowedType(aST);
326 if (!bIsAllowedType) {
330 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
332 if (aST==GeomAbs_Plane) {
337 aAx3=aPln.Position();
339 aInfo.SetKindOfShape(GEOMAlgo_KS_PLANE);
340 aInfo.SetKindOfName(GEOMAlgo_KN_PLANE);
341 aInfo.SetKindOfClosed(GEOMAlgo_KC_NOTCLOSED);
342 aInfo.SetLocation(aP0);
343 aInfo.SetPosition(aAx3);
345 BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
346 bInfU1=Precision::IsNegativeInfinite(aUMin);
347 bInfU2=Precision::IsPositiveInfinite(aUMax);
348 bInfV1=Precision::IsNegativeInfinite(aVMin);
349 bInfV2=Precision::IsPositiveInfinite(aVMax);
351 bInf=(bInfU1 || bInfU2 || bInfV1 || bInfV2);
353 aInfo.SetKindOfBounds(GEOMAlgo_KB_INFINITE);
357 aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
359 FillDetails(aF, aPln);
360 }// if (aCT==GeomAbs_Line) {
362 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
364 else if (aST==GeomAbs_Sphere) {
367 aSphere=aGAS.Sphere();
368 aP0=aSphere.Location();
369 aAx3=aSphere.Position();
370 aR1=aSphere.Radius();
372 aInfo.SetKindOfShape(GEOMAlgo_KS_SPHERE);
373 aInfo.SetKindOfName(GEOMAlgo_KN_SPHERE);
374 aInfo.SetLocation(aP0);
375 aInfo.SetPosition(aAx3);
376 aInfo.SetRadius1(aR1);
378 aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
379 aInfo.SetKindOfClosed(GEOMAlgo_KC_CLOSED);
381 FillDetails(aF, aSphere);
382 }// else if (aST==GeomAbs_Sphere) {
384 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
386 else if (aST==GeomAbs_Cylinder) {
389 aCyl=aGAS.Cylinder();
391 aAx3=aCyl.Position();
394 aInfo.SetKindOfShape(GEOMAlgo_KS_CYLINDER);
395 aInfo.SetKindOfName(GEOMAlgo_KN_CYLINDER);
396 aInfo.SetLocation(aP0);
397 aInfo.SetPosition(aAx3);
398 aInfo.SetRadius1(aR1);
400 BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
401 bInfU1=Precision::IsNegativeInfinite(aUMin);
402 bInfU2=Precision::IsPositiveInfinite(aUMax);
403 bInfV1=Precision::IsNegativeInfinite(aVMin);
404 bInfV2=Precision::IsPositiveInfinite(aVMax);
406 bInf=(bInfU1 || bInfU2 || bInfV1 || bInfV2);
408 aInfo.SetKindOfBounds(GEOMAlgo_KB_INFINITE);
412 aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
417 FillDetails(aF, aCyl);
420 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
422 else if (aST==GeomAbs_Cone) {
423 const gp_Cone aCone=aGAS.Cone();
425 aInfo.SetKindOfShape(GEOMAlgo_KS_CONE);
426 aInfo.SetKindOfName(GEOMAlgo_KN_CONE);
428 BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
430 bInfU1=Precision::IsNegativeInfinite(aUMin);
431 bInfU2=Precision::IsPositiveInfinite(aUMax);
432 bInfV1=Precision::IsNegativeInfinite(aVMin);
433 bInfV2=Precision::IsPositiveInfinite(aVMax);
435 bInf=bInfV1 || bInfV2;
438 aAx3=aCone.Position();
439 aInfo.SetLocation(aP0);
440 aInfo.SetPosition(aAx3);
441 aInfo.SetKindOfBounds(GEOMAlgo_KB_INFINITE);
445 aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
447 const Standard_Real aSemiAngle = aCone.SemiAngle();
450 Standard_Real H = dV * std::cos(aSemiAngle);
452 aAx3 = aCone.Position();
453 Standard_Real aShiftAlongAxisLength = aVMin * std::cos(aSemiAngle); // Required, because R1 does not equal to gp_Cone.RefRadius() in general case, and gp_Cone.Location() corresponds to the latter one.
454 auto aShiftAlongAxis = gp_Vec(aAx3.Direction().XYZ());
455 aShiftAlongAxis *= aShiftAlongAxisLength;
456 aAx3.Translate(aShiftAlongAxis);
459 aInfo.SetLocation(aP0);
460 aInfo.SetPosition(aAx3);
462 aR1 = aCone.RefRadius() + aVMin * std::sin(aSemiAngle);
463 aR2 = aCone.RefRadius() + aVMax * std::sin(aSemiAngle);
465 aInfo.SetRadius1(aR1);
466 aInfo.SetRadius2(aR2);
468 aInfo.SetKindOfDef(GEOMAlgo_KD_SPECIFIED);
471 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
473 else if (aST==GeomAbs_Torus) {
477 aP0=aTorus.Location();
478 aAx3=aTorus.Position();
479 aR1=aTorus.MajorRadius();
480 aR2=aTorus.MinorRadius();
482 aInfo.SetKindOfShape(GEOMAlgo_KS_TORUS);
483 aInfo.SetKindOfName(GEOMAlgo_KN_TORUS);
484 aInfo.SetLocation(aP0);
485 aInfo.SetPosition(aAx3);
486 aInfo.SetRadius1(aR1);
487 aInfo.SetRadius2(aR2);
489 aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
491 FillDetails(aF, aTorus);
494 //=======================================================================
497 //=======================================================================
498 void GEOMAlgo_ShapeInfoFiller::FillEdge(const TopoDS_Shape& aS)
502 Standard_Boolean bDegenerated, bIsAllowedType;
503 Standard_Integer aNbV;
504 Standard_Real aR1, aR2;
505 gp_Pnt aP, aP1, aP2, aPc;
508 Standard_Real aT1, aT2;
509 GeomAbs_CurveType aCT;
510 Handle(Geom_Curve) aC3D;
512 //----------------------------------------------------
513 if (myMapInfo.Contains(aS)) {
517 GEOMAlgo_ShapeInfo aInfoX;
518 myMapInfo.Add(aS, aInfoX);
520 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aS);
521 //----------------------------------------------------
522 aInfo.SetType(TopAbs_EDGE);
524 FillNbSubShapes(aS, aInfo);
528 bDegenerated=BRep_Tool::Degenerated(aE);
530 aInfo.SetKindOfShape(GEOMAlgo_KS_DEGENERATED);
535 aC3D=BRep_Tool::Curve(aE, aT1, aT2);
536 GeomAdaptor_Curve aGAC(aC3D);
538 bIsAllowedType=GEOMAlgo_ShapeInfoFiller::IsAllowedType(aCT);
539 if (!bIsAllowedType) {
544 if (aCT==GeomAbs_BSplineCurve) {
545 Standard_Integer aNbKnots, aNbPoles, aNbWeights, aNbMultiplicities, aDegree, i;
546 Standard_Real aLength;
547 gp_XYZ aXYZ1, aXYZ2, aXYZc;
548 Handle(Geom_BSplineCurve) aBSp;
551 aDegree = aBSp->Degree();
552 aNbPoles = aBSp->NbPoles();
553 aNbKnots = aBSp->NbKnots();
554 aNbWeights = (aBSp->IsRational() ? aNbPoles : 0);
555 aNbMultiplicities = (aBSp->KnotDistribution() == GeomAbs_Uniform ? 0 : aNbKnots);
556 if (aDegree==1 && aNbKnots==2 && aNbPoles==2) {
557 // This is a single line segment
558 aInfo.SetKindOfShape(GEOMAlgo_KS_BSPLINE);
559 aInfo.SetKindOfClosed(GEOMAlgo_KC_NOTCLOSED);
561 aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
562 aInfo.SetKindOfName(GEOMAlgo_KN_SEGMENT);
568 aLength=aP1.Distance(aP2);
569 aInfo.SetLength(aLength);
576 aInfo.SetLocation(aPc);
578 if ( aLength >= gp::Resolution() ) {
579 gp_Vec aVec(aPc, aP2);
581 aInfo.SetDirection(aDir);
585 // We have a higher degree B-Spline curve
586 aInfo.SetKindOfShape(GEOMAlgo_KS_BSPLINE);
587 aInfo.SetKindOfName(GEOMAlgo_KN_CURVEBSPLINE);
588 aInfo.SetKindOfPeriod(aBSp->IsPeriodic() ? GEOMAlgo_KP_PERIODIC : GEOMAlgo_KP_NONPERIODIC);
589 aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
590 aInfo.SetKindOfClosed(aBSp->IsClosed() ? GEOMAlgo_KC_CLOSED : GEOMAlgo_KC_NOTCLOSED);
596 aInfo.SetDegree(aDegree);
597 aInfo.SetNbKnots(aNbKnots);
598 aInfo.SetNbPoles(aNbPoles);
599 aInfo.SetNbWeights(aNbWeights);
600 aInfo.SetNbMultiplicities(aNbMultiplicities);
602 Handle(TColgp_HArray1OfPnt) poles = new TColgp_HArray1OfPnt(1, aNbPoles);
603 for (i=1; i<=aNbPoles; i++)
604 poles->SetValue(i, aBSp->Pole(i));
605 aInfo.SetPoles(poles);
607 Handle(TColStd_HArray1OfReal) knots = new TColStd_HArray1OfReal(1, aNbKnots);
608 for (i=1; i<=aNbKnots; i++)
609 knots->SetValue(i, aBSp->Knot(i));
610 aInfo.SetKnots(knots);
612 if (aNbWeights > 0) {
613 Handle(TColStd_HArray1OfReal) weights = new TColStd_HArray1OfReal(1, aNbWeights);
614 for (i=1; i<=aNbWeights; i++)
615 weights->SetValue(i, aBSp->Weight(i));
616 aInfo.SetWeights(weights);
618 // Fill the multiplicities
619 if (aNbMultiplicities > 0) {
620 Handle(TColStd_HArray1OfInteger) mults = new TColStd_HArray1OfInteger(1, aNbMultiplicities);
621 for (i=1; i<=aNbMultiplicities; i++)
622 mults->SetValue(i, aBSp->Multiplicity(i));
623 aInfo.SetMultiplicities(mults);
626 }//if (aCT==GeomAbs_BSplineCurve) {
628 else if (aCT==GeomAbs_BezierCurve) {
629 Standard_Integer aNbPoles, aNbWeights, aDegree, i;
630 Handle(Geom_BezierCurve) aBC;
632 aNbPoles = aBC->NbPoles();
633 aNbWeights = (aBC->IsRational() ? aNbPoles : 0);
634 aDegree = aBC->Degree();
635 aInfo.SetKindOfShape(GEOMAlgo_KS_BEZIER);
636 aInfo.SetKindOfName(GEOMAlgo_KN_CURVEBEZIER);
637 aInfo.SetKindOfPeriod(aBC->IsPeriodic() ? GEOMAlgo_KP_PERIODIC : GEOMAlgo_KP_NONPERIODIC);
638 aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
639 aInfo.SetKindOfClosed(aBC->IsClosed() ? GEOMAlgo_KC_CLOSED : GEOMAlgo_KC_NOTCLOSED);
645 aInfo.SetDegree(aDegree);
646 aInfo.SetNbPoles(aNbPoles);
647 aInfo.SetNbWeights(aNbWeights);
649 Handle(TColgp_HArray1OfPnt) poles = new TColgp_HArray1OfPnt(1, aNbPoles);
650 for (i=1; i<=aNbPoles; i++)
651 poles->SetValue(i, aBC->Pole(i));
652 aInfo.SetPoles(poles);
654 if (aNbWeights > 0) {
655 Handle(TColStd_HArray1OfReal) weights = new TColStd_HArray1OfReal(1, aNbWeights);
656 for (i=1; i<=aNbWeights; i++)
657 weights->SetValue(i, aBC->Weight(i));
658 aInfo.SetWeights(weights);
660 }// if (aCT==GeomAbs_BezierCurve) {
662 else if (aCT==GeomAbs_Line) {
663 Standard_Boolean bInf1, bInf2;
664 Standard_Real aLength;
666 gp_XYZ aXYZ1, aXYZ2, aXYZc;
672 aInfo.SetKindOfShape(GEOMAlgo_KS_LINE);
673 aInfo.SetKindOfClosed(GEOMAlgo_KC_NOTCLOSED);
674 aInfo.SetLocation(aP);
675 aInfo.SetDirection(aD);
677 bInf1=Precision::IsNegativeInfinite(aT1);
678 bInf2=Precision::IsPositiveInfinite(aT2);
680 aInfo.SetKindOfBounds(GEOMAlgo_KB_INFINITE);
681 aInfo.SetKindOfName(GEOMAlgo_KN_LINE);
684 aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
685 aInfo.SetKindOfName(GEOMAlgo_KN_SEGMENT);
691 aLength=aP1.Distance(aP2);
698 gp_Vec aVec(aPc, aP2);
701 aInfo.SetLocation(aPc);
702 aInfo.SetDirection(aDir);
703 aInfo.SetLength(aLength);
705 }// if (aCT==GeomAbs_Line) {
708 else if (aCT==GeomAbs_Circle) {
713 aAx2=aCirc.Position();
716 aInfo.SetKindOfShape(GEOMAlgo_KS_CIRCLE);
717 aInfo.SetLocation(aP);
718 aInfo.SetPosition(aAx2);
719 aInfo.SetRadius1(aR1);
721 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
723 myErrorStatus=11; // circle edge without vertices
726 aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
733 aInfo.SetKindOfClosed(GEOMAlgo_KC_CLOSED);
734 aInfo.SetKindOfName(GEOMAlgo_KN_CIRCLE);
737 aInfo.SetKindOfClosed(GEOMAlgo_KC_NOTCLOSED);
738 aInfo.SetKindOfName(GEOMAlgo_KN_ARCCIRCLE);
740 gp_Vec aVecX(aP, aP1);
742 gp_Ax2 aAx2new(aP, aAx2.Direction(), aDirX);
743 aInfo.SetPosition(aAx2new);
745 }// else if (aCT==GeomAbs_Circle) {
748 else if (aCT==GeomAbs_Ellipse) {
751 aElips=aGAC.Ellipse();
752 aP=aElips.Location();
753 aAx2=aElips.Position();
754 aR1=aElips.MajorRadius();
755 aR2=aElips.MinorRadius();
757 aInfo.SetKindOfShape(GEOMAlgo_KS_ELLIPSE);
758 aInfo.SetLocation(aP);
759 aInfo.SetPosition(aAx2);
760 aInfo.SetRadius1(aR1);
761 aInfo.SetRadius2(aR2);
763 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
765 myErrorStatus=11; // ellipse edge without vertices
768 aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
775 aInfo.SetKindOfClosed(GEOMAlgo_KC_CLOSED);
776 aInfo.SetKindOfName(GEOMAlgo_KN_ELLIPSE);
779 aInfo.SetKindOfClosed(GEOMAlgo_KC_NOTCLOSED);
780 aInfo.SetKindOfName(GEOMAlgo_KN_ARCELLIPSE);
782 }// else if (aCT==GeomAbs_Ellipse) {
784 else if (aCT==GeomAbs_Hyperbola) {
786 aHyp=aGAC.Hyperbola();
788 aAx2=aHyp.Position();
789 aR1=aHyp.MajorRadius();
790 aR2=aHyp.MinorRadius();
791 aInfo.SetKindOfShape(GEOMAlgo_KS_HYPERBOLA);
792 aInfo.SetKindOfName(GEOMAlgo_KN_HYPERBOLA);
793 aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
794 aInfo.SetLocation(aP);
795 aInfo.SetPosition(aAx2);
796 aInfo.SetRadius1(aR1);
797 aInfo.SetRadius2(aR2);
804 }// if (aCT==GeomAbs_Hyperbola) {
806 else if (aCT==GeomAbs_Parabola) {
808 aPara=aGAC.Parabola();
810 aAx2=aPara.Position();
812 aInfo.SetKindOfShape(GEOMAlgo_KS_PARABOLA);
813 aInfo.SetKindOfName(GEOMAlgo_KN_PARABOLA);
814 aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
815 aInfo.SetLocation(aP);
816 aInfo.SetPosition(aAx2);
817 aInfo.SetRadius1(aR1);
824 }// if (aCT==GeomAbs_Parabola) {
828 //=======================================================================
829 //function :FillVertex
831 //=======================================================================
832 void GEOMAlgo_ShapeInfoFiller::FillVertex(const TopoDS_Shape& aS)
839 if (myMapInfo.Contains(aS)) {
843 GEOMAlgo_ShapeInfo aInfoX;
844 myMapInfo.Add(aS, aInfoX);
846 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aS);
848 aV=TopoDS::Vertex(aS);
849 aP=BRep_Tool::Pnt(aV);
851 aInfo.SetType(TopAbs_VERTEX);
852 aInfo.SetLocation(aP);
853 myMapInfo.Add(aS, aInfo);
855 //=======================================================================
856 //function : FillNbSubshapes
858 //=======================================================================
859 void GEOMAlgo_ShapeInfoFiller::FillNbSubShapes(const TopoDS_Shape& aS,
860 GEOMAlgo_ShapeInfo& aInfo)
864 Standard_Integer i, aNb, aNbS;
865 TopTools_IndexedMapOfShape aM;
866 TopAbs_ShapeEnum aST;
867 TopAbs_ShapeEnum aTypes[]= {
868 //TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX
881 aNb=sizeof(aTypes)/sizeof(aTypes[0]);
882 for (i=0; i<aNb; ++i) {
883 if (aTypes[i]==aST) {
887 TopExp::MapShapes(aS, aTypes[i], aM);
889 aInfo.SetNbSubShapes(aTypes[i], aNbS);
892 //=======================================================================
895 //=======================================================================
896 Standard_Integer GEOMAlgo_ShapeInfoFiller::NbShells
897 (const TopoDS_Solid& aSd)
899 Standard_Integer iCnt;
905 for (; aIt.More(); aIt.Next()) {
910 //=======================================================================
913 //=======================================================================
914 Standard_Integer GEOMAlgo_ShapeInfoFiller::NbWires
915 (const TopoDS_Face& aF)
917 Standard_Integer iCnt;
923 for (; aIt.More(); aIt.Next()) {
928 //=======================================================================
929 //function : IsAllowedType
931 //=======================================================================
932 Standard_Boolean GEOMAlgo_ShapeInfoFiller::IsAllowedType
933 (const GeomAbs_CurveType aCT)
935 Standard_Boolean bRet;
936 Standard_Integer i, aNb;
937 GeomAbs_CurveType aTypes[]={
941 GeomAbs_BSplineCurve,
948 aNb=sizeof(aTypes)/sizeof(aTypes[0]);
949 for (i=0; i<aNb && !bRet; ++i) {
950 bRet=(aCT==aTypes[i]);
954 //=======================================================================
955 //function : IsAllowedType
957 //=======================================================================
958 Standard_Boolean GEOMAlgo_ShapeInfoFiller::IsAllowedType
959 (const GeomAbs_SurfaceType aST)
961 Standard_Boolean bRet;
962 Standard_Integer i, aNb;
963 GeomAbs_SurfaceType aTypes[]={
964 GeomAbs_Plane, GeomAbs_Cylinder,
965 GeomAbs_Cone, GeomAbs_Sphere,
970 aNb=sizeof(aTypes)/sizeof(aTypes[0]);
971 for (i=0; i<aNb && !bRet; ++i) {
972 bRet=(aST==aTypes[i]);
981 // 1 - The object is just initialized
984 // 11 - circle/ellipse edge without vertices