| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #include <Mod/Part/PartGlobal.h> |
| |
|
| | #include <memory> |
| | #include <Standard_Failure.hxx> |
| |
|
| |
|
| | #include <Base/VectorPy.h> |
| | #include <Base/PyWrapParseTupleAndKeywords.h> |
| |
|
| | #include "GeomPlate/PointConstraintPy.h" |
| | #include "GeomPlate/PointConstraintPy.cpp" |
| |
|
| |
|
| | using namespace Part; |
| |
|
| | PyObject* PointConstraintPy::PyMake(struct _typeobject*, PyObject*, PyObject*) |
| | { |
| | |
| | return new PointConstraintPy(nullptr); |
| | } |
| |
|
| | |
| | int PointConstraintPy::PyInit(PyObject* args, PyObject* kwds) |
| | { |
| | PyObject* pt; |
| | int order = 0; |
| | double tolDist = 0.0001; |
| |
|
| | static const std::array<const char*, 4> keywords {"Point", "Order", "TolDist", nullptr}; |
| | if (!Base::Wrapped_ParseTupleAndKeywords( |
| | args, |
| | kwds, |
| | "O!|id", |
| | keywords, |
| | &(Base::VectorPy::Type), |
| | &pt, |
| | &order, |
| | &tolDist |
| | )) { |
| | return -1; |
| | } |
| |
|
| | try { |
| | std::unique_ptr<GeomPlate_PointConstraint> ptr; |
| | Base::Vector3d v = static_cast<Base::VectorPy*>(pt)->value(); |
| |
|
| | ptr = std::make_unique<GeomPlate_PointConstraint>(gp_Pnt(v.x, v.y, v.z), order, tolDist); |
| | setTwinPointer(ptr.release()); |
| |
|
| | return 0; |
| | } |
| | catch (const Standard_Failure& e) { |
| | PyErr_SetString(PyExc_RuntimeError, e.GetMessageString()); |
| | return -1; |
| | } |
| | } |
| |
|
| | |
| | std::string PointConstraintPy::representation() const |
| | { |
| | return {"<GeomPlate_PointConstraint object>"}; |
| | } |
| |
|
| | PyObject* PointConstraintPy::setOrder(PyObject* args) |
| | { |
| | int order; |
| | if (!PyArg_ParseTuple(args, "i", &order)) { |
| | return nullptr; |
| | } |
| |
|
| | try { |
| | getGeomPlate_PointConstraintPtr()->SetOrder(order); |
| | Py_Return; |
| | } |
| | catch (const Standard_Failure& e) { |
| | PyErr_SetString(PyExc_RuntimeError, e.GetMessageString()); |
| | return nullptr; |
| | } |
| | } |
| |
|
| | PyObject* PointConstraintPy::order(PyObject* args) |
| | { |
| | if (!PyArg_ParseTuple(args, "")) { |
| | return nullptr; |
| | } |
| |
|
| | try { |
| | Standard_Integer v = getGeomPlate_PointConstraintPtr()->Order(); |
| | return PyLong_FromLong(v); |
| | } |
| | catch (const Standard_Failure& e) { |
| | PyErr_SetString(PyExc_RuntimeError, e.GetMessageString()); |
| | return nullptr; |
| | } |
| | } |
| |
|
| | PyObject* PointConstraintPy::G0Criterion(PyObject* args) |
| | { |
| | if (!PyArg_ParseTuple(args, "")) { |
| | return nullptr; |
| | } |
| |
|
| | try { |
| | Standard_Real v = getGeomPlate_PointConstraintPtr()->G0Criterion(); |
| | return PyFloat_FromDouble(v); |
| | } |
| | catch (const Standard_Failure& e) { |
| | PyErr_SetString(PyExc_RuntimeError, e.GetMessageString()); |
| | return nullptr; |
| | } |
| | } |
| |
|
| | PyObject* PointConstraintPy::G1Criterion(PyObject* args) |
| | { |
| | if (!PyArg_ParseTuple(args, "")) { |
| | return nullptr; |
| | } |
| |
|
| | try { |
| | Standard_Real v = getGeomPlate_PointConstraintPtr()->G1Criterion(); |
| | return PyFloat_FromDouble(v); |
| | } |
| | catch (const Standard_Failure& e) { |
| | PyErr_SetString(PyExc_RuntimeError, e.GetMessageString()); |
| | return nullptr; |
| | } |
| | } |
| |
|
| | PyObject* PointConstraintPy::G2Criterion(PyObject* args) |
| | { |
| | if (!PyArg_ParseTuple(args, "")) { |
| | return nullptr; |
| | } |
| |
|
| | try { |
| | Standard_Real v = getGeomPlate_PointConstraintPtr()->G2Criterion(); |
| | return PyFloat_FromDouble(v); |
| | } |
| | catch (const Standard_Failure& e) { |
| | PyErr_SetString(PyExc_RuntimeError, e.GetMessageString()); |
| | return nullptr; |
| | } |
| | } |
| |
|
| | PyObject* PointConstraintPy::setG0Criterion(PyObject* args) |
| | { |
| | double tolDist; |
| | if (!PyArg_ParseTuple(args, "d", &tolDist)) { |
| | return nullptr; |
| | } |
| |
|
| | try { |
| | getGeomPlate_PointConstraintPtr()->SetG0Criterion(tolDist); |
| | Py_Return; |
| | } |
| | catch (const Standard_Failure& e) { |
| | PyErr_SetString(PyExc_RuntimeError, e.GetMessageString()); |
| | return nullptr; |
| | } |
| | } |
| |
|
| | PyObject* PointConstraintPy::setG1Criterion(PyObject* args) |
| | { |
| | double tolAng; |
| | if (!PyArg_ParseTuple(args, "d", &tolAng)) { |
| | return nullptr; |
| | } |
| |
|
| | try { |
| | getGeomPlate_PointConstraintPtr()->SetG1Criterion(tolAng); |
| | Py_Return; |
| | } |
| | catch (const Standard_Failure& e) { |
| | PyErr_SetString(PyExc_RuntimeError, e.GetMessageString()); |
| | return nullptr; |
| | } |
| | } |
| |
|
| | PyObject* PointConstraintPy::setG2Criterion(PyObject* args) |
| | { |
| | double tolCurv; |
| | if (!PyArg_ParseTuple(args, "d", &tolCurv)) { |
| | return nullptr; |
| | } |
| |
|
| | try { |
| | getGeomPlate_PointConstraintPtr()->SetG2Criterion(tolCurv); |
| | Py_Return; |
| | } |
| | catch (const Standard_Failure& e) { |
| | PyErr_SetString(PyExc_RuntimeError, e.GetMessageString()); |
| | return nullptr; |
| | } |
| | } |
| |
|
| | PyObject* PointConstraintPy::hasPnt2dOnSurf(PyObject* args) |
| | { |
| | if (!PyArg_ParseTuple(args, "")) { |
| | return nullptr; |
| | } |
| |
|
| | try { |
| | Standard_Boolean ok = getGeomPlate_PointConstraintPtr()->HasPnt2dOnSurf(); |
| | return Py_BuildValue("O", (ok ? Py_True : Py_False)); |
| | } |
| | catch (const Standard_Failure& e) { |
| | PyErr_SetString(PyExc_RuntimeError, e.GetMessageString()); |
| | return nullptr; |
| | } |
| | } |
| |
|
| | PyObject* PointConstraintPy::setPnt2dOnSurf(PyObject* args) |
| | { |
| | double x, y; |
| | if (!PyArg_ParseTuple(args, "dd", &x, &y)) { |
| | return nullptr; |
| | } |
| |
|
| | try { |
| | getGeomPlate_PointConstraintPtr()->SetPnt2dOnSurf(gp_Pnt2d(x, y)); |
| | Py_Return; |
| | } |
| | catch (const Standard_Failure& e) { |
| | PyErr_SetString(PyExc_RuntimeError, e.GetMessageString()); |
| | return nullptr; |
| | } |
| | } |
| |
|
| | PyObject* PointConstraintPy::pnt2dOnSurf(PyObject* args) |
| | { |
| | if (!PyArg_ParseTuple(args, "")) { |
| | return nullptr; |
| | } |
| |
|
| | try { |
| | gp_Pnt2d pt = getGeomPlate_PointConstraintPtr()->Pnt2dOnSurf(); |
| | Py::Tuple coord(2); |
| | coord.setItem(0, Py::Float(pt.X())); |
| | coord.setItem(1, Py::Float(pt.Y())); |
| | return Py::new_reference_to(coord); |
| | } |
| | catch (const Standard_Failure& e) { |
| | PyErr_SetString(PyExc_RuntimeError, e.GetMessageString()); |
| | return nullptr; |
| | } |
| | } |
| |
|
| | PyObject* PointConstraintPy::getCustomAttributes(const char* ) const |
| | { |
| | return nullptr; |
| | } |
| |
|
| | int PointConstraintPy::setCustomAttributes(const char* , PyObject* ) |
| | { |
| | return 0; |
| | } |
| |
|