From 1da39d014d470c363cc6b27a07a5a18f18e71da1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 25 Aug 2013 11:32:03 +0200 Subject: [PATCH] 0001221: Add a function that can apply a Placement to a Shape like sh.transformGeometry(sh.Placement.toMatrix()) --- src/Mod/Part/App/TopoShape.cpp | 4 ++-- src/Mod/Part/App/TopoShape.h | 2 +- src/Mod/Part/App/TopoShapePy.xml | 3 ++- src/Mod/Part/App/TopoShapePyImp.cpp | 5 +++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index 1afbad292..b41d0c9e6 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -1845,7 +1845,7 @@ TopoDS_Shape TopoShape::transformGShape(const Base::Matrix4D& rclTrf) const return mkTrf.Shape(); } -void TopoShape::transformShape(const Base::Matrix4D& rclTrf) +void TopoShape::transformShape(const Base::Matrix4D& rclTrf, bool copy) { // There is a strange behaviour of the gp_Trsf class if rclTrf has // a negative determinant. @@ -1864,7 +1864,7 @@ void TopoShape::transformShape(const Base::Matrix4D& rclTrf) } // location transformation - BRepBuilderAPI_Transform mkTrf(this->_Shape, mat); + BRepBuilderAPI_Transform mkTrf(this->_Shape, mat, copy ? Standard_True : Standard_False); this->_Shape = mkTrf.Shape(); } diff --git a/src/Mod/Part/App/TopoShape.h b/src/Mod/Part/App/TopoShape.h index 0369682ff..9e7ecd9a1 100644 --- a/src/Mod/Part/App/TopoShape.h +++ b/src/Mod/Part/App/TopoShape.h @@ -179,7 +179,7 @@ public: //@{ void transformGeometry(const Base::Matrix4D &rclMat); TopoDS_Shape transformGShape(const Base::Matrix4D&) const; - void transformShape(const Base::Matrix4D&); + void transformShape(const Base::Matrix4D&, bool copy); TopoDS_Shape mirror(const gp_Ax2&) const; TopoDS_Shape toNurbs() const; TopoDS_Shape replaceShape(const std::vector< std::pair >& s) const; diff --git a/src/Mod/Part/App/TopoShapePy.xml b/src/Mod/Part/App/TopoShapePy.xml index b78fe5737..92b56f50f 100644 --- a/src/Mod/Part/App/TopoShapePy.xml +++ b/src/Mod/Part/App/TopoShapePy.xml @@ -156,7 +156,8 @@ underlying geometry then use the methods translate or rotate. Apply transformation on a shape without changing -the underlying geometry. +the underlying geometry. +transformShape(Matrix,[boolean copy=False]) diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index 4c5779c8f..537e58ec0 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -787,12 +787,13 @@ PyObject* TopoShapePy::transformGeometry(PyObject *args) PyObject* TopoShapePy::transformShape(PyObject *args) { PyObject *obj; - if (!PyArg_ParseTuple(args, "O!", &(Base::MatrixPy::Type),&obj)) + PyObject *copy = Py_False; + if (!PyArg_ParseTuple(args, "O!|O!", &(Base::MatrixPy::Type),&obj,&(PyBool_Type), ©)) return NULL; Base::Matrix4D mat = static_cast(obj)->value(); try { - this->getTopoShapePtr()->transformShape(mat); + this->getTopoShapePtr()->transformShape(mat, PyObject_IsTrue(copy) ? true : false); Py_Return; } catch (Standard_Failure) {