Implement GeometryCurvePy::length

This commit is contained in:
wmayer 2013-04-08 12:54:46 +02:00
parent a7e3f0539d
commit f43f70f395
2 changed files with 32 additions and 0 deletions

View File

@ -26,6 +26,12 @@
<UserDocu>Discretizes the curve using a given deflection or number of points and returns a list of points</UserDocu>
</Documentation>
</Methode>
<Methode Name="length">
<Documentation>
<UserDocu>Computes the length of a curve
length([uMin,uMax,Tol]) -> Float</UserDocu>
</Documentation>
</Methode>
<Methode Name="value">
<Documentation>
<UserDocu>Computes the point of parameter u on this curve</UserDocu>

View File

@ -28,6 +28,7 @@
# include <gp_Vec.hxx>
# include <gp_Pln.hxx>
# include <GCPnts_UniformAbscissa.hxx>
# include <GCPnts_AbscissaPoint.hxx>
# include <Geom2dAPI_InterCurveCurve.hxx>
# include <GeomAPI.hxx>
# include <Geom_Geometry.hxx>
@ -156,6 +157,31 @@ PyObject* GeometryCurvePy::discretize(PyObject *args)
return 0;
}
PyObject* GeometryCurvePy::length(PyObject *args)
{
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
try {
if (!c.IsNull()) {
double u=c->FirstParameter();
double v=c->LastParameter();
double t=Precision::Confusion();
if (!PyArg_ParseTuple(args, "|ddd", &u,&v,&t))
return 0;
double len = GCPnts_AbscissaPoint::Length(GeomAdaptor_Curve(c),u,v,t);
return PyFloat_FromDouble(len);
}
}
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;
}
PyObject* GeometryCurvePy::value(PyObject *args)
{
Handle_Geom_Geometry g = getGeometryPtr()->handle();