0001221: Add a function that can apply a Placement to a Shape like sh.transformGeometry(sh.Placement.toMatrix())

This commit is contained in:
wmayer 2013-08-25 11:32:03 +02:00
parent 47fd378f3f
commit 1da39d014d
4 changed files with 8 additions and 6 deletions

View File

@ -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();
}

View File

@ -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<TopoDS_Shape,TopoDS_Shape> >& s) const;

View File

@ -156,7 +156,8 @@ underlying geometry then use the methods translate or rotate.
<Methode Name="transformShape">
<Documentation>
<UserDocu>Apply transformation on a shape without changing
the underlying geometry.</UserDocu>
the underlying geometry.
transformShape(Matrix,[boolean copy=False])</UserDocu>
</Documentation>
</Methode>
<Methode Name="translate">

View File

@ -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), &copy))
return NULL;
Base::Matrix4D mat = static_cast<Base::MatrixPy*>(obj)->value();
try {
this->getTopoShapePtr()->transformShape(mat);
this->getTopoShapePtr()->transformShape(mat, PyObject_IsTrue(copy) ? true : false);
Py_Return;
}
catch (Standard_Failure) {