[vtkusers] display tens of thousands of cubes

Bryn Lloyd lloyd at itis.ethz.ch
Tue Feb 7 11:39:06 EST 2012


Use the glyph mapper for even faster GPU rendering.

http://www.vtk.org/doc/nightly/html/classvtkGlyph3DMapper.html


On 2/7/2012 5:17 PM, David E DeMarle wrote:
>
> Use the glyph filter to make one actor with thousands of cubes.
>
> On Feb 7, 2012 11:12 AM, "Alex Southern" <mrapsouthern at gmail.com 
> <mailto:mrapsouthern at gmail.com>> wrote:
>
>     Hi,
>
>     I'm wondering what the best way to do this is?
>
>     Currently the cubes are defined in a dynamic array of
>     vtkCubeSources, see code below. This results in very slow interaction.
>
>     Is there a more lightweight approach to this problem? There is a
>     typical image below.
>
>     // Create a cube array.
>         int numCubes = 44582; // in practice this value could be anything
>         vtkCubeSource **cubeSource = new vtkCubeSource* [numCubes];
>         vtkPolyDataMapper **mapper = new vtkPolyDataMapper* [numCubes];
>         vtkActor **actor = new vtkActor* [numCubes];
>
>         for (int i = 0; i < ca.numCubes; i++)
>         {
>             cubeSource[i] = vtkCubeSource::New();
>             mapper[i] = vtkPolyDataMapper::New();
>             actor[i] = vtkActor::New();
>
>             cubeSource[i]->SetCenter(ca.cubeCentre[i].x ,
>     ca.cubeCentre[i].y, ca.cubeCentre[i].z);
>             cubeSource[i]->SetXLength(ca.cubeLength[i] );
>             cubeSource[i]->SetYLength(ca.cubeLength[i] );
>             cubeSource[i]->SetZLength(ca.cubeLength[i] );
>
>             mapper[i]->SetInputConnection(cubeSource[i]->GetOutputPort());
>             actor[i]->SetMapper(mapper[i]);
>             actor[i]->GetProperty()->SetColor(255,0,0);
>             actor[i]->GetProperty()->SetRepresentationToWireframe();
>
>             renderer->AddActor(actor[i]);
>
>         }
>
>
>
>     _______________________________________________
>     Powered by www.kitware.com <http://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
>
>
>
> _______________________________________________
> 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/20120207/7b6c3647/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 148968 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120207/7b6c3647/attachment.png>


More information about the vtkusers mailing list