+ Support Quasi methods in discretize()
This commit is contained in:
parent
7369fbd154
commit
7eaa4fff74
|
@ -26,8 +26,10 @@
|
|||
<UserDocu>Discretizes the curve and returns a list of points.
|
||||
The function accepts keywords as argument:
|
||||
discretize(Number=n) => gives a list of 'n' equidistant points
|
||||
discretize(QuasiNumber=n) => gives a list of 'n' quasi equidistant points (is faster than the method above)
|
||||
discretize(Distance=d) => gives a list of equidistant points with distance 'd'
|
||||
discretize(Deflection=d) => gives a list of points with a maximum deflection 'd' to the curve
|
||||
discretize(QuasiDeflection=d) => gives a list of points with a maximum deflection 'd' to the curve (faster)
|
||||
discretize(Angular=a,Curvature=c,[Minimum=m]) => gives a list of points with an angular deflection of 'a'
|
||||
and a curvature deflection of 'c'. Optionally a minimum number of points
|
||||
can be set which by default is set to 2.
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -74,8 +74,10 @@
|
|||
<UserDocu>Discretizes the edge and returns a list of points.
|
||||
The function accepts keywords as argument:
|
||||
discretize(Number=n) => gives a list of 'n' equidistant points
|
||||
discretize(QuasiNumber=n) => gives a list of 'n' quasi equidistant points (is faster than the method above)
|
||||
discretize(Distance=d) => gives a list of equidistant points with distance 'd'
|
||||
discretize(Deflection=d) => gives a list of points with a maximum deflection 'd' to the edge
|
||||
discretize(QuasiDeflection=d) => gives a list of points with a maximum deflection 'd' to the edge (faster)
|
||||
discretize(Angular=a,Curvature=c,[Minimum=m]) => gives a list of points with an angular deflection of 'a'
|
||||
and a curvature deflection of 'c'. Optionally a minimum number of points
|
||||
can be set which by default is set to 2.
|
||||
|
|
|
@ -60,6 +60,8 @@
|
|||
#include <GCPnts_UniformAbscissa.hxx>
|
||||
#include <GCPnts_UniformDeflection.hxx>
|
||||
#include <GCPnts_TangentialDeflection.hxx>
|
||||
#include <GCPnts_QuasiUniformAbscissa.hxx>
|
||||
#include <GCPnts_QuasiUniformDeflection.hxx>
|
||||
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Base/VectorPy.h>
|
||||
|
@ -501,6 +503,50 @@ PyObject* TopoShapeEdgePy::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 edge 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 edge failed");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_Exception, e.what());
|
||||
|
|
|
@ -56,8 +56,10 @@ Make a loft defined by a list of profiles along a wire. Transition can be
|
|||
<UserDocu>Discretizes the wire and returns a list of points.
|
||||
The function accepts keywords as argument:
|
||||
discretize(Number=n) => gives a list of 'n' equidistant points
|
||||
discretize(QuasiNumber=n) => gives a list of 'n' quasi equidistant points (is faster than the method above)
|
||||
discretize(Distance=d) => gives a list of equidistant points with distance 'd'
|
||||
discretize(Deflection=d) => gives a list of points with a maximum deflection 'd' to the wire
|
||||
discretize(QuasiDeflection=d) => gives a list of points with a maximum deflection 'd' to the wire (faster)
|
||||
discretize(Angular=a,Curvature=c,[Minimum=m]) => gives a list of points with an angular deflection of 'a'
|
||||
and a curvature deflection of 'c'. Optionally a minimum number of points
|
||||
can be set which by default is set to 2.
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#include <GCPnts_UniformAbscissa.hxx>
|
||||
#include <GCPnts_UniformDeflection.hxx>
|
||||
#include <GCPnts_TangentialDeflection.hxx>
|
||||
#include <GCPnts_QuasiUniformAbscissa.hxx>
|
||||
#include <GCPnts_QuasiUniformDeflection.hxx>
|
||||
|
||||
#include <Base/VectorPy.h>
|
||||
#include <Base/GeometryPyCXX.h>
|
||||
|
@ -442,6 +444,50 @@ PyObject* TopoShapeWirePy::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 wire 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 wire failed");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_Exception, e.what());
|
||||
|
|
Loading…
Reference in New Issue
Block a user