now i found the CPU usage is very high when using QT3D Comparing with the QT embedded VTK



  • 1 when i create a Qt3DWindow and draw some axise and grid the cpu increased %27memery increased 24MByte ,but do same thing with vtk ,it just increased %1or %2 .. and the memery increased only 2MByte..could anyone now why? or That's what it was


  • Lifetime Qt Champion

    Hi,

    You should provide the version of the libraries you are using.

    In any case, if older than 5.9.2, you should upgrade to it at least. Memory and CPU improvements have been done in Qt3D.



  • 1.yes qt 5.9.0 and also test with 5.9.2 example and now i found the qt3d has no convenient api for update window like vtk api Render..how to update the QT3DWindows when 3DObject is change (add,delete..ect) 2.the result of testing with 5.9.2 example(metarials-cpp) ,the cpu is increased %24 ..memery used up 166MByte


  • Lifetime Qt Champion

    Can you provide sample applications that shows the behaviour of both ?

    By the way, why not stay with VTK if it does the job you want ?



    1. 5.9.2 example(metarials-cpp) just this src provided by installing qt-opensource-windows-x86-5.9.2.exe.. this is my computer path C:\Qt\Qt5.9.2\Examples\Qt-5.9.2\qt3d\materials-cpp. and my os is window 8.1 Microsoft Windows [Version 6.3.9600] ..
      2.using vtk to load a stl file it will cost more twice memery than file size. and our file maybe very large . but using qt3d even not getting rid of the repeat points, it cost less memery than vtk. excepert drawing some axise and grid .(consist of lines adn cubics)
      3 btw could u tell how to get rid of the repeat points..this my snippet:
      Qt3DRender::QGeometry geometry = new Qt3DRender::QGeometry;
      auto m_positionAttr = new Qt3DRender::QAttribute(geometry);
      //auto m_colorAttr = new Qt3DRender::QAttribute(geometry);
      auto m_indexAttr = new Qt3DRender::QAttribute(geometry);
      auto m_NORAttr = new Qt3DRender::QAttribute(geometry);
      auto m_positionBuffer = new Qt3DRender::QBuffer(Qt3DRender::QBuffer::VertexBuffer, geometry);
      //auto m_colorBuffer = new Qt3DRender::QBuffer(Qt3DRender::QBuffer::VertexBuffer, geometry);
      auto m_indexBuffer = new Qt3DRender::QBuffer(Qt3DRender::QBuffer::IndexBuffer, geometry);
      auto m_NORBuffer = new Qt3DRender::QBuffer(Qt3DRender::QBuffer::VertexBuffer, geometry);
      uint vsize = amesh.mVertices.size();
      uint isize = amesh.mIndices.size();
      vsize = isize;
      //Configure the attributes access
      QByteArray colorData;
      uint size1 = sizeof(QVector3D);
      //positionData.resize(vsize * 3 * sizeof(float));
      QByteArray mNormals, mindexs;
      char
      pdata = (char*)&amesh.mVertices[0][0];
      mindexs.resize(vsize * sizeof(uint));
      uintpindexs = (uint)mindexs.data();
      for (uint i = 0; i <vsize; i++)
      pindexs[i] = i;
      const uint nVerts = vsize;
      const uint size = nVerts * 3 * sizeof(float);
      QByteArray positionBytes, noramlbytes;
      //positionBytes.resize(size);
      vsize = nVerts;
      uint facenum = vsize / 3;
      uint j = 0, i = 0;
      mNormals.resize(vsize * 2 * sizeof(Vector3));
      uintpindex1 = &amesh.mIndices[0];
      Vector3
      vertex = &amesh.mVertices[0];
      Vector3pnormal = (Vector3)mNormals.data();
      Vector3 n;
      FindMinMax((QVector3D*)vertex, amesh.mVertices.size());
      movetocenterbyOC((QVector3D*)vertex, amesh.mVertices.size(), mcenter);
      uint cnt = 0, index1 = 0, count = 0;
      Vector3 pt[3] = {};
      for (j = 0; j <vsize * 2; )
      {
      if (j % 6 == 0) {
      pt[0] = vertex[pindex1[cnt]];
      pt[1] = vertex[pindex1[cnt+1]];
      pt[2] = vertex[pindex1[cnt+2]];
      CalcNormal(pt, n);
      }

      	pnormal[j++] = vertex[pindex1[cnt++]];
      	pnormal[j++] = n;
      }
      //	m_indexBuffer->setData(mindexs);
      m_NORBuffer->setData(mNormals);
      //m_positionBuffer->setData(QByteArray::fromRawData((char*)&vertex[0], size)); 
      const quint32 elementSize = 3 + 3;
      const quint32 stride = elementSize * sizeof(float);
      //m_colorBuffer->setData(colorData);
      m_positionAttr->setName(Qt3DRender::QAttribute::defaultPositionAttributeName());
      m_positionAttr->setVertexBaseType(Qt3DRender::QAttribute::Float);
      m_positionAttr->setDataSize(3);
      m_positionAttr->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
      m_positionAttr->setBuffer(m_NORBuffer);
      m_positionAttr->setCount(vsize);
      m_positionAttr->setByteStride(stride);
      //m_positionAttr->setProperty();
      
      m_NORAttr->setName(Qt3DRender::QAttribute::defaultNormalAttributeName());
      m_NORAttr->setVertexBaseType(Qt3DRender::QAttribute::Float);
      m_NORAttr->setDataSize(3);
      m_NORAttr->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
      m_NORAttr->setBuffer(m_NORBuffer);
      m_NORAttr->setCount(vsize);
      m_NORAttr->setByteOffset(3 * sizeof(float));
      m_NORAttr->setByteStride(stride);
      
    	geometry->addAttribute(m_positionAttr);
    	geometry->addAttribute(m_NORAttr);
    	//  geometry->addAttribute(m_indexAttr);
    	geometry->setParent(m3dentity);
    	return geometry;


  • class Mesh{
    std::vector<uint> mIndices;// all stl file vertices index 0,1,2........
    std::vector<Vector3> mVertices;// all stl file vertices {{x0,y0,z0},{x1,y1,z1},......}
    }amesh;
    my really mean is how to construct data (which have already been not including the repeat points) to m_positionAttr and m_indexBuffer


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.