diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index a7a6b8c5e..0af323e6c 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -56,6 +56,7 @@ # include # include # include +# include # include # include # include @@ -1491,6 +1492,16 @@ TopoDS_Shape TopoShape::makeThickSolid(const TopTools_ListOfShape& remFace, return mkThick.Shape(); } +TopoDS_Shape TopoShape::makeOffset(double offset, double tol, bool intersection, + bool selfInter, short offsetMode, short join) +{ + BRepOffsetAPI_MakeOffsetShape mkOffset(this->_Shape, offset, tol, BRepOffset_Mode(offsetMode), + intersection ? Standard_True : Standard_False, + selfInter ? Standard_True : Standard_False, + GeomAbs_JoinType(join)); + return mkOffset.Shape(); +} + void TopoShape::transformGeometry(const Base::Matrix4D &rclMat) { this->_Shape = transformGShape(rclMat); diff --git a/src/Mod/Part/App/TopoShape.h b/src/Mod/Part/App/TopoShape.h index 817e69402..9def92645 100644 --- a/src/Mod/Part/App/TopoShape.h +++ b/src/Mod/Part/App/TopoShape.h @@ -199,6 +199,9 @@ public: TopoDS_Shape makeTube(double radius, double tol) const; TopoDS_Shape makeTube() const; TopoDS_Shape makeLoft(const TopTools_ListOfShape& profiles, Standard_Boolean isSolid, Standard_Boolean isRuled) const; + TopoDS_Shape makeOffset(double offset, double tol, + bool intersection = false, bool selfInter = false, + short offsetMode = 0, short join = 0); //@} /** @name Manipulation*/ diff --git a/src/Mod/Part/App/TopoShapePy.xml b/src/Mod/Part/App/TopoShapePy.xml index 1be6ec7ab..af77a262a 100644 --- a/src/Mod/Part/App/TopoShapePy.xml +++ b/src/Mod/Part/App/TopoShapePy.xml @@ -179,6 +179,11 @@ which are to be removed. The remaining faces of the solid become the walls of the hollowed solid, their thickness defined at the time of construction. + + + Offset a given shape + + Reverses the orientation of this shape. diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index 374028e54..66e9a01e7 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -965,6 +965,31 @@ PyObject* TopoShapePy::makeThickness(PyObject *args) } } +PyObject* TopoShapePy::makeOffsetShape(PyObject *args) +{ + double offset, tolerance; + PyObject* inter = Py_False; + PyObject* self_inter = Py_False; + short offsetMode = 0, join = 0; + if (!PyArg_ParseTuple(args, "dd|O!O!hh", + &offset, &tolerance, + &(PyBool_Type), &inter, + &(PyBool_Type), &self_inter, + &offsetMode, &join)) + return 0; + + try { + TopoDS_Shape shape = this->getTopoShapePtr()->makeOffset(offset, tolerance, + (inter == Py_True), (self_inter == Py_True), offsetMode, join); + return new TopoShapePy(new TopoShape(shape)); + } + catch (Standard_Failure) { + Handle_Standard_Failure e = Standard_Failure::Caught(); + PyErr_SetString(PyExc_Exception, e->GetMessageString()); + return NULL; + } +} + PyObject* TopoShapePy::reverse(PyObject *args) { if (!PyArg_ParseTuple(args, ""))