Base: misc patches
Convenience macros/function (in Interpreter.h) * FC_PY_GetObject/Callable(), look for callables in a python object, which will be used in future patch to improve performance in various python observer/features. * pyCall(WithKeywords)(), helper function to invoke the callable Matrix4D: * hasScale(), check if there is any scale in the transformation. If so, further check if the scale is uniform or not. This will be used in future patch for Part::TopoShape to decide which type of transform to apply. Placement: * translate/rotate(), new convenience API Rotation: * isSame/multiVec(), new convenience API Polygon2d: * Intersect(), GetCenter(), new convenience API. FlagToggler: * New class for exception safe flag toggling, similar to StateLocker but with template (actually, FlagToggler is added earlier by me). BitsetLocker: * New class for exception manipulation of a std::bitset variable.
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include "MatrixPy.h"
|
||||
#include "RotationPy.h"
|
||||
#include "VectorPy.h"
|
||||
#include "Tools.h"
|
||||
|
||||
using namespace Base;
|
||||
|
||||
@@ -158,6 +159,34 @@ PyObject* PlacementPy::move(PyObject * args)
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* PlacementPy::translate(PyObject * args)
|
||||
{
|
||||
return move(args);
|
||||
}
|
||||
|
||||
PyObject* PlacementPy::rotate(PyObject *args) {
|
||||
PyObject *obj1, *obj2;
|
||||
double angle;
|
||||
if (!PyArg_ParseTuple(args, "OOd", &obj1, &obj2, &angle))
|
||||
return NULL;
|
||||
|
||||
try {
|
||||
Py::Sequence p1(obj1), p2(obj2);
|
||||
Vector3d center((double)Py::Float(p1[0]),
|
||||
(double)Py::Float(p1[1]),
|
||||
(double)Py::Float(p1[2]));
|
||||
Vector3d axis((double)Py::Float(p2[0]),
|
||||
(double)Py::Float(p2[1]),
|
||||
(double)Py::Float(p2[2]));
|
||||
(*getPlacementPtr()) *= Placement(
|
||||
Vector3d(),Rotation(axis,toRadians<double>(angle)),center);
|
||||
Py_Return;
|
||||
}
|
||||
catch (const Py::Exception&) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* PlacementPy::multiply(PyObject * args)
|
||||
{
|
||||
PyObject *plm;
|
||||
|
||||
Reference in New Issue
Block a user