-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include <GEOMAlgo_ShapeInfoFiller.ixx>
+
+#include <GEOMAlgo_ShapeInfoFiller.hxx>
#include <Precision.hxx>
#include <gp_Lin.hxx>
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
-
-#include <Geom_Curve.hxx>
-#include <GeomAdaptor_Curve.hxx>
-
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-
-#include <BRep_Tool.hxx>
-#include <TopExp.hxx>
-
-#include <TopTools_IndexedMapOfShape.hxx>
#include <gp_Circ.hxx>
#include <gp_Ax2.hxx>
#include <gp_Elips.hxx>
-#include <TopoDS_Iterator.hxx>
-#include <TopoDS_Wire.hxx>
-#include <TopExp.hxx>
-#include <Geom_Surface.hxx>
-#include <TopoDS_Face.hxx>
-#include <GeomAdaptor_Surface.hxx>
-#include <gp_Pln.hxx>
#include <gp_Sphere.hxx>
#include <gp_Ax3.hxx>
-#include <BRepTools.hxx>
#include <gp_Cylinder.hxx>
#include <gp_Cone.hxx>
#include <gp_Torus.hxx>
-#include <TopoDS_Solid.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Hypr.hxx>
+#include <gp_Parab.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_BSplineCurve.hxx>
+#include <Geom_BezierCurve.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <GeomAdaptor_Surface.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Face.hxx>
+
+#include <BRep_Tool.hxx>
+#include <TopExp.hxx>
+#include <BRepTools.hxx>
-static
- Standard_Boolean IsAllowedType(const GeomAbs_CurveType aCT);
-static
- Standard_Boolean IsAllowedType(const GeomAbs_SurfaceType aST);
-static
- Standard_Integer NbWires(const TopoDS_Face& aF);
-static
- Standard_Integer NbShells(const TopoDS_Solid& aS);
+#include <TopTools_IndexedMapOfShape.hxx>
//=======================================================================
-//function :
-//purpose :
+//function :
+//purpose :
//=======================================================================
- GEOMAlgo_ShapeInfoFiller::GEOMAlgo_ShapeInfoFiller()
+GEOMAlgo_ShapeInfoFiller::GEOMAlgo_ShapeInfoFiller()
:
GEOMAlgo_Algo()
{
}
//=======================================================================
//function : ~
-//purpose :
+//purpose :
//=======================================================================
- GEOMAlgo_ShapeInfoFiller::~GEOMAlgo_ShapeInfoFiller()
+GEOMAlgo_ShapeInfoFiller::~GEOMAlgo_ShapeInfoFiller()
{
}
//=======================================================================
//function : SetTolerance
-//purpose :
+//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::SetTolerance(const Standard_Real aT)
+void GEOMAlgo_ShapeInfoFiller::SetTolerance(const Standard_Real aT)
{
myTolerance=aT;
}
//=======================================================================
//function : Tolerance
-//purpose :
+//purpose :
//=======================================================================
- Standard_Real GEOMAlgo_ShapeInfoFiller::Tolerance()const
+Standard_Real GEOMAlgo_ShapeInfoFiller::Tolerance()const
{
return myTolerance;
}
//=======================================================================
//function : SetShape
-//purpose :
+//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::SetShape(const TopoDS_Shape& aS)
+void GEOMAlgo_ShapeInfoFiller::SetShape(const TopoDS_Shape& aS)
{
myShape=aS;
}
//=======================================================================
//function : Shape
-//purpose :
+//purpose :
//=======================================================================
- const TopoDS_Shape& GEOMAlgo_ShapeInfoFiller::Shape() const
+const TopoDS_Shape& GEOMAlgo_ShapeInfoFiller::Shape() const
{
return myShape;
}
//=======================================================================
//function : Info
-//purpose :
+//purpose :
//=======================================================================
- const GEOMAlgo_ShapeInfo& GEOMAlgo_ShapeInfoFiller::Info() const
+const GEOMAlgo_ShapeInfo& GEOMAlgo_ShapeInfoFiller::Info() const
{
- return Info(myShape);
+ return Info(myShape);
}
//=======================================================================
//function : Info
-//purpose :
+//purpose :
//=======================================================================
- const GEOMAlgo_ShapeInfo& GEOMAlgo_ShapeInfoFiller::Info(const TopoDS_Shape& aS) const
+const GEOMAlgo_ShapeInfo& GEOMAlgo_ShapeInfoFiller::Info
+ (const TopoDS_Shape& aS) const
{
if (!aS.IsNull()) {
if (myMapInfo.Contains(aS)) {
return aInfo;
}
}
- return myEmptyInfo;
+ return myEmptyInfo;
}
//=======================================================================
//function : CheckData
-//purpose :
+//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::CheckData()
+void GEOMAlgo_ShapeInfoFiller::CheckData()
{
myErrorStatus=0;
//
}
//=======================================================================
//function : Perform
-//purpose :
+//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::Perform()
+void GEOMAlgo_ShapeInfoFiller::Perform()
{
myErrorStatus=0;
//
FillShape(myShape);
}
//=======================================================================
-//function :FillShape
-//purpose :
+//function :FillShape
+//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::FillShape(const TopoDS_Shape& aS)
+void GEOMAlgo_ShapeInfoFiller::FillShape(const TopoDS_Shape& aS)
{
TopAbs_ShapeEnum aType;
//
case TopAbs_VERTEX:
FillVertex(aS);
break;
- //
+ //
case TopAbs_EDGE:
FillEdge(aS);
break;
case TopAbs_COMPOUND:
FillContainer(aS);
break;
- //
+ //
default:
break;
}
}
//=======================================================================
-//function :FillSubShapes
-//purpose :
+//function :FillSubShapes
+//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::FillSubShapes(const TopoDS_Shape& aS)
+void GEOMAlgo_ShapeInfoFiller::FillSubShapes(const TopoDS_Shape& aS)
{
TopoDS_Iterator aIt;
//
aIt.Initialize(aS);
- for (; aIt.More(); aIt.Next()){
+ for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
FillShape(aSx);
}
}
//=======================================================================
//function : FillContainer
-//purpose :
+//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::FillContainer(const TopoDS_Shape& aS)
+void GEOMAlgo_ShapeInfoFiller::FillContainer(const TopoDS_Shape& aS)
{
myErrorStatus=0;
//
}
//=======================================================================
//function : FillSolid
-//purpose :
+//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::FillSolid(const TopoDS_Shape& aS)
+void GEOMAlgo_ShapeInfoFiller::FillSolid(const TopoDS_Shape& aS)
{
- Standard_Integer aNbShells;
TopoDS_Solid aSd;
//
myErrorStatus=0;
//
aSd=TopoDS::Solid(aS);
//
- aNbShells=NbShells(aSd);
- if (aNbShells>1) {
- return;
- }
- //
FillDetails(aSd);
}
//=======================================================================
-//function :FillFace
-//purpose :
+//function :FillFace
+//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::FillFace(const TopoDS_Shape& aS)
+void GEOMAlgo_ShapeInfoFiller::FillFace(const TopoDS_Shape& aS)
{
myErrorStatus=0;
+ if (myMapInfo.Contains(aS)) {
+ return;
+ }
//
Standard_Boolean bIsAllowedType;
- Standard_Integer aNbWires;//, iRet
Standard_Boolean bInf, bInfU1, bInfU2, bInfV1, bInfV2;
- Standard_Real aUMin, aUMax, aVMin, aVMax, aR1, aR2;
- gp_Pnt aP0;
+ Standard_Real aUMin, aUMax, aVMin, aVMax, aR1, aR2, dV;
+ gp_Pnt aP0;
gp_Dir aDN;
gp_Ax3 aAx3;
GeomAbs_SurfaceType aST;
Handle(Geom_Surface) aSurf;
TopoDS_Face aF;
- //GEOMAlgo_KindOfName aKindOfName;
//----------------------------------------------------
- if (myMapInfo.Contains(aS)) {
- return;
- }
- else {
- GEOMAlgo_ShapeInfo aInfoX;
- myMapInfo.Add(aS, aInfoX);
- }
+ GEOMAlgo_ShapeInfo aInfoX;
+ myMapInfo.Add(aS, aInfoX);
+ //
GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aS);
//----------------------------------------------------
aInfo.SetType(TopAbs_FACE);
//
aF=TopoDS::Face(aS);
//
- aNbWires=NbWires(aF);
- //
aSurf=BRep_Tool::Surface(aF);
GeomAdaptor_Surface aGAS(aSurf);
aST=aGAS.GetType();
- bIsAllowedType=IsAllowedType(aST);
+ bIsAllowedType=GEOMAlgo_ShapeInfoFiller::IsAllowedType(aST);
if (!bIsAllowedType) {
return;
}
//
+ //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 1. Plane
if (aST==GeomAbs_Plane) {
gp_Pln aPln;
aAx3=aPln.Position();
//
aInfo.SetKindOfShape(GEOMAlgo_KS_PLANE);
+ aInfo.SetKindOfName(GEOMAlgo_KN_PLANE);
aInfo.SetKindOfClosed(GEOMAlgo_KC_NOTCLOSED);
aInfo.SetLocation(aP0);
aInfo.SetPosition(aAx3);
//
- if (aNbWires>1) return;
- //
- //aSurf->Bounds(aUMin, aUMax, aVMin, aVMax);
BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
bInfU1=Precision::IsNegativeInfinite(aUMin);
bInfU2=Precision::IsPositiveInfinite(aUMax);
bInf=(bInfU1 || bInfU2 || bInfV1 || bInfV2);
if (bInf) {
aInfo.SetKindOfBounds(GEOMAlgo_KB_INFINITE);
- }
- else {
- aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
+ return;
}
//
+ aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
+ //
FillDetails(aF, aPln);
}// if (aCT==GeomAbs_Line) {
//
+ //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 2. Sphere
else if (aST==GeomAbs_Sphere) {
gp_Sphere aSphere;
aR1=aSphere.Radius();
//
aInfo.SetKindOfShape(GEOMAlgo_KS_SPHERE);
+ aInfo.SetKindOfName(GEOMAlgo_KN_SPHERE);
aInfo.SetLocation(aP0);
aInfo.SetPosition(aAx3);
aInfo.SetRadius1(aR1);
//
- if (aNbWires>1) return;
- //
aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
aInfo.SetKindOfClosed(GEOMAlgo_KC_CLOSED);
//
FillDetails(aF, aSphere);
}// else if (aST==GeomAbs_Sphere) {
- //
+ //
+ //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 3. Cylinder
else if (aST==GeomAbs_Cylinder) {
gp_Cylinder aCyl;
aR1=aCyl.Radius();
//
aInfo.SetKindOfShape(GEOMAlgo_KS_CYLINDER);
+ aInfo.SetKindOfName(GEOMAlgo_KN_CYLINDER);
aInfo.SetLocation(aP0);
aInfo.SetPosition(aAx3);
aInfo.SetRadius1(aR1);
//
- if (aNbWires>1) return;
- //
BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
bInfU1=Precision::IsNegativeInfinite(aUMin);
bInfU2=Precision::IsPositiveInfinite(aUMax);
bInf=(bInfU1 || bInfU2 || bInfV1 || bInfV2);
if (bInf) {
aInfo.SetKindOfBounds(GEOMAlgo_KB_INFINITE);
+ return;
}
- else {
- aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
- }
+ //
+ aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
+ //
+ dV=aVMax-aVMin;
+ aInfo.SetHeight(dV);
+ //
FillDetails(aF, aCyl);
}
- //
+ //
+ //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 4. Cone
else if (aST==GeomAbs_Cone) {
- gp_Cone aCone;
- //
- aCone=aGAS.Cone();
- aP0=aCone.Location();
- aAx3=aCone.Position();
- //aR1=aCyl.Radius();
+ const gp_Cone aCone=aGAS.Cone();
//
aInfo.SetKindOfShape(GEOMAlgo_KS_CONE);
- aInfo.SetLocation(aP0);
- aInfo.SetPosition(aAx3);
- //aInfo.SetRadius1(aR1);
- //
- if (aNbWires>1) return;
+ aInfo.SetKindOfName(GEOMAlgo_KN_CONE);
//
BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
+
bInfU1=Precision::IsNegativeInfinite(aUMin);
bInfU2=Precision::IsPositiveInfinite(aUMax);
bInfV1=Precision::IsNegativeInfinite(aVMin);
bInfV2=Precision::IsPositiveInfinite(aVMax);
//
- bInf=(bInfU1 || bInfU2 || bInfV1 || bInfV2);
+ bInf=bInfV1 || bInfV2;
if (bInf) {
+ aP0=aAx3.Location();
+ aAx3=aCone.Position();
+ aInfo.SetLocation(aP0);
+ aInfo.SetPosition(aAx3);
aInfo.SetKindOfBounds(GEOMAlgo_KB_INFINITE);
+ return;
}
- else {
- aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
- }
- FillDetails(aF, aCone);
+ //
+ aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
+ //
+ const Standard_Real aSemiAngle = aCone.SemiAngle();
+
+ dV = aVMax - aVMin;
+ Standard_Real H = dV * std::cos(aSemiAngle);
+
+ aAx3 = aCone.Position();
+ 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.
+ auto aShiftAlongAxis = gp_Vec(aAx3.Direction().XYZ());
+ aShiftAlongAxis *= aShiftAlongAxisLength;
+ aAx3.Translate(aShiftAlongAxis);
+
+ aP0=aAx3.Location();
+ aInfo.SetLocation(aP0);
+ aInfo.SetPosition(aAx3);
+
+ aR1 = aCone.RefRadius() + aVMin * std::sin(aSemiAngle);
+ aR2 = aCone.RefRadius() + aVMax * std::sin(aSemiAngle);
+
+ aInfo.SetRadius1(aR1);
+ aInfo.SetRadius2(aR2);
+ aInfo.SetHeight(H);
+ aInfo.SetKindOfDef(GEOMAlgo_KD_SPECIFIED);
}
- //
+ //
+ //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 5. Torus
else if (aST==GeomAbs_Torus) {
gp_Torus aTorus;
aR2=aTorus.MinorRadius();
//
aInfo.SetKindOfShape(GEOMAlgo_KS_TORUS);
+ aInfo.SetKindOfName(GEOMAlgo_KN_TORUS);
aInfo.SetLocation(aP0);
aInfo.SetPosition(aAx3);
aInfo.SetRadius1(aR1);
aInfo.SetRadius2(aR2);
//
- if (aNbWires>1) return;
- //
aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
//
FillDetails(aF, aTorus);
}
}
//=======================================================================
-//function :FillEdge
-//purpose :
+//function :FillEdge
+//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::FillEdge(const TopoDS_Shape& aS)
+void GEOMAlgo_ShapeInfoFiller::FillEdge(const TopoDS_Shape& aS)
{
myErrorStatus=0;
//
aC3D=BRep_Tool::Curve(aE, aT1, aT2);
GeomAdaptor_Curve aGAC(aC3D);
aCT=aGAC.GetType();
- bIsAllowedType=IsAllowedType(aCT);
+ bIsAllowedType=GEOMAlgo_ShapeInfoFiller::IsAllowedType(aCT);
if (!bIsAllowedType) {
FillSubShapes(aS);
return;
}
+ // BSplineCurve
+ if (aCT==GeomAbs_BSplineCurve) {
+ Standard_Integer aNbKnots, aNbPoles, aNbWeights, aNbMultiplicities, aDegree, i;
+ Standard_Real aLength;
+ gp_XYZ aXYZ1, aXYZ2, aXYZc;
+ Handle(Geom_BSplineCurve) aBSp;
+ //
+ aBSp=aGAC.BSpline();
+ aDegree = aBSp->Degree();
+ aNbPoles = aBSp->NbPoles();
+ aNbKnots = aBSp->NbKnots();
+ aNbWeights = (aBSp->IsRational() ? aNbPoles : 0);
+ aNbMultiplicities = (aBSp->KnotDistribution() == GeomAbs_Uniform ? 0 : aNbKnots);
+ if (aDegree==1 && aNbKnots==2 && aNbPoles==2) {
+ // This is a single line segment
+ aInfo.SetKindOfShape(GEOMAlgo_KS_BSPLINE);
+ aInfo.SetKindOfClosed(GEOMAlgo_KC_NOTCLOSED);
+ //
+ aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
+ aInfo.SetKindOfName(GEOMAlgo_KN_SEGMENT);
+ aGAC.D0(aT1, aP1);
+ aGAC.D0(aT2, aP2);
+ aInfo.SetPnt1(aP1);
+ aInfo.SetPnt2(aP2);
+ //
+ aLength=aP1.Distance(aP2);
+ aInfo.SetLength(aLength);
+ //
+ aXYZ1=aP1.XYZ();
+ aXYZ2=aP2.XYZ();
+ aXYZc=aXYZ1+aXYZ2;
+ aXYZc.Multiply(0.5);
+ aPc.SetXYZ(aXYZc);
+ aInfo.SetLocation(aPc);
+ //
+ if ( aLength >= gp::Resolution() ) {
+ gp_Vec aVec(aPc, aP2);
+ gp_Dir aDir(aVec);
+ aInfo.SetDirection(aDir);
+ }
+ }
+ else {
+ // We have a higher degree B-Spline curve
+ aInfo.SetKindOfShape(GEOMAlgo_KS_BSPLINE);
+ aInfo.SetKindOfName(GEOMAlgo_KN_CURVEBSPLINE);
+ aInfo.SetKindOfPeriod(aBSp->IsPeriodic() ? GEOMAlgo_KP_PERIODIC : GEOMAlgo_KP_NONPERIODIC);
+ aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
+ aInfo.SetKindOfClosed(aBSp->IsClosed() ? GEOMAlgo_KC_CLOSED : GEOMAlgo_KC_NOTCLOSED);
+ aGAC.D0(aT1, aP1);
+ aGAC.D0(aT2, aP2);
+ aInfo.SetPnt1(aP1);
+ aInfo.SetPnt2(aP2);
+ //
+ aInfo.SetDegree(aDegree);
+ aInfo.SetNbKnots(aNbKnots);
+ aInfo.SetNbPoles(aNbPoles);
+ aInfo.SetNbWeights(aNbWeights);
+ aInfo.SetNbMultiplicities(aNbMultiplicities);
+ // Fill the poles
+ Handle(TColgp_HArray1OfPnt) poles = new TColgp_HArray1OfPnt(1, aNbPoles);
+ for (i=1; i<=aNbPoles; i++)
+ poles->SetValue(i, aBSp->Pole(i));
+ aInfo.SetPoles(poles);
+ // Fill the knots
+ Handle(TColStd_HArray1OfReal) knots = new TColStd_HArray1OfReal(1, aNbKnots);
+ for (i=1; i<=aNbKnots; i++)
+ knots->SetValue(i, aBSp->Knot(i));
+ aInfo.SetKnots(knots);
+ // Fill the weights
+ if (aNbWeights > 0) {
+ Handle(TColStd_HArray1OfReal) weights = new TColStd_HArray1OfReal(1, aNbWeights);
+ for (i=1; i<=aNbWeights; i++)
+ weights->SetValue(i, aBSp->Weight(i));
+ aInfo.SetWeights(weights);
+ }
+ // Fill the multiplicities
+ if (aNbMultiplicities > 0) {
+ Handle(TColStd_HArray1OfInteger) mults = new TColStd_HArray1OfInteger(1, aNbMultiplicities);
+ for (i=1; i<=aNbMultiplicities; i++)
+ mults->SetValue(i, aBSp->Multiplicity(i));
+ aInfo.SetMultiplicities(mults);
+ }
+ }
+ }//if (aCT==GeomAbs_BSplineCurve) {
+ // Bezier
+ else if (aCT==GeomAbs_BezierCurve) {
+ Standard_Integer aNbPoles, aNbWeights, aDegree, i;
+ Handle(Geom_BezierCurve) aBC;
+ aBC=aGAC.Bezier();
+ aNbPoles = aBC->NbPoles();
+ aNbWeights = (aBC->IsRational() ? aNbPoles : 0);
+ aDegree = aBC->Degree();
+ aInfo.SetKindOfShape(GEOMAlgo_KS_BEZIER);
+ aInfo.SetKindOfName(GEOMAlgo_KN_CURVEBEZIER);
+ aInfo.SetKindOfPeriod(aBC->IsPeriodic() ? GEOMAlgo_KP_PERIODIC : GEOMAlgo_KP_NONPERIODIC);
+ aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
+ aInfo.SetKindOfClosed(aBC->IsClosed() ? GEOMAlgo_KC_CLOSED : GEOMAlgo_KC_NOTCLOSED);
+ aGAC.D0(aT1, aP1);
+ aGAC.D0(aT2, aP2);
+ aInfo.SetPnt1(aP1);
+ aInfo.SetPnt2(aP2);
+ //
+ aInfo.SetDegree(aDegree);
+ aInfo.SetNbPoles(aNbPoles);
+ aInfo.SetNbWeights(aNbWeights);
+ // Fill the poles
+ Handle(TColgp_HArray1OfPnt) poles = new TColgp_HArray1OfPnt(1, aNbPoles);
+ for (i=1; i<=aNbPoles; i++)
+ poles->SetValue(i, aBC->Pole(i));
+ aInfo.SetPoles(poles);
+ // Fill the weights
+ if (aNbWeights > 0) {
+ Handle(TColStd_HArray1OfReal) weights = new TColStd_HArray1OfReal(1, aNbWeights);
+ for (i=1; i<=aNbWeights; i++)
+ weights->SetValue(i, aBC->Weight(i));
+ aInfo.SetWeights(weights);
+ }
+ }// if (aCT==GeomAbs_BezierCurve) {
// Line
- if (aCT==GeomAbs_Line) {
+ else if (aCT==GeomAbs_Line) {
Standard_Boolean bInf1, bInf2;
Standard_Real aLength;
gp_Lin aLin;
aInfo.SetKindOfName(GEOMAlgo_KN_ARCCIRCLE);
//
gp_Vec aVecX(aP, aP1);
- gp_Dir aDirX(aVecX);
+ gp_Dir aDirX(aVecX);
gp_Ax2 aAx2new(aP, aAx2.Direction(), aDirX);
aInfo.SetPosition(aAx2new);
}
else {
aInfo.SetKindOfClosed(GEOMAlgo_KC_NOTCLOSED);
aInfo.SetKindOfName(GEOMAlgo_KN_ARCELLIPSE);
- //
- gp_Vec aVecX(aP, aP1);
- gp_Dir aDirX(aVecX);
- gp_Ax2 aAx2new(aP, aAx2.Direction(), aDirX);
- aInfo.SetPosition(aAx2new);
}
}// else if (aCT==GeomAbs_Ellipse) {
+ // Hyperbola
+ else if (aCT==GeomAbs_Hyperbola) {
+ gp_Hypr aHyp;
+ aHyp=aGAC.Hyperbola();
+ aP=aHyp.Location();
+ aAx2=aHyp.Position();
+ aR1=aHyp.MajorRadius();
+ aR2=aHyp.MinorRadius();
+ aInfo.SetKindOfShape(GEOMAlgo_KS_HYPERBOLA);
+ aInfo.SetKindOfName(GEOMAlgo_KN_HYPERBOLA);
+ aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
+ aInfo.SetLocation(aP);
+ aInfo.SetPosition(aAx2);
+ aInfo.SetRadius1(aR1);
+ aInfo.SetRadius2(aR2);
+ //
+ aGAC.D0(aT1, aP1);
+ aGAC.D0(aT2, aP2);
+ aInfo.SetPnt1(aP1);
+ aInfo.SetPnt2(aP2);
+ //
+ }// if (aCT==GeomAbs_Hyperbola) {
+ // Parabola
+ else if (aCT==GeomAbs_Parabola) {
+ gp_Parab aPara;
+ aPara=aGAC.Parabola();
+ aP=aPara.Location();
+ aAx2=aPara.Position();
+ aR1=aPara.Focal();
+ aInfo.SetKindOfShape(GEOMAlgo_KS_PARABOLA);
+ aInfo.SetKindOfName(GEOMAlgo_KN_PARABOLA);
+ aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
+ aInfo.SetLocation(aP);
+ aInfo.SetPosition(aAx2);
+ aInfo.SetRadius1(aR1);
+ //
+ aGAC.D0(aT1, aP1);
+ aGAC.D0(aT2, aP2);
+ aInfo.SetPnt1(aP1);
+ aInfo.SetPnt2(aP2);
+ //
+ }// if (aCT==GeomAbs_Parabola) {
//
FillSubShapes(aS);
}
//=======================================================================
-//function :FillVertex
-//purpose :
+//function :FillVertex
+//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::FillVertex(const TopoDS_Shape& aS)
+void GEOMAlgo_ShapeInfoFiller::FillVertex(const TopoDS_Shape& aS)
{
myErrorStatus=0;
//
}
//=======================================================================
//function : FillNbSubshapes
-//purpose :
+//purpose :
//=======================================================================
- void GEOMAlgo_ShapeInfoFiller::FillNbSubShapes(const TopoDS_Shape& aS,
- GEOMAlgo_ShapeInfo& aInfo)
+void GEOMAlgo_ShapeInfoFiller::FillNbSubShapes(const TopoDS_Shape& aS,
+ GEOMAlgo_ShapeInfo& aInfo)
{
myErrorStatus=0;
//
Standard_Integer i, aNb, aNbS;
TopTools_IndexedMapOfShape aM;
- TopAbs_ShapeEnum aST;
+ TopAbs_ShapeEnum aST;
TopAbs_ShapeEnum aTypes[]= {
//TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX
TopAbs_COMPOUND,
TopAbs_EDGE,
TopAbs_VERTEX
};
-
+
//
aST=aS.ShapeType();
aNb=sizeof(aTypes)/sizeof(aTypes[0]);
}
}
//=======================================================================
-//function :NbShells
-//purpose :
+//function :NbShells
+//purpose :
//=======================================================================
-Standard_Integer NbShells(const TopoDS_Solid& aSd)
+Standard_Integer GEOMAlgo_ShapeInfoFiller::NbShells
+ (const TopoDS_Solid& aSd)
{
Standard_Integer iCnt;
TopoDS_Iterator aIt;
iCnt=0;
//
aIt.Initialize(aSd);
- for (; aIt.More(); aIt.Next()){
- //const TopoDS_Shape& aSh=aIt.Value();
+ for (; aIt.More(); aIt.Next()) {
++iCnt;
}
return iCnt;
}
//=======================================================================
//function : NbWires
-//purpose :
+//purpose :
//=======================================================================
-Standard_Integer NbWires(const TopoDS_Face& aF)
+Standard_Integer GEOMAlgo_ShapeInfoFiller::NbWires
+ (const TopoDS_Face& aF)
{
Standard_Integer iCnt;
TopoDS_Iterator aIt;
iCnt=0;
//
aIt.Initialize(aF);
- for (; aIt.More(); aIt.Next()){
- //const TopoDS_Shape& aW=aIt.Value();
+ for (; aIt.More(); aIt.Next()) {
++iCnt;
}
return iCnt;
}
//=======================================================================
//function : IsAllowedType
-//purpose :
+//purpose :
//=======================================================================
-Standard_Boolean IsAllowedType(const GeomAbs_CurveType aCT)
+Standard_Boolean GEOMAlgo_ShapeInfoFiller::IsAllowedType
+ (const GeomAbs_CurveType aCT)
{
Standard_Boolean bRet;
Standard_Integer i, aNb;
GeomAbs_CurveType aTypes[]={
- GeomAbs_Line, GeomAbs_Circle, GeomAbs_Ellipse
+ GeomAbs_Line,
+ GeomAbs_Circle,
+ GeomAbs_Ellipse,
+ GeomAbs_BSplineCurve,
+ GeomAbs_BezierCurve,
+ GeomAbs_Hyperbola,
+ GeomAbs_Parabola
};
//
bRet=Standard_False;
for (i=0; i<aNb && !bRet; ++i) {
bRet=(aCT==aTypes[i]);
}
- //
return bRet;
}
//=======================================================================
//function : IsAllowedType
-//purpose :
+//purpose :
//=======================================================================
-Standard_Boolean IsAllowedType(const GeomAbs_SurfaceType aST)
+Standard_Boolean GEOMAlgo_ShapeInfoFiller::IsAllowedType
+ (const GeomAbs_SurfaceType aST)
{
Standard_Boolean bRet;
Standard_Integer i, aNb;
GeomAbs_SurfaceType aTypes[]={
- GeomAbs_Plane, GeomAbs_Cylinder,
+ GeomAbs_Plane, GeomAbs_Cylinder,
GeomAbs_Cone, GeomAbs_Sphere,
GeomAbs_Torus
};
}
//
// myErrorStatus
-//
+//
// 0 - Ok
// 1 - The object is just initialized
//
-// 10 - Null shape
+// 10 - Null shape
// 11 - circle/ellipse edge without vertices