[vtkusers] display tens of thousands of cubes

David E DeMarle dave.demarle at kitware.com
Tue Feb 7 11:17:02 EST 2012


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> 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
>
> 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/19554007/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/19554007/attachment.png>


More information about the vtkusers mailing list