[vtkusers] Problem with vtkPolyDataMapper

Bill Lorensen bill.lorensen at gmail.com
Tue Apr 12 11:57:11 EDT 2011


It should work as you expect. Something else is going on. Can you post a
small, compilable example that illustrates the problem?

Bill

On Mon, Apr 11, 2011 at 11:18 AM, Pascal Augustin <pascal at rogue-research.com
> wrote:

> Hi,
>
> Let's assume I have two actors with exactly the same shape. To avoid
> creating the vtkPolyData and vtkPolyDataMapper twice, I decided to let both
> actors share the same vtkPolyDataMapper.
>
> vtkSmartPointer<vtkPolyDataMapper> sphereMapper = ...
>
>
> // Sphere
> vtkSmartPointer<vtkActor> sphereActor1 = ...
> sphereActor1->SetMapper(sphereMapper);
>
> // Sphere
> vtkSmartPointer<vtkActor> sphereActor2 = ...
> sphereActor2->SetMapper(sphereMapper);
>
>
> // Cube
> vtkSmartPointer<vtkPolyDataMapper> cubeMapper = ...
> vtkSmartPointer<vtkActor> cubeActor = ...
> cubeActor->SetMapper(cubeMapper);
>
> I was expecting sphereActor1 and sphereActor2 to be displayed as spheres
> while cubeActor would be a cube. Here is what I sometimes get:
>
> sphereActor1 ---> sphere
> sphereActor2 --> sphere
> cubeActor ---> *** sphere***
>
> The cubeActor seems to be using the shereMapper. It has the correct
> position, color, scale, etc. Only the shape is wrong.
>
> I can avoid this problem by doing this:
> sphereMapper->ImmediateModeRenderingOn();
>
> Doing a shallowCopy also seems to prevent that bug from happening:
> vtkSmartPointer<vtkPolyDataMapper> sphereMapper1
> = vtkSmartPointer<vtkPolyDataMapper>::New();
> sphereMapper1->ShallowCopy(sphereMapper);
> sphereActor1->SetMapper(sphereMapper1);
>
> Am I missing something? Can multiple actors safely share the same mapper?
>
> Thanks!
>
> I am using VTK 5.7 on Mac OS X 10.6.7.
>
> ______________________
> Pascal Augustin
> Rogue Research Inc.
> Montreal (Quebec), Canada
> www.rogue-research.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/20110412/bb3767d7/attachment.htm>


More information about the vtkusers mailing list