Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1880

Conversion from numpy.ndarray to QSurfaceDataArray

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • Not Evaluated
    • None
    • None
    • PySide, Shiboken
    • None
    • Win 10

      Python 3.9.10

      Pyside6

    • 37697e672b (pyside/pyside-setup/dev) 37697e672b (pyside/tqtc-pyside-setup/dev)

    Description

      The only way to create QSurfaceDataArray to pass to the QSurfaceDataProxy object is via a nested for loop that creates for every point a QVerctor3D object. For bigger arrays like 300x300, this takes extremely long and for real time use it is in my case too slow.

      My code to generate a QSurfaceDataArray or in the Surface Example:

      def parse_data(data: np.ndarray):
          global vector_list
          for y_index in range(data.shape[0]):
              for x_index in range(data.shape[1]):
                  vector_list[y_index][x_index] = QVector3D(x_index, data[y_index, x_index], y_index)
      

      The vector_list is after the generation passed to the QSurfaceDataProxy.setRows function. I think the problem is, that the list must contain QVector3D objects and therefore no direct conversion with numpy or python functions is possible.

      It would be nicer and probably much faster, if a numpy ndarray (2D or 3D) could be passed directly as a QSurfaceDataArray, or a conversion function would exist.

      typedef QList<QSurfaceDataItem> QSurfaceDataRow;
      typedef QList<QSurfaceDataRow *> QSurfaceDataArray;
      
       QSurfaceDataItem::QSurfaceDataItem(const QVector3D &position);
      

      Attachments

        Issue Links

          For Gerrit Dashboard: PYSIDE-1880
          # Subject Branch Project Status CR V

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              ludw Matthias Ludwig
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes