From 8d177f3cafd1388a058f7802d5bbbdc5d4551559 Mon Sep 17 00:00:00 2001 From: tomate44 Date: Tue, 3 Jul 2018 13:44:52 +0200 Subject: [PATCH] add python binding of OCC defeaturing --- src/Mod/Part/App/TopoShapePy.xml | 6 ++++++ src/Mod/Part/App/TopoShapePyImp.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/Mod/Part/App/TopoShapePy.xml b/src/Mod/Part/App/TopoShapePy.xml index 4ad0dd941f..44a8b66cb7 100644 --- a/src/Mod/Part/App/TopoShapePy.xml +++ b/src/Mod/Part/App/TopoShapePy.xml @@ -563,6 +563,12 @@ The parameter is in the form list of tuples with the two shapes. The parameter is a list of shapes. + + + Remove a feature defined by supplied faces and return a new shape. +The parameter is a list of faces. + + Checks whether a point is inside or outside the shape. diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index 93a46bdc11..720c9b695a 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -2650,6 +2650,33 @@ PyObject* TopoShapePy::optimalBoundingBox(PyObject *args) } } +PyObject* TopoShapePy::defeaturing(PyObject *args) +{ + PyObject *l; + if (!PyArg_ParseTuple(args, "O",&l)) + return NULL; + + try { + Py::Sequence list(l); + std::vector shapes; + for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { + Py::TopoShape sh(*it); + shapes.push_back( + sh.extensionObject()->getTopoShapePtr()->getShape() + ); + } + PyTypeObject* type = this->GetType(); + PyObject* inst = type->tp_new(type, this, 0); + static_cast(inst)->getTopoShapePtr()->setShape + (this->getTopoShapePtr()->defeaturing(shapes)); + return inst; + } + catch (const Standard_Failure& e) { + PyErr_SetString(PartExceptionOCCError, e.GetMessageString()); + return NULL; + } +} + // End of Methods, Start of Attributes #if 0 // see ComplexGeoDataPy::Matrix which does the same