Skip to content

Commit

Permalink
Part: converter from Adaptor3d_Curve to GeomCurve
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Sep 28, 2020
1 parent af8ff5c commit 218d617
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
72 changes: 72 additions & 0 deletions src/Mod/Part/App/Geometry.cpp
Expand Up @@ -5039,4 +5039,76 @@ std::unique_ptr<GeomCurve> makeFromTrimmedCurve(const Handle(Geom_Curve)& c, dou
}
}

std::unique_ptr<GeomCurve> makeFromCurveAdaptor(const Adaptor3d_Curve& adapt)
{
std::unique_ptr<GeomCurve> geoCurve;
switch (adapt.GetType())
{
case GeomAbs_Line:
{
geoCurve.reset(new GeomLine());
Handle(Geom_Line) this_curv = Handle(Geom_Line)::DownCast
(geoCurve->handle());
this_curv->SetLin(adapt.Line());
break;
}
case GeomAbs_Circle:
{
geoCurve.reset(new GeomCircle());
Handle(Geom_Circle) this_curv = Handle(Geom_Circle)::DownCast
(geoCurve->handle());
this_curv->SetCirc(adapt.Circle());
break;
}
case GeomAbs_Ellipse:
{
geoCurve.reset(new GeomEllipse());
Handle(Geom_Ellipse) this_curv = Handle(Geom_Ellipse)::DownCast
(geoCurve->handle());
this_curv->SetElips(adapt.Ellipse());
break;
}
case GeomAbs_Hyperbola:
{
geoCurve.reset(new GeomHyperbola());
Handle(Geom_Hyperbola) this_curv = Handle(Geom_Hyperbola)::DownCast
(geoCurve->handle());
this_curv->SetHypr(adapt.Hyperbola());
break;
}
case GeomAbs_Parabola:
{
geoCurve.reset(new GeomParabola());
Handle(Geom_Parabola) this_curv = Handle(Geom_Parabola)::DownCast
(geoCurve->handle());
this_curv->SetParab(adapt.Parabola());
break;
}
case GeomAbs_BezierCurve:
{
geoCurve.reset(new GeomBezierCurve(adapt.Bezier()));
break;
}
case GeomAbs_BSplineCurve:
{
geoCurve.reset(new GeomBSplineCurve(adapt.BSpline()));
break;
}
#if OCC_VERSION_HEX >= 0x070000
case GeomAbs_OffsetCurve:
{
geoCurve.reset(new GeomOffsetCurve(adapt.OffsetCurve()));
break;
}
#endif
case GeomAbs_OtherCurve:
default:
break;
}

if (!geoCurve)
throw Base::TypeError("Unhandled curve type");
return geoCurve;
}

}
4 changes: 4 additions & 0 deletions src/Mod/Part/App/Geometry.h
Expand Up @@ -24,6 +24,7 @@
#ifndef PART_GEOMETRY_H
#define PART_GEOMETRY_H

#include <Adaptor3d_Curve.hxx>
#include <Geom_CartesianPoint.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx>
Expand Down Expand Up @@ -1087,6 +1088,9 @@ std::unique_ptr<GeomCurve> makeFromCurve(const Handle(Geom_Curve)&);

PartExport
std::unique_ptr<GeomCurve> makeFromTrimmedCurve(const Handle(Geom_Curve)&, double f, double l);

PartExport
std::unique_ptr<GeomCurve> makeFromCurveAdaptor(const Adaptor3d_Curve&);
}

#endif // PART_GEOMETRY_H

0 comments on commit 218d617

Please sign in to comment.