diff --git a/src/Mod/Part/App/ShapeFix/ShapeFix_ShellPy.xml b/src/Mod/Part/App/ShapeFix/ShapeFix_ShellPy.xml index 38d6d0cdd4..88c7fe6f04 100644 --- a/src/Mod/Part/App/ShapeFix/ShapeFix_ShellPy.xml +++ b/src/Mod/Part/App/ShapeFix/ShapeFix_ShellPy.xml @@ -30,10 +30,57 @@ Returns fixed shell (or subset of oriented faces) + + + Returns the number of obtained shells + + In case of multiconnexity returns compound of fixed shells and one shell otherwise + + + Returns not oriented subset of faces + + + + + +Fixes orientation of faces in shell. +Changes orientation of face in the shell, if it is oriented opposite +to neigbouring faces. If it is not possible to orient all faces in the +shell (like in case of mebious band), this method orients only subset +of faces. Other faces are stored in Error compound. +Modes : +isAccountMultiConex - mode for account cases of multiconnexity. +If this mode is equal to Standard_True, separate shells will be created +in the cases of multiconnexity. If this mode is equal to Standard_False, +one shell will be created without account of multiconnexity.By defautt - Standard_True; +NonManifold - mode for creation of non-manifold shells. +If this mode is equal to Standard_True one non-manifold will be created from shell +contains multishared edges. Else if this mode is equal to Standard_False only +manifold shells will be created. By default - Standard_False. + + + + + + Sets NonManifold flag + + + + + Mode for applying fixes of orientation of faces + + + + + + Mode for applying fixes using ShapeFix_Face + + + diff --git a/src/Mod/Part/App/ShapeFix/ShapeFix_ShellPyImp.cpp b/src/Mod/Part/App/ShapeFix/ShapeFix_ShellPyImp.cpp index 1b29e06674..19fdc6fcb2 100644 --- a/src/Mod/Part/App/ShapeFix/ShapeFix_ShellPyImp.cpp +++ b/src/Mod/Part/App/ShapeFix/ShapeFix_ShellPyImp.cpp @@ -88,6 +88,15 @@ PyObject* ShapeFix_ShellPy::shell(PyObject *args) return shape.getPyObject(); } +PyObject* ShapeFix_ShellPy::numberOfShells(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + int num = getShapeFix_ShellPtr()->NbShells(); + return Py::new_reference_to(Py::Long(num)); +} + PyObject* ShapeFix_ShellPy::shape(PyObject *args) { if (!PyArg_ParseTuple(args, "")) @@ -97,6 +106,61 @@ PyObject* ShapeFix_ShellPy::shape(PyObject *args) return shape.getPyObject(); } +PyObject* ShapeFix_ShellPy::errorFaces(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + TopoShape shape = getShapeFix_ShellPtr()->ErrorFaces(); + return shape.getPyObject(); +} + +PyObject* ShapeFix_ShellPy::fixFaceOrientation(PyObject *args) +{ + PyObject* shell; + PyObject* multiConex = Py_True; + PyObject* nonManifold = Py_False; + if (!PyArg_ParseTuple(args, "O!|O!O!", &TopoShapeShellPy::Type, &shell, + &PyBool_Type, &multiConex, + &PyBool_Type, &nonManifold)) + return nullptr; + + bool ok = getShapeFix_ShellPtr()->FixFaceOrientation(TopoDS::Shell(static_cast(shell)->getTopoShapePtr()->getShape()), + PyObject_IsTrue(multiConex) ? Standard_True : Standard_False, + PyObject_IsTrue(nonManifold) ? Standard_True : Standard_False); + return Py::new_reference_to(Py::Boolean(ok)); +} + +PyObject* ShapeFix_ShellPy::setNonManifoldFlag(PyObject *args) +{ + PyObject* nonManifold; + if (!PyArg_ParseTuple(args, "O!", &PyBool_Type, &nonManifold)) + return nullptr; + + getShapeFix_ShellPtr()->SetNonManifoldFlag(PyObject_IsTrue(nonManifold) ? Standard_True : Standard_False); + Py_Return; +} + +Py::Boolean ShapeFix_ShellPy::getFixFaceMode() const +{ + return Py::Boolean(getShapeFix_ShellPtr()->FixFaceMode()); +} + +void ShapeFix_ShellPy::setFixFaceMode(Py::Boolean arg) +{ + getShapeFix_ShellPtr()->FixFaceMode() = arg; +} + +Py::Boolean ShapeFix_ShellPy::getFixOrientationMode() const +{ + return Py::Boolean(getShapeFix_ShellPtr()->FixOrientationMode()); +} + +void ShapeFix_ShellPy::setFixOrientationMode(Py::Boolean arg) +{ + getShapeFix_ShellPtr()->FixOrientationMode() = arg; +} + PyObject *ShapeFix_ShellPy::getCustomAttributes(const char* /*attr*/) const { return nullptr; diff --git a/src/Mod/Part/TestPartApp.py b/src/Mod/Part/TestPartApp.py index f471738a8d..0577392162 100644 --- a/src/Mod/Part/TestPartApp.py +++ b/src/Mod/Part/TestPartApp.py @@ -490,3 +490,16 @@ class PartTestShapeFix(unittest.TestCase): fix.perform() fix.shell() fix.shape() + + fix.setNonManifoldFlag(True) + fix.fixFaceOrientation(shell) + + self.assertEqual(len(fix.errorFaces().Faces), 0) + + self.assertEqual(fix.numberOfShells(), 1) + + fix.FixFaceMode = True + self.assertEqual(fix.FixFaceMode, True) + + fix.FixOrientationMode = True + self.assertEqual(fix.FixOrientationMode, True)