[vtkusers] fast visualization of polygons

Jeff Lee jeff at cdnorthamerica.com
Wed Jan 23 08:32:12 EST 2002


A faster version would probably use vtkPolyData instead of 
vtkUnstructuredGrid.  Also, I'm guessing that "slower" means building 
time, not rendering time.  In that case, If you know the structure of 
your polygons (points, attributes, cell-types...) and if your data 
structures are right, you could set them in one step using 
vtkPolyData->SetPoints(...), vtkPolyData->SetLines(...), 
vtkPolyData->SetPolys(...).  You can basically wrap vtk around your data 
(assuming the data is stored in a compacted array format).  This 
basically bypasses the slower insert methods.  Also, the method 
described below is about as slow as you can get - using an append 
filter.  You could just use vtkPolyData's InsertNextCell() method.  If 
your requirement is to add cells one at a time, then GL has the least 
overhead.
-Jeff

Prof. Andreas Gerber wrote:

>How can I display a lot of individual polygons very fast. I use somthing like 
>this to add polygons to the scene:
>
>        polygon = vtkPolygon()
>        polygon.GetPointIds().SetNumberOfIds(numpoints)
>        for p in range(numpoints):
>            polygon.GetPointIds().SetId(p,p)
>
>        polygonGrid = vtkUnstructuredGrid()
>        polygonGrid.Allocate(1,1)
>        polygonGrid.InsertNextCell(polygon.GetCellType(),  
>        polygon.GetPointIds())        
>        polygonGrid.SetPoints(points)
>
>        self.M.append(vtkDataSetMapper())
>        self.M[-1].SetInput(polygonGrid)
>
>The mappers are appended to a vtkAppendFilter. 
>
>In comparison to a program which uses GL this solution is fairly slow. 
>
>
>Andreas 
>_______________________________________________
>This is the private VTK discussion list. 
>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers
>
>





More information about the vtkusers mailing list