MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / transformFirstArgument

Method transformFirstArgument

src/App/Expression.cpp:2097–2119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2095}
2096
2097Py::Object FunctionExpression::transformFirstArgument(
2098 const Expression* expression,
2099 const std::vector<Expression*> &arguments,
2100 const Base::Matrix4D* transformationMatrix
2101)
2102{
2103 Py::Object target = arguments[0]->getPyValue();
2104
2105 if (PyObject_TypeCheck(target.ptr(), &Base::MatrixPy::Type)) {
2106 Base::Matrix4D matrix = static_cast<Base::MatrixPy*>(target.ptr())->value();
2107 return Py::asObject(new Base::MatrixPy(*transformationMatrix * matrix));
2108 } else if (PyObject_TypeCheck(target.ptr(), &Base::PlacementPy::Type)) {
2109 Base::Matrix4D placementMatrix =
2110 static_cast<Base::PlacementPy*>(target.ptr())->getPlacementPtr()->toMatrix();
2111 return Py::asObject(new Base::PlacementPy(Base::Placement(*transformationMatrix * placementMatrix)));
2112 } else if (PyObject_TypeCheck(target.ptr(), &Base::RotationPy::Type)) {
2113 Base::Matrix4D rotatioMatrix;
2114 static_cast<Base::RotationPy*>(target.ptr())->getRotationPtr()->getValue(rotatioMatrix);
2115 return Py::asObject(new Base::RotationPy(Base::Rotation(*transformationMatrix * rotatioMatrix)));
2116 }
2117
2118 _EXPR_THROW("Function requires the first argument to be either Matrix, Placement or Rotation.", expression);
2119}
2120
2121Py::Object FunctionExpression::translationMatrix(double x, double y, double z)
2122{

Callers

nothing calls this directly

Calls 7

PlacementClass · 0.70
RotationClass · 0.70
getPyValueMethod · 0.45
ptrMethod · 0.45
valueMethod · 0.45
toMatrixMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected