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

Berk Geveci berk.geveci at kitware.com
Thu Sep 5 06:59:32 EDT 2013


I am confused. Why wouldn't you use 1 vtkPolyData for the whole thing? You
can add multiple polygons each with their own points to 1 vtkPolyData. I am
not sure why the last block is being rendered in this case but what you are
doing will have a large memory overhead because each vtkPolyData object
uses a decent amount of memory for various internal data structures.

Best,
-berk


On Thu, Aug 29, 2013 at 4:41 AM, finfanillo <esteban.vidal at huawei.com>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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130905/a746a978/attachment.htm>


More information about the vtkusers mailing list