MCPcopy Create free account
hub / github.com/Kitware/VTK / vtkPythonGetNArray

Function vtkPythonGetNArray

Wrapping/PythonCore/vtkPythonArgs.cxx:577–648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

575
576template <class T>
577bool vtkPythonGetNArray(PyObject* o, T* a, int ndim, const size_t* dims)
578{
579 if (a)
580 {
581 size_t inc = 1;
582 for (int j = 1; j < ndim; j++)
583 {
584 inc *= dims[j];
585 }
586
587 size_t n = dims[0];
588 Py_ssize_t m = static_cast<Py_ssize_t>(n);
589
590 if (PyList_Check(o))
591 {
592 m = PyList_Size(o);
593 if (m == static_cast<Py_ssize_t>(n))
594 {
595 bool r = true;
596 if (ndim > 1)
597 {
598 for (Py_ssize_t i = 0; i < m && r; i++)
599 {
600 PyObject* s = PyList_GetItem(o, i);
601 r = vtkPythonGetNArray(s, a, ndim - 1, dims + 1);
602 a += inc;
603 }
604 }
605 else
606 {
607 for (Py_ssize_t i = 0; i < m && r; i++)
608 {
609 PyObject* s = PyList_GetItem(o, i);
610 r = vtkPythonGetValue(s, a[i]);
611 }
612 }
613 return r;
614 }
615 }
616 else if (PySequence_Check(o))
617 {
618 m = PySequence_Size(o);
619 if (m == static_cast<Py_ssize_t>(n))
620 {
621 bool r = true;
622 for (Py_ssize_t i = 0; i < m && r; i++)
623 {
624 r = false;
625 PyObject* s = PySequence_GetItem(o, i);
626 if (s)
627 {
628 if (ndim > 1)
629 {
630 r = vtkPythonGetNArray(s, a, ndim - 1, dims + 1);
631 a += inc;
632 }
633 else
634 {

Callers

nothing calls this directly

Calls 2

vtkPythonGetValueFunction · 0.85
vtkPythonSequenceErrorFunction · 0.85

Tested by

no test coverage detected