Part: modernize C++11
* use nullptr
This commit is contained in:
@@ -89,7 +89,7 @@ PyObject *Curve2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Py
|
||||
// never create such objects with the constructor
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"You cannot create an instance of the abstract class 'Curve2d'.");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// constructor method
|
||||
@@ -108,11 +108,11 @@ PyObject* Curve2dPy::reverse(PyObject * args)
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
namespace Part {
|
||||
@@ -187,7 +187,7 @@ PyObject* Curve2dPy::toShape(PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ PyObject* Curve2dPy::toShape(PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ PyObject* Curve2dPy::toShape(PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ PyObject* Curve2dPy::toShape(PyObject *args)
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ PyObject* Curve2dPy::toShape(PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,12 +281,12 @@ PyObject* Curve2dPy::toShape(PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "empty parameter list, parameter range or surface expected");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
@@ -296,7 +296,7 @@ PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
Handle(Geom2d_Curve) c = Handle(Geom2d_Curve)::DownCast(g);
|
||||
if (c.IsNull()) {
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Geom2dAdaptor_Curve adapt(c);
|
||||
@@ -304,7 +304,7 @@ PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
double last = adapt.LastParameter();
|
||||
|
||||
// use Number kwds
|
||||
static char* kwds_numPoints[] = {"Number","First","Last",NULL};
|
||||
static char* kwds_numPoints[] = {"Number","First","Last",nullptr};
|
||||
PyErr_Clear();
|
||||
int numPoints = -1;
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "i|dd", kwds_numPoints, &numPoints, &first, &last)) {
|
||||
@@ -324,12 +324,12 @@ PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PartExceptionOCCError, "Discretization of curve failed");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// use Distance kwds
|
||||
static char* kwds_Distance[] = {"Distance","First","Last",NULL};
|
||||
static char* kwds_Distance[] = {"Distance","First","Last",nullptr};
|
||||
PyErr_Clear();
|
||||
double distance = -1;
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "d|dd", kwds_Distance, &distance, &first, &last)) {
|
||||
@@ -349,12 +349,12 @@ PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PartExceptionOCCError, "Discretization of curve failed");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// use Deflection kwds
|
||||
static char* kwds_Deflection[] = {"Deflection","First","Last",NULL};
|
||||
static char* kwds_Deflection[] = {"Deflection","First","Last",nullptr};
|
||||
PyErr_Clear();
|
||||
double deflection;
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "d|dd", kwds_Deflection, &deflection, &first, &last)) {
|
||||
@@ -372,12 +372,12 @@ PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PartExceptionOCCError, "Discretization of curve failed");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// use TangentialDeflection kwds
|
||||
static char* kwds_TangentialDeflection[] = {"Angular","Curvature","First","Last","Minimum",NULL};
|
||||
static char* kwds_TangentialDeflection[] = {"Angular","Curvature","First","Last","Minimum",nullptr};
|
||||
PyErr_Clear();
|
||||
double angular;
|
||||
double curvature;
|
||||
@@ -397,12 +397,12 @@ PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PartExceptionOCCError, "Discretization of curve failed");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// use QuasiNumber kwds
|
||||
static char* kwds_QuasiNumPoints[] = {"QuasiNumber","First","Last",NULL};
|
||||
static char* kwds_QuasiNumPoints[] = {"QuasiNumber","First","Last",nullptr};
|
||||
PyErr_Clear();
|
||||
int quasiNumPoints;
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "i|dd", kwds_QuasiNumPoints, &quasiNumPoints, &first, &last)) {
|
||||
@@ -420,12 +420,12 @@ PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PartExceptionOCCError, "Discretization of curve failed");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// use QuasiDeflection kwds
|
||||
static char* kwds_QuasiDeflection[] = {"QuasiDeflection","First","Last",NULL};
|
||||
static char* kwds_QuasiDeflection[] = {"QuasiDeflection","First","Last",nullptr};
|
||||
PyErr_Clear();
|
||||
double quasiDeflection;
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "d|dd", kwds_QuasiDeflection, &quasiDeflection, &first, &last)) {
|
||||
@@ -442,17 +442,17 @@ PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PartExceptionOCCError, "Discretization of curve failed");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError,"Wrong arguments");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* Curve2dPy::length(PyObject *args)
|
||||
@@ -465,7 +465,7 @@ PyObject* Curve2dPy::length(PyObject *args)
|
||||
double v=c->LastParameter();
|
||||
double t=Precision::Confusion();
|
||||
if (!PyArg_ParseTuple(args, "|ddd", &u,&v,&t))
|
||||
return 0;
|
||||
return nullptr;
|
||||
Geom2dAdaptor_Curve adapt(c);
|
||||
double len = GCPnts_AbscissaPoint::Length(adapt,u,v,t);
|
||||
return PyFloat_FromDouble(len);
|
||||
@@ -473,11 +473,11 @@ PyObject* Curve2dPy::length(PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* Curve2dPy::parameterAtDistance(PyObject *args)
|
||||
@@ -489,7 +489,7 @@ PyObject* Curve2dPy::parameterAtDistance(PyObject *args)
|
||||
double abscissa;
|
||||
double u = 0;
|
||||
if (!PyArg_ParseTuple(args, "d|d", &abscissa,&u))
|
||||
return 0;
|
||||
return nullptr;
|
||||
Geom2dAdaptor_Curve adapt(c);
|
||||
GCPnts_AbscissaPoint abscissaPoint(adapt,abscissa,u);
|
||||
double parm = abscissaPoint.Parameter();
|
||||
@@ -498,11 +498,11 @@ PyObject* Curve2dPy::parameterAtDistance(PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* Curve2dPy::value(PyObject *args)
|
||||
@@ -513,18 +513,18 @@ PyObject* Curve2dPy::value(PyObject *args)
|
||||
if (!c.IsNull()) {
|
||||
double u;
|
||||
if (!PyArg_ParseTuple(args, "d", &u))
|
||||
return 0;
|
||||
return nullptr;
|
||||
gp_Pnt2d p = c->Value(u);
|
||||
return Py::new_reference_to(Base::Vector2dPy::create(p.X(), p.Y()));
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* Curve2dPy::tangent(PyObject *args)
|
||||
@@ -535,7 +535,7 @@ PyObject* Curve2dPy::tangent(PyObject *args)
|
||||
if (!c.IsNull()) {
|
||||
double u;
|
||||
if (!PyArg_ParseTuple(args, "d", &u))
|
||||
return 0;
|
||||
return nullptr;
|
||||
gp_Dir2d dir;
|
||||
Geom2dLProp_CLProps2d prop(c,u,2,Precision::Confusion());
|
||||
if (prop.IsTangentDefined()) {
|
||||
@@ -547,11 +547,11 @@ PyObject* Curve2dPy::tangent(PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* Curve2dPy::normal(PyObject *args)
|
||||
@@ -562,7 +562,7 @@ PyObject* Curve2dPy::normal(PyObject *args)
|
||||
if (!c.IsNull()) {
|
||||
double u;
|
||||
if (!PyArg_ParseTuple(args, "d", &u))
|
||||
return 0;
|
||||
return nullptr;
|
||||
gp_Dir2d dir;
|
||||
Geom2dLProp_CLProps2d prop(c,u,2,Precision::Confusion());
|
||||
prop.Normal(dir);
|
||||
@@ -572,11 +572,11 @@ PyObject* Curve2dPy::normal(PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* Curve2dPy::curvature(PyObject *args)
|
||||
@@ -587,7 +587,7 @@ PyObject* Curve2dPy::curvature(PyObject *args)
|
||||
if (!c.IsNull()) {
|
||||
double u;
|
||||
if (!PyArg_ParseTuple(args, "d", &u))
|
||||
return 0;
|
||||
return nullptr;
|
||||
Geom2dLProp_CLProps2d prop(c,u,2,Precision::Confusion());
|
||||
double C = prop.Curvature();
|
||||
return Py::new_reference_to(Py::Float(C));
|
||||
@@ -595,11 +595,11 @@ PyObject* Curve2dPy::curvature(PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* Curve2dPy::centerOfCurvature(PyObject *args)
|
||||
@@ -610,7 +610,7 @@ PyObject* Curve2dPy::centerOfCurvature(PyObject *args)
|
||||
if (!c.IsNull()) {
|
||||
double u;
|
||||
if (!PyArg_ParseTuple(args, "d", &u))
|
||||
return 0;
|
||||
return nullptr;
|
||||
Geom2dLProp_CLProps2d prop(c,u,2,Precision::Confusion());
|
||||
gp_Pnt2d pnt ;
|
||||
prop.CentreOfCurvature(pnt);
|
||||
@@ -620,11 +620,11 @@ PyObject* Curve2dPy::centerOfCurvature(PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* Curve2dPy::parameter(PyObject *args)
|
||||
@@ -635,7 +635,7 @@ PyObject* Curve2dPy::parameter(PyObject *args)
|
||||
if (!c.IsNull()) {
|
||||
PyObject *p;
|
||||
if (!PyArg_ParseTuple(args, "O!", Base::Vector2dPy::type_object(), &p))
|
||||
return 0;
|
||||
return nullptr;
|
||||
Base::Vector2d v = Py::toVector2d(p);
|
||||
gp_Pnt2d pnt(v.x,v.y);
|
||||
Geom2dAPI_ProjectPointOnCurve ppc(pnt, c);
|
||||
@@ -646,11 +646,11 @@ PyObject* Curve2dPy::parameter(PyObject *args)
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* Curve2dPy::toBSpline(PyObject * args)
|
||||
@@ -663,7 +663,7 @@ PyObject* Curve2dPy::toBSpline(PyObject * args)
|
||||
u=c->FirstParameter();
|
||||
v=c->LastParameter();
|
||||
if (!PyArg_ParseTuple(args, "|dd", &u,&v))
|
||||
return 0;
|
||||
return nullptr;
|
||||
ShapeConstruct_Curve scc;
|
||||
Handle(Geom2d_BSplineCurve) spline = scc.ConvertToBSpline(c, u, v, Precision::Confusion());
|
||||
if (spline.IsNull())
|
||||
@@ -673,11 +673,11 @@ PyObject* Curve2dPy::toBSpline(PyObject * args)
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* Curve2dPy::approximateBSpline(PyObject *args)
|
||||
@@ -686,7 +686,7 @@ PyObject* Curve2dPy::approximateBSpline(PyObject *args)
|
||||
int maxSegment, maxDegree;
|
||||
char* order = "C2";
|
||||
if (!PyArg_ParseTuple(args, "dii|s", &tolerance, &maxSegment, &maxDegree, &order))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
GeomAbs_Shape absShape;
|
||||
std::string str = order;
|
||||
@@ -717,16 +717,16 @@ PyObject* Curve2dPy::approximateBSpline(PyObject *args)
|
||||
std::stringstream str;
|
||||
str << "Maximum error (" << approx.MaxError() << ") is outside tolerance";
|
||||
PyErr_SetString(PyExc_RuntimeError, str.str().c_str());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Approximation of curve failed");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -790,7 +790,7 @@ Py::Float Curve2dPy::getLastParameter(void) const
|
||||
|
||||
PyObject *Curve2dPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int Curve2dPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
@@ -806,7 +806,7 @@ PyObject* Curve2dPy::intersectCC(PyObject *args)
|
||||
PyObject *p;
|
||||
double prec = Precision::Confusion();
|
||||
if (!PyArg_ParseTuple(args, "O!|d", &(Part::Curve2dPy::Type), &p, &prec))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
Handle(Geom2d_Curve) curve2 = Handle(Geom2d_Curve)::DownCast(static_cast<Geometry2dPy*>(p)->getGeometry2dPtr()->handle());
|
||||
Py::List points;
|
||||
@@ -842,9 +842,9 @@ PyObject* Curve2dPy::intersectCC(PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "Geometry is not a curve");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user