Part: expose ShapeFix_Shell to Python
This commit is contained in:
@@ -30,10 +30,57 @@
|
||||
<UserDocu>Returns fixed shell (or subset of oriented faces)</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="numberOfShells">
|
||||
<Documentation>
|
||||
<UserDocu>Returns the number of obtained shells</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="shape">
|
||||
<Documentation>
|
||||
<UserDocu>In case of multiconnexity returns compound of fixed shells and one shell otherwise</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="errorFaces">
|
||||
<Documentation>
|
||||
<UserDocu>Returns not oriented subset of faces</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="fixFaceOrientation">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
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.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setNonManifoldFlag">
|
||||
<Documentation>
|
||||
<UserDocu>Sets NonManifold flag</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="FixOrientationMode" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Mode for applying fixes of orientation of faces</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="FixOrientationMode" Type="Boolean"/>
|
||||
</Attribute>
|
||||
<Attribute Name="FixFaceMode" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Mode for applying fixes using ShapeFix_Face</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="FixFaceMode" Type="Boolean"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -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<TopoShapePy*>(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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user