+ Method to convert any curve into B-Spline

This commit is contained in:
wmayer 2013-10-24 17:30:38 +02:00
parent f6c776e577
commit d22772d5fd
2 changed files with 36 additions and 0 deletions

View File

@ -58,6 +58,14 @@ length([uMin,uMax,Tol]) -> Float</UserDocu>
of the nearest orthogonal projection of the point.</UserDocu>
</Documentation>
</Methode>
<Methode Name="toBSpline">
<Documentation>
<UserDocu>
Converts a curve of any type (only part from First to Last)
toBSpline([Float=First, Float=Last]) -> B-Spline curve
</UserDocu>
</Documentation>
</Methode>
<Attribute Name="FirstParameter" ReadOnly="true">
<Documentation>
<UserDocu>

View File

@ -43,6 +43,7 @@
# include <Precision.hxx>
# include <GeomAPI_ProjectPointOnCurve.hxx>
# include <Standard_Failure.hxx>
# include <ShapeConstruct_Curve.hxx>
#endif
#include <Base/GeometryPyCXX.h>
@ -54,6 +55,7 @@
#include "RectangularTrimmedSurfacePy.h"
#include "BSplineSurfacePy.h"
#include "PlanePy.h"
#include "BSplineCurvePy.h"
#include "TopoShape.h"
#include "TopoShapePy.h"
@ -339,6 +341,32 @@ PyObject* GeometryCurvePy::intersect2d(PyObject *args)
}
}
PyObject* GeometryCurvePy::toBSpline(PyObject * args)
{
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
try {
if (!c.IsNull()) {
double u,v;
u=c->FirstParameter();
v=c->LastParameter();
if (!PyArg_ParseTuple(args, "|dd", &u,&v))
return 0;
ShapeConstruct_Curve scc;
Handle_Geom_BSplineCurve spline = scc.ConvertToBSpline(c, u, v, Precision::Confusion());
return new BSplineCurvePy(new GeomBSplineCurve(spline));
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return 0;
}
PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
return 0;
}
Py::Float GeometryCurvePy::getFirstParameter(void) const
{
return Py::Float(Handle_Geom_Curve::DownCast