Part: use of factory method of Vector2dPy
This commit is contained in:
@@ -107,7 +107,6 @@ PyObject* Curve2dPy::reverse(PyObject * args)
|
||||
Py_Return;
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
@@ -187,7 +186,6 @@ PyObject* Curve2dPy::toShape(PyObject *args)
|
||||
return Py::new_reference_to(shape2pyshape(edge));
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
@@ -204,7 +202,6 @@ PyObject* Curve2dPy::toShape(PyObject *args)
|
||||
return Py::new_reference_to(shape2pyshape(edge));
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
@@ -225,7 +222,6 @@ PyObject* Curve2dPy::toShape(PyObject *args)
|
||||
return Py::new_reference_to(shape2pyshape(edge));
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
@@ -265,7 +261,6 @@ PyObject* Curve2dPy::toShape(PyObject *args)
|
||||
return Py::new_reference_to(shape2pyshape(edge));
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
@@ -285,7 +280,6 @@ PyObject* Curve2dPy::toShape(PyObject *args)
|
||||
return Py::new_reference_to(shape2pyshape(edge));
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
@@ -321,14 +315,9 @@ PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
Py::List points;
|
||||
int nbPoints = discretizer.NbPoints ();
|
||||
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
Py::Tuple arg(2);
|
||||
for (int i=1; i<=nbPoints; i++) {
|
||||
gp_Pnt2d p = adapt.Value (discretizer.Parameter (i));
|
||||
arg.setItem(0, Py::Float(p.X()));
|
||||
arg.setItem(1, Py::Float(p.Y()));
|
||||
points.append(method.apply(arg));
|
||||
points.append(Base::Vector2dPy::create(p.X(), p.Y()));
|
||||
}
|
||||
|
||||
return Py::new_reference_to(points);
|
||||
@@ -351,14 +340,9 @@ PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
Py::List points;
|
||||
int nbPoints = discretizer.NbPoints ();
|
||||
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
Py::Tuple arg(2);
|
||||
for (int i=1; i<=nbPoints; i++) {
|
||||
gp_Pnt2d p = adapt.Value (discretizer.Parameter (i));
|
||||
arg.setItem(0, Py::Float(p.X()));
|
||||
arg.setItem(1, Py::Float(p.Y()));
|
||||
points.append(method.apply(arg));
|
||||
points.append(Base::Vector2dPy::create(p.X(), p.Y()));
|
||||
}
|
||||
|
||||
return Py::new_reference_to(points);
|
||||
@@ -379,14 +363,9 @@ PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
Py::List points;
|
||||
int nbPoints = discretizer.NbPoints ();
|
||||
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
Py::Tuple arg(2);
|
||||
for (int i=1; i<=nbPoints; i++) {
|
||||
gp_Pnt p = discretizer.Value (i);
|
||||
arg.setItem(0, Py::Float(p.X()));
|
||||
arg.setItem(1, Py::Float(p.Y()));
|
||||
points.append(method.apply(arg));
|
||||
points.append(Base::Vector2dPy::create(p.X(), p.Y()));
|
||||
}
|
||||
|
||||
return Py::new_reference_to(points);
|
||||
@@ -409,14 +388,9 @@ PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
Py::List points;
|
||||
int nbPoints = discretizer.NbPoints ();
|
||||
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
Py::Tuple arg(2);
|
||||
for (int i=1; i<=nbPoints; i++) {
|
||||
gp_Pnt p = discretizer.Value (i);
|
||||
arg.setItem(0, Py::Float(p.X()));
|
||||
arg.setItem(1, Py::Float(p.Y()));
|
||||
points.append(method.apply(arg));
|
||||
points.append(Base::Vector2dPy::create(p.X(), p.Y()));
|
||||
}
|
||||
|
||||
return Py::new_reference_to(points);
|
||||
@@ -437,14 +411,9 @@ PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
Py::List points;
|
||||
int nbPoints = discretizer.NbPoints ();
|
||||
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
Py::Tuple arg(2);
|
||||
for (int i=1; i<=nbPoints; i++) {
|
||||
gp_Pnt2d p = adapt.Value (discretizer.Parameter (i));
|
||||
arg.setItem(0, Py::Float(p.X()));
|
||||
arg.setItem(1, Py::Float(p.Y()));
|
||||
points.append(method.apply(arg));
|
||||
points.append(Base::Vector2dPy::create(p.X(), p.Y()));
|
||||
}
|
||||
|
||||
return Py::new_reference_to(points);
|
||||
@@ -464,15 +433,9 @@ PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
if (discretizer.NbPoints () > 0) {
|
||||
Py::List points;
|
||||
int nbPoints = discretizer.NbPoints ();
|
||||
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
Py::Tuple arg(2);
|
||||
for (int i=1; i<=nbPoints; i++) {
|
||||
gp_Pnt p = discretizer.Value (i);
|
||||
arg.setItem(0, Py::Float(p.X()));
|
||||
arg.setItem(1, Py::Float(p.Y()));
|
||||
points.append(method.apply(arg));
|
||||
points.append(Base::Vector2dPy::create(p.X(), p.Y()));
|
||||
}
|
||||
|
||||
return Py::new_reference_to(points);
|
||||
@@ -509,7 +472,6 @@ PyObject* Curve2dPy::length(PyObject *args)
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
@@ -535,7 +497,6 @@ PyObject* Curve2dPy::parameterAtDistance(PyObject *args)
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
@@ -554,17 +515,10 @@ PyObject* Curve2dPy::value(PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "d", &u))
|
||||
return 0;
|
||||
gp_Pnt2d p = c->Value(u);
|
||||
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
Py::Tuple arg(2);
|
||||
arg.setItem(0, Py::Float(p.X()));
|
||||
arg.setItem(1, Py::Float(p.Y()));
|
||||
return Py::new_reference_to(method.apply(arg));
|
||||
return Py::new_reference_to(Base::Vector2dPy::create(p.X(), p.Y()));
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
@@ -588,16 +542,10 @@ PyObject* Curve2dPy::tangent(PyObject *args)
|
||||
prop.Tangent(dir);
|
||||
}
|
||||
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
Py::Tuple arg(2);
|
||||
arg.setItem(0, Py::Float(dir.X()));
|
||||
arg.setItem(1, Py::Float(dir.Y()));
|
||||
return Py::new_reference_to(method.apply(arg));
|
||||
return Py::new_reference_to(Base::Vector2dPy::create(dir.X(), dir.Y()));
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
@@ -619,16 +567,10 @@ PyObject* Curve2dPy::normal(PyObject *args)
|
||||
Geom2dLProp_CLProps2d prop(c,u,2,Precision::Confusion());
|
||||
prop.Normal(dir);
|
||||
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
Py::Tuple arg(2);
|
||||
arg.setItem(0, Py::Float(dir.X()));
|
||||
arg.setItem(1, Py::Float(dir.Y()));
|
||||
return Py::new_reference_to(method.apply(arg));
|
||||
return Py::new_reference_to(Base::Vector2dPy::create(dir.X(), dir.Y()));
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
@@ -652,7 +594,6 @@ PyObject* Curve2dPy::curvature(PyObject *args)
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
@@ -674,16 +615,10 @@ PyObject* Curve2dPy::centerOfCurvature(PyObject *args)
|
||||
gp_Pnt2d pnt ;
|
||||
prop.CentreOfCurvature(pnt);
|
||||
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
Py::Tuple arg(2);
|
||||
arg.setItem(0, Py::Float(pnt.X()));
|
||||
arg.setItem(1, Py::Float(pnt.Y()));
|
||||
return Py::new_reference_to(method.apply(arg));
|
||||
return Py::new_reference_to(Base::Vector2dPy::create(pnt.X(), pnt.Y()));
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
@@ -737,7 +672,6 @@ PyObject* Curve2dPy::toBSpline(PyObject * args)
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
@@ -791,7 +725,6 @@ PyObject* Curve2dPy::approximateBSpline(PyObject *args)
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
@@ -874,11 +807,9 @@ PyObject* Curve2dPy::intersectCC(PyObject *args)
|
||||
double prec = Precision::Confusion();
|
||||
if (!PyArg_ParseTuple(args, "O!|d", &(Part::Curve2dPy::Type), &p, &prec))
|
||||
return 0;
|
||||
|
||||
Handle(Geom2d_Curve) curve2 = Handle(Geom2d_Curve)::DownCast(static_cast<Geometry2dPy*>(p)->getGeometry2dPtr()->handle());
|
||||
Py::List points;
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
Py::Tuple arg(2);
|
||||
Geom2dAPI_InterCurveCurve intersector(curve1, curve2, prec);
|
||||
if ((intersector.NbPoints() == 0) && (intersector.NbSegments() == 0)) {
|
||||
// No intersection
|
||||
@@ -888,9 +819,7 @@ PyObject* Curve2dPy::intersectCC(PyObject *args)
|
||||
// Cross intersections
|
||||
for (int i = 1; i <= intersector.NbPoints(); i++) {
|
||||
gp_Pnt2d p1 = intersector.Point(i);
|
||||
arg.setItem(0, Py::Float(p1.X()));
|
||||
arg.setItem(1, Py::Float(p1.Y()));
|
||||
points.append(method.apply(arg));
|
||||
points.append(Base::Vector2dPy::create(p1.X(), p1.Y()));
|
||||
}
|
||||
}
|
||||
if (intersector.NbSegments() > 0) {
|
||||
@@ -905,17 +834,13 @@ PyObject* Curve2dPy::intersectCC(PyObject *args)
|
||||
continue;
|
||||
gp_Pnt2d p1, p2;
|
||||
intersector2.Points(i, p1, p2);
|
||||
|
||||
arg.setItem(0, Py::Float(p1.X()));
|
||||
arg.setItem(1, Py::Float(p1.Y()));
|
||||
points.append(method.apply(arg));
|
||||
points.append(Base::Vector2dPy::create(p1.X(), p1.Y()));
|
||||
}
|
||||
}
|
||||
return Py::new_reference_to(points);
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PyExc_RuntimeError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user