Well, AFAIK there is the possibility to use OpenGL directly but this must/should be done in the context of VTK. I have never done that but maybe another one can say something about it. When you want to use VTK for your colored points I suggest to reorder your data structure: All point coordinates and colors should be separated. This ensures that you can still use VTK's SetData()/SetArray()-API. I.e., keep two separate lists for points and colors. For OpenGL, the opposite might be true, since you can specify interleaved data structures. However, when you keep the lists separated, it is easy for the mapper to distinguish if it should render colorless points or colored points (in case it has a color-list). :-)
-----Ursprüngliche Nachricht----- Von: Clarkson, Matt [mailto:[email protected]] Gesendet: Mittwoch, 8. Mai 2013 16:25 An: Kislinskiy, Stefan Cc: Engelhardt, Sandy; mitk-users Betreff: Re: Bug 14890: Very Slow Rendering of PointSets Hi Stefan, thanks. I also thought about something that would render points, with an associated colour value. Imagine a data set, eg. mitkPointCloud which contains a std::vector< std::pair < mitk::Point3D, itk::RGBPixel < unsigned char > > > (for each timestep obviously). Then each point can have a colour... or provide overloaded functions that enable you to set a point without a colour, and the colour defaults to white. Then a mapper can either render according to a set colour, provided as a colour property on the data node. Or it can render a point with the colour stored with the point. And the rendering is litterally just one open GL point.. so no VTK at all? Would this be of any use? Would it be better/worse? M On 8 May 2013, at 15:09, "Kislinskiy, Stefan" <[email protected]> wrote: > Hi Matt, > > I suggest you to write your own "FastPointSetVtkMapper3D". It should be quite > easy to do so. Here are some tricks to really speed things up: > > 1. Create only one vtkPoints, vtkCellArray, vtkPolyData, vtkPolyDataMapper, > vtkActor and don't do it in every frame. That's a one shot initialization. > 2. Prefer the SetData() method of vtkPoints and hence create a vtkFloatArray > (or vtkDoubleArray) during initialization as well. You can tell the > vtkFloatArray to use your point-array without copying it. > > Pseudo-code: > vector<Point> points; // Your point list > vtkFloatArray->SetNumberOfComponents(3) > vtkFloatArray->SetArray(&points[0], points.size() * 3, 1); // 1 means > vtkFloatArray->VTK does not free your array > vtkPoints->SetData(vtkFloatArray); > > 3. You can also pre-generate your vtkCellArray during initialization (and > extend it on-the-fly if necessary): > vector<vtkIdType> m_Indices; > m_Indices.reserve(2000000); > for (i = 0; i < 1000000; ++i) > { > m_Indices.push_back(1); > m_Indices.push_back(i); > } > > Usage is like this: > vtkIdTypeArray->SetArray(&m_Indices[0], points.size() * 2, 1); > vtkCellArray->SetCells(points.size(), vtkIdTypeArray); > > 4. Create the VTK-pipeline > > vtkPolyData->SetPoints(vtkPoints); > vtkPolyData->SetVerts(vtkCellArray); > vtkPolyDataMapper->SetInputConnection(0, > vtkPolyDataMapper->vtkPolyData->GetProducerPort()); > vtkActor->SetMapper(vtkPolyDataMapper); > > 5. You can set point size through the properties of the vtkActor: > vtkActor->GetProperty()->SetPointSize(pointSize); > > This is very fast and you should be able to render millions of points at a > very high frame rate. Maybe you can even get VTK to render your points > without the need of indices... Should be possible somehow I guess. > > The points are rendered as squares which is kind of ugly. Solution: Add > mitkWorkbench to your AMD/NVidia application profiles and enable MSAA. > > Best, > Stefan > > > -----Ursprüngliche Nachricht----- > Von: Clarkson, Matt [mailto:[email protected]] > Gesendet: Mittwoch, 8. Mai 2013 15:15 > An: Engelhardt, Sandy > Cc: mitk-users > Betreff: Re: [mitk-users] Bug 14890: Very Slow Rendering of PointSets > > Please can you remind me.. when was the ITKv4 commit? > Is it possible to upgrade MITK to include 8150+14932, without ITKv4? > > However, I suspect that the problem also lies with the fact that for each > point a sphere is rendered, and the resolution is set to 20 in both latitude > and longitude. > Is there any way to litterally just render a single point for each point in > the point set? > > We are using 2 million points, and 2 million spheres is a bit ... > optimistic. :-) > > Thanks > M > > On 8 May 2013, at 13:42, "Engelhardt, Sandy" > <[email protected]> > wrote: > >> Dear Matt, >> the bug, which occurred in the latest release, has been fixed within the >> scope of bug 8150. The merge of "GenerateDataForRenderer" and "GenerateData" >> methods caused performance issues in a couple of other mappers too (see bug >> 14932). >> >> Please let us know whether you still have problems with rendering large >> pointsets. >> >> Kind regards, >> >> Sandy >> >> -----Ursprüngliche Nachricht----- >> Von: Clarkson, Matt [mailto:[email protected]] >> Gesendet: Mittwoch, 8. Mai 2013 14:13 >> An: mitk-users >> Betreff: [mitk-users] Bug 14890: Very Slow Rendering of PointSets >> >> Hi there, >> >> Does anyone have an update on this: >> http://bugs.mitk.org/show_bug.cgi?id=14890 >> >> We are running into a problem rendering large pointsets, and so would be >> REALLY interested to know if anyone had taken a look at this, or had >> suggestions. >> >> Thanks >> >> Matt >> >> >> >> --------------------------------------------------------------------- >> - >> -------- Learn Graph Databases - Download FREE O'Reilly Book "Graph >> Databases" is the definitive new guide to graph databases and their >> applications. This 200-page book is written by three acclaimed leaders in >> the field. The early access version is available now. >> >> Download your free book today! http://p.sf.net/sfu/neotech_d2d_may >> _______________________________________________ >> mitk-users mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/mitk-users >> > > > > ---------------------------------------------------------------------- > -------- Learn Graph Databases - Download FREE O'Reilly Book "Graph > Databases" is the definitive new guide to graph databases and their > applications. This 200-page book is written by three acclaimed leaders in the > field. The early access version is available now. > > Download your free book today! http://p.sf.net/sfu/neotech_d2d_may > _______________________________________________ > mitk-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/mitk-users > ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. This 200-page book is written by three acclaimed leaders in the field. The early access version is available now. Download your free book today! http://p.sf.net/sfu/neotech_d2d_may _______________________________________________ mitk-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mitk-users
