[vtkusers] Rendering huge amount of polyData with 1 actor and vtkMultiBlockDataSet/vtkCompositePolyDataMapper2

Gib Bogle g.bogle at auckland.ac.nz
Fri Aug 30 03:28:44 EDT 2013


That's what I would expect, since only one actor is rendered.  If you want to 
see multiple objects you need multiple actors.

On 29/08/2013 8:41 p.m., finfanillo wrote:
> Hi all,
>
> I have a huge amount of polydata (octagons) created from a point cloud, so I
> want to render them with 1 actor, in order to save memory. I need to keep
> track of color information, which is different for every point. My code is
> something like:
>
> ////////////
>
> vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
> vtkSmartPointer<vtkUnsignedCharArray> colors =
> vtkSmartPointer<vtkUnsignedCharArray>::New();
> vtkSmartPointer<vtkPolygon> octagon = vtkSmartPointer<vtkPolygon>::New();
> vtkSmartPointer<vtkCellArray> Octagons =
> vtkSmartPointer<vtkCellArray>::New();
> vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
> vtkMultiBlockDataSet* Blocks = vtkMultiBlockDataSet::New();
>
>
> for(size_t i=0;i<point_cloud_size;++i)
> {
>     // Create and octagon for every point, using them at a central points and
> getting 8 vertices
>
>     points->InsertNextPoint(vertex_1_x[i], vertex_1_y[i], vertex_1_z[i]);
>     ...
>     points->InsertNextPoint(vertex_8_x[i], vertex_8_y[i], vertex_8_z[i]);
>
>     // Add color information to every vertex
>
>     colors->SetNumberOfComponents(3);
>     colors->SetName("Colors");
>     colors->InsertNextTupleValue(point_color[i]);
>     ...
>     colors->InsertNextTupleValue(point_color[i]); // 8 times, 1 for every
> vertex
>
>    // Create every octagon
>
>    octagon->GetPointIds()->SetNumberOfIds(8);
>    octagon->GetPointIds()->SetId(0, 0);
>    octagon->GetPointIds()->SetId(1, 1);
>    ...
>    octagon->GetPointIds()->SetId(7, 7);
>
>    Octagons->InsertNextCell(octagon);
>
>    // Create the polydatas and put it into a MultiBlockDataSet
>
>    polyData ->SetPoints(points);
>    polyData ->SetPolys(Octagons);
>    polyData ->GetPointData()->SetScalars(colors);
>
>    Blocks ->SetBlock(i+1,polyData);
>    Blocks ->Modified();
>
>    // Initialize
>
>    points->Initialize();
>    colors->Initialize();
>    octagon->Initialize();
>    Octagons->Initialize();
>    polyData->Initialize();
> }
>
> // Rendering. I guess the problem is here, but I don't know where exactly
>
> vtkSmartPointer<vtkCompositeDataGeometryFilter> geom =
> vtkSmartPointer<vtkCompositeDataGeometryFilter>::New();
>
> geom->SetInput(Blocks);
> geom->Update();
>
> vtkCompositePolyDataMapper2* mapper = vtkCompositePolyDataMapper2::New();
> mapper->SetInputConnection(0,geom->GetOutputPort(0));
>
> vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
> actor->SetMapper(mapper);
>   
> vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
> vtkSmartPointer<vtkRenderWindow> renderWindow =
> vtkSmartPointer<vtkRenderWindow>::New();
> renderWindow->AddRenderer(renderer);
> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
> vtkSmartPointer<vtkRenderWindowInteractor>::New();
> renderWindowInteractor->SetRenderWindow(renderWindow);
>   
> renderer->AddActor(actor);
>   
> renderWindow->Render();
> renderWindowInteractor->Start();
>
> ////////////////
>
> The result is that only the last polygon is rendered. Can anybody help me
> please? Thank you!
>
>
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Rendering-huge-amount-of-polyData-with-1-actor-and-vtkMultiBlockDataSet-vtkCompositePolyDataMapper2-tp5723120.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers


-- 
Dr. Gib Bogle
Senior Research Fellow
Auckland Bioengineering Institute
University of Auckland
New Zealand

http://www.bioeng.auckland.ac.nz

g.bogle at auckland.ac.nz
(64-9) 373-7599 Ext. 87030




More information about the vtkusers mailing list