add optional parameters to copy method to copy topology and/or triangulation

This commit is contained in:
wmayer
2018-09-04 23:17:25 +02:00
parent 56d5305edf
commit 68b57d659a
2 changed files with 13 additions and 4 deletions

View File

@@ -539,7 +539,13 @@ into B-spline surfaces.</UserDocu>
</Methode>
<Methode Name="copy" Const="true">
<Documentation>
<UserDocu>Create a copy of this shape</UserDocu>
<UserDocu>Create a copy of this shape
copy(copyGeom=True, copyMesh=False) -> Shape
If copyMesh is True, triangulation contained in original shape will be
copied along with geometry.
If copyGeom is False, only topological objects will be copied, while
geometry and triangulation will be shared with original shape.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="cleaned" Const="true">

View File

@@ -143,7 +143,6 @@ int TopoShapePy::PyInit(PyObject* args, PyObject*)
}
}
catch (Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return -1;
}
@@ -156,7 +155,9 @@ int TopoShapePy::PyInit(PyObject* args, PyObject*)
PyObject* TopoShapePy::copy(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
PyObject* copyGeom = Py_True;
PyObject* copyMesh = Py_False;
if (!PyArg_ParseTuple(args, "|O!O!", &PyBool_Type, &copyGeom, &PyBool_Type, &copyMesh))
return NULL;
const TopoDS_Shape& shape = this->getTopoShapePtr()->getShape();
@@ -171,7 +172,9 @@ PyObject* TopoShapePy::copy(PyObject *args)
}
if (!shape.IsNull()) {
BRepBuilderAPI_Copy c(shape);
BRepBuilderAPI_Copy c(shape,
PyObject_IsTrue(copyGeom) ? Standard_True : Standard_False,
PyObject_IsTrue(copyMesh) ? Standard_True : Standard_False);
static_cast<TopoShapePy*>(cpy)->getTopoShapePtr()->setShape(c.Shape());
}
return cpy;