add methods to convert a curve to a B-Spline or NURBS

This commit is contained in:
wmayer
2017-02-13 10:38:09 +01:00
parent b96b275579
commit becdede5c0
4 changed files with 67 additions and 8 deletions

View File

@@ -95,7 +95,7 @@
# include <GC_MakeSegment.hxx>
# include <Precision.hxx>
# include <GeomAPI_ProjectPointOnCurve.hxx>
# include <ShapeConstruct_Curve.hxx>
#endif
#include <Base/VectorPy.h>
@@ -318,6 +318,21 @@ TopoDS_Shape GeomCurve::toShape() const
return mkBuilder.Shape();
}
GeomBSplineCurve* GeomCurve::toBSpline(double first, double last) const
{
ShapeConstruct_Curve scc;
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(handle());
Handle_Geom_BSplineCurve spline = scc.ConvertToBSpline(c, first, last, Precision::Confusion());
if (spline.IsNull())
throw Base::RuntimeError("Conversion to B-Spline failed");
return new GeomBSplineCurve(spline);
}
GeomBSplineCurve* GeomCurve::toNurbs(double first, double last) const
{
return toBSpline(first, last);
}
bool GeomCurve::tangent(double u, gp_Dir& dir) const
{
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(handle());