Make Python API more pythonic
This commit is contained in:
parent
564f3d14e3
commit
a3b4524cca
|
@ -233,7 +233,7 @@ Analyzes the type of transformation.
|
||||||
<Documentation>
|
<Documentation>
|
||||||
<UserDocu>The matrix elements</UserDocu>
|
<UserDocu>The matrix elements</UserDocu>
|
||||||
</Documentation>
|
</Documentation>
|
||||||
<Parameter Name="A" Type="List" />
|
<Parameter Name="A" Type="Sequence" />
|
||||||
</Attribute>
|
</Attribute>
|
||||||
<ClassDeclarations>public:
|
<ClassDeclarations>public:
|
||||||
MatrixPy(const Matrix4D & mat, PyTypeObject *T = &Type)
|
MatrixPy(const Matrix4D & mat, PyTypeObject *T = &Type)
|
||||||
|
|
|
@ -662,24 +662,24 @@ void MatrixPy::setA44(Py::Float arg)
|
||||||
(*this->getMatrixPtr())[3][3] = (double)arg;
|
(*this->getMatrixPtr())[3][3] = (double)arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py::List MatrixPy::getA(void) const
|
Py::Sequence MatrixPy::getA(void) const
|
||||||
{
|
{
|
||||||
double mat[16];
|
double mat[16];
|
||||||
this->getMatrixPtr()->getMatrix(mat);
|
this->getMatrixPtr()->getMatrix(mat);
|
||||||
Py::List list(16);
|
Py::Tuple tuple(16);
|
||||||
for (int i=0; i<16; i++) {
|
for (int i=0; i<16; i++) {
|
||||||
list[i] = Py::Float(mat[i]);
|
tuple[i] = Py::Float(mat[i]);
|
||||||
}
|
}
|
||||||
return list;
|
return tuple;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MatrixPy::setA(Py::List arg)
|
void MatrixPy::setA(Py::Sequence arg)
|
||||||
{
|
{
|
||||||
double mat[16];
|
double mat[16];
|
||||||
this->getMatrixPtr()->getMatrix(mat);
|
this->getMatrixPtr()->getMatrix(mat);
|
||||||
|
|
||||||
int index=0;
|
int index=0;
|
||||||
for (Py::List::iterator it = arg.begin(); it != arg.end() && index < 16; ++it) {
|
for (Py::Sequence::iterator it = arg.begin(); it != arg.end() && index < 16; ++it) {
|
||||||
mat[index++] = (double)Py::Float(*it);
|
mat[index++] = (double)Py::Float(*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,15 +135,15 @@ PyObject* PointsPy::writeInventor(PyObject * args)
|
||||||
PyObject* PointsPy::addPoints(PyObject * args)
|
PyObject* PointsPy::addPoints(PyObject * args)
|
||||||
{
|
{
|
||||||
PyObject *obj;
|
PyObject *obj;
|
||||||
if (!PyArg_ParseTuple(args, "O!", &PyList_Type, &obj))
|
if (!PyArg_ParseTuple(args, "O", &obj))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Py::List list(obj);
|
try {
|
||||||
|
Py::Sequence list(obj);
|
||||||
union PyType_Object pyType = {&(Base::VectorPy::Type)};
|
union PyType_Object pyType = {&(Base::VectorPy::Type)};
|
||||||
Py::Type vType(pyType.o);
|
Py::Type vType(pyType.o);
|
||||||
|
|
||||||
try {
|
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||||
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
|
|
||||||
if ((*it).isType(vType)) {
|
if ((*it).isType(vType)) {
|
||||||
Py::Vector p(*it);
|
Py::Vector p(*it);
|
||||||
getPointKernelPtr()->push_back(p.toVector());
|
getPointKernelPtr()->push_back(p.toVector());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user