+ Support Quasi methods in discretize()
This commit is contained in:
@@ -31,6 +31,8 @@
|
||||
# include <GCPnts_UniformAbscissa.hxx>
|
||||
# include <GCPnts_UniformDeflection.hxx>
|
||||
# include <GCPnts_TangentialDeflection.hxx>
|
||||
# include <GCPnts_QuasiUniformAbscissa.hxx>
|
||||
# include <GCPnts_QuasiUniformDeflection.hxx>
|
||||
# include <GCPnts_AbscissaPoint.hxx>
|
||||
# include <Geom2dAPI_InterCurveCurve.hxx>
|
||||
# include <GeomAPI.hxx>
|
||||
@@ -233,6 +235,50 @@ PyObject* GeometryCurvePy::discretize(PyObject *args, PyObject *kwds)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// use QuasiNumber kwds
|
||||
static char* kwds_QuasiNumPoints[] = {"QuasiNumber","First","Last",NULL};
|
||||
PyErr_Clear();
|
||||
int quasiNumPoints;
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "i|dd", kwds_QuasiNumPoints, &quasiNumPoints, &first, &last)) {
|
||||
GCPnts_QuasiUniformAbscissa discretizer(adapt, quasiNumPoints, first, last);
|
||||
if (discretizer.NbPoints () > 0) {
|
||||
Py::List points;
|
||||
int nbPoints = discretizer.NbPoints ();
|
||||
for (int i=1; i<=nbPoints; i++) {
|
||||
gp_Pnt p = adapt.Value (discretizer.Parameter (i));
|
||||
points.append(Py::Vector(Base::Vector3d(p.X(),p.Y(),p.Z())));
|
||||
}
|
||||
|
||||
return Py::new_reference_to(points);
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_Exception, "Discretization of curve failed");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// use QuasiDeflection kwds
|
||||
static char* kwds_QuasiDeflection[] = {"QuasiDeflection","First","Last",NULL};
|
||||
PyErr_Clear();
|
||||
double quasiDeflection;
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "d|dd", kwds_QuasiDeflection, &quasiDeflection, &first, &last)) {
|
||||
GCPnts_QuasiUniformDeflection discretizer(adapt, quasiDeflection, first, last);
|
||||
if (discretizer.NbPoints () > 0) {
|
||||
Py::List points;
|
||||
int nbPoints = discretizer.NbPoints ();
|
||||
for (int i=1; i<=nbPoints; i++) {
|
||||
gp_Pnt p = discretizer.Value (i);
|
||||
points.append(Py::Vector(Base::Vector3d(p.X(),p.Y(),p.Z())));
|
||||
}
|
||||
|
||||
return Py::new_reference_to(points);
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_Exception, "Discretization of curve failed");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_Exception, e.what());
|
||||
|
||||
Reference in New Issue
Block a user