diff --git a/src/Mod/Part/App/TopoShapePy.xml b/src/Mod/Part/App/TopoShapePy.xml index 29a9f49cbc..f0924ebc59 100644 --- a/src/Mod/Part/App/TopoShapePy.xml +++ b/src/Mod/Part/App/TopoShapePy.xml @@ -489,6 +489,11 @@ op: an optional string to be appended when auto generates element mapping. Reverses the orientation of this shape. + + + Reverses the orientation of a copy of this shape. + + Computes the complement of the orientation of this shape, diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index b380f42272..28f7ff1257 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -1769,6 +1769,31 @@ PyObject* TopoShapePy::reverse(PyObject *args) Py_Return; } +PyObject* TopoShapePy::reversed(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return NULL; + + TopoDS_Shape shape = getTopoShapePtr()->getShape(); + shape = shape.Reversed(); + + PyTypeObject* type = this->GetType(); + PyObject* cpy = nullptr; + + // let the type object decide + if (type->tp_new) + cpy = type->tp_new(type, this, 0); + if (!cpy) { + PyErr_SetString(PyExc_TypeError, "failed to create copy of shape"); + return nullptr; + } + + if (!shape.IsNull()) { + static_cast(cpy)->getTopoShapePtr()->setShape(shape); + } + return cpy; +} + PyObject* TopoShapePy::complement(PyObject *args) { if (!PyArg_ParseTuple(args, ""))