Part: adjust TopoShape::transformGShape() to reduce code duplication of TopoShape::makeGTransform
Revert changes of a96d356afb as otherwise there is no way to handle a failure in client code
This commit is contained in:
@@ -3179,7 +3179,7 @@ void TopoShape::transformGeometry(const Base::Matrix4D &rclMat)
|
||||
*this = makeGTransform(rclMat);
|
||||
}
|
||||
|
||||
TopoDS_Shape TopoShape::transformGShape(const Base::Matrix4D& rclTrf) const
|
||||
TopoDS_Shape TopoShape::transformGShape(const Base::Matrix4D& rclTrf, bool copy) const
|
||||
{
|
||||
if (this->_Shape.IsNull())
|
||||
Standard_Failure::Raise("Cannot transform null shape");
|
||||
@@ -3199,7 +3199,7 @@ TopoDS_Shape TopoShape::transformGShape(const Base::Matrix4D& rclTrf) const
|
||||
mat.SetValue(3,4,rclTrf[2][3]);
|
||||
|
||||
// geometric transformation
|
||||
BRepBuilderAPI_GTransform mkTrf(this->_Shape, mat);
|
||||
BRepBuilderAPI_GTransform mkTrf(this->_Shape, mat, copy);
|
||||
return mkTrf.Shape();
|
||||
}
|
||||
|
||||
@@ -4354,32 +4354,9 @@ TopoShape &TopoShape::makeTransform(const TopoShape &shape, const gp_Trsf &trsf,
|
||||
return *this;
|
||||
}
|
||||
|
||||
TopoShape &TopoShape::makeGTransform(const TopoShape &shape,
|
||||
const Base::Matrix4D &rclTrf, const char *op, bool copy)
|
||||
TopoShape &TopoShape::makeGTransform(const TopoShape &shape, const Base::Matrix4D &rclTrf, const char *op, bool copy)
|
||||
{
|
||||
(void)op;
|
||||
gp_GTrsf mat;
|
||||
mat.SetValue(1,1,rclTrf[0][0]);
|
||||
mat.SetValue(2,1,rclTrf[1][0]);
|
||||
mat.SetValue(3,1,rclTrf[2][0]);
|
||||
mat.SetValue(1,2,rclTrf[0][1]);
|
||||
mat.SetValue(2,2,rclTrf[1][1]);
|
||||
mat.SetValue(3,2,rclTrf[2][1]);
|
||||
mat.SetValue(1,3,rclTrf[0][2]);
|
||||
mat.SetValue(2,3,rclTrf[1][2]);
|
||||
mat.SetValue(3,3,rclTrf[2][2]);
|
||||
mat.SetValue(1,4,rclTrf[0][3]);
|
||||
mat.SetValue(2,4,rclTrf[1][3]);
|
||||
mat.SetValue(3,4,rclTrf[2][3]);
|
||||
|
||||
try {
|
||||
// geometric transformation
|
||||
BRepBuilderAPI_GTransform mkTrf(shape.getShape(), mat, copy);
|
||||
_Shape = mkTrf.Shape();
|
||||
}
|
||||
catch (const Standard_Failure& e) {
|
||||
Base::Console().Error("TopoShape::makeGTransform failed: %s\n", e.GetMessageString());
|
||||
}
|
||||
std::ignore = op;
|
||||
_Shape = shape.transformGShape(rclTrf, copy);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ public:
|
||||
/** @name Manipulation*/
|
||||
//@{
|
||||
void transformGeometry(const Base::Matrix4D &rclMat);
|
||||
TopoDS_Shape transformGShape(const Base::Matrix4D&) const;
|
||||
TopoDS_Shape transformGShape(const Base::Matrix4D&, bool copy = false) const;
|
||||
bool transformShape(const Base::Matrix4D&, bool copy, bool checkScale=false);
|
||||
TopoDS_Shape mirror(const gp_Ax2&) const;
|
||||
TopoDS_Shape toNurbs() const;
|
||||
|
||||
@@ -1374,16 +1374,16 @@ PyObject* TopoShapePy::mirror(PyObject *args)
|
||||
PyObject* TopoShapePy::transformGeometry(PyObject *args)
|
||||
{
|
||||
PyObject *obj;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(Base::MatrixPy::Type),&obj))
|
||||
PyObject *cpy = Py_False;
|
||||
if (!PyArg_ParseTuple(args, "O!|O!", &(Base::MatrixPy::Type), &obj, &PyBool_Type, &cpy))
|
||||
return nullptr;
|
||||
|
||||
Base::Matrix4D mat = static_cast<Base::MatrixPy*>(obj)->value();
|
||||
try {
|
||||
TopoDS_Shape shape = this->getTopoShapePtr()->transformGShape(mat);
|
||||
Base::Matrix4D mat = static_cast<Base::MatrixPy*>(obj)->value();
|
||||
TopoDS_Shape shape = this->getTopoShapePtr()->transformGShape(mat, PyObject_IsTrue(cpy) ? true : false);
|
||||
return new TopoShapePy(new TopoShape(shape));
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user