MeVisLab supports NumPy nd-arrays in various places. Using NumPy arrays makes sense when you want to pass large amounts of data between Python and C++ wrappers. NumPy arrays are automatically converted to QList<[double|float|int|...]> or QVariantList when passed into a wrapper methods. As a general convention, we use the term NumPyArray whenever we mean a numpy.ndarray, because ndarray is not commonly known to people that don't use NumPy a lot.
The following classes support NumPy:
- QByteArray::toNumPyArray(), QByteArray::fromNumPyArray()
- QImage::toNumPyArray(), QImage::fromNumPyArray()
- MeVisLab Fields: fields with vectors/matrices have an ndarray property and a numPyValue() method
- MLABDicomTag::toNumPyArray(), MLABMutableDicomTag::setValueFromNumPyArray() for binary data DicomTags
- Open Inventor wrappers for SoMFVec2f, SoMFVec3f, SoMFColor and SoMFPlane return NumPy arrays when calling startEditing()
- MLCSOListWrapper, MLWEMWrapper, MLWEMPatchWrapper, MLXMarkerListWrapper all have methods that allow to set/get values via NumPy arrays, look for methods with NumPy in their name.
- MLPagedImageWrapper and MLWriteablePagedImageWrapper, see Python image processing.
You can find details on the NumPy API itself at: https://docs.scipy.org/doc/numpy/reference/
The following code shows an example how to create a WEM triangle patch using NumPy:
import numpy
points = numpy.asarray(([0,0,0], [2,0,0], [2,1,0], [0,1,0]), numpy.float64)
triangles = numpy.asarray(([0,1,2], [1,2,3]), numpy.uint32)
patch = wem.addTrianglePatchFromNumPyArray(points, triangles)
QObject * createMLBaseObject(const QString &baseClassName, const QVariantList &arguments=QVariantList())
Creates a new reference-counted ml::Base object, conveniently wrapped for scripting; which arguments ...