Hello!

I want to visualize a large 2D triangulation consisting of several million triangles. It works already
but the memory consumption is way too high:
Qt Code:
  1. class TriangulationScene : public QGraphicsScene
  2. {
  3. public:
  4. TriangulationScene();
  5. void scribble();
  6. ...
  7. }
  8.  
  9. void TriangulationScene::scribble()
  10. {
  11. setItemIndexMethod(NoIndex);
  12. for(vector<Triangle2*>::iterator it(vTriangles.begin());it!=vTriangles.end();++it)
  13. {
  14. Triangle2* pT(*it);
  15. Point2* p0(pT->getCorner(0));
  16. Point2* p1(pT->getCorner(1));
  17. Point2* p2(pT->getCorner(2));
  18. QPolygonF polygon;
  19. polygon << QPointF(p0->x(),p0->y())<<QPointF(p1->x(),p1->y())<<QPointF(p2->x(),p2->y());
  20. this->addPolygon(polygon);
  21. }
  22. }
  23.  
  24. int main(int argc, char *argv[])
  25. {
  26. QApplication a(argc, argv);
  27. TriangulationScene s;
  28. v.setDragMode(QGraphicsView::ScrollHandDrag);
  29. v.resize(1024,768);
  30. v.scale(100,100);
  31. v.show();
  32. return a.exec();
  33. }
To copy to clipboard, switch view to plain text mode 

This way I need 1 GB for 2 million triangles. I see two possible workarounds:

1) Creating a picture of the triangulation. The drawback is that the picture will certainly
look ugly when zoomed in.

2) I could do it like shown above if I add only the small amount of triangles that must currently
be shown. However, this would require quite some work to implement updates when zooming
or scrolling is done.

Any better ideas? Is there a better class for my purpose than QGraphicsScene?

Thanks, best regards