Implement GeometryCurvePy::length

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

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();