[vtkusers] How put many sphers in to one actor?

David E DeMarle dave.demarle at kitware.com
Wed Sep 9 09:41:11 EDT 2009


It is much better to use a glyphs for this. Make a vtkPolyData or
vtkUnstructuredGrid with the vertices, and optionally a scalar array if you
want to vary the size of the spheres. Then make one sphere source and apply
the Glyph filter. The glyph filter will instantaite a copy of the sphere at
every point, and size each according to the scalar array content for that
particular vertex. This way you pay the overhead of having the mapper and
actor only once instead of thousands of times.

David E DeMarle
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x109


On Wed, Sep 9, 2009 at 9:27 AM, Arkadiusz Zychewicz <oczykota at gmail.com>wrote:

> Hi,
>   i must create many sphers (~10000) but almost all is same. Now i make
> one aktor for one sphere, it's no working fine.
>
> My code:
>        for (int i = 0; i < P->size(); i++) {
>            //utworzenie obiektu reprezentujacego linie w vtk
>            vtkSphereSource* zrodlo = vtkSphereSource::New();
>            Punkt* pp = P->at(i);
>            zrodlo->SetCenter(pp->x, pp->y, pp->z);
>            zrodlo->SetRadius(0.06);
>            //utworzenie odpowiedniego mappera i przypisanie go do
> wlasciwej linii
>            vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
>            mapper->SetInputConnection(zrodlo->GetOutputPort());
>            //utworzenie aktora i przypisanie do niego odpowiedniego mappera
>            vtkActor *aktor = vtkActor::New();
>            aktor->SetMapper(mapper);
>            aktor->GetProperty()->SetColor(cR, cG, cB);
>            //dodanie aktora na scene.
>            render->AddActor(aktor);
>       }
>
> How put all sphers int one actor?
>
> A.
> _______________________________________________
> 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/20090909/e72cfde8/attachment.htm>


More information about the vtkusers mailing list