[vtkusers] Set position of vtkImageSlice

David Doria daviddoria at gmail.com
Tue Nov 13 16:32:36 EST 2012


On Tue, Nov 13, 2012 at 4:24 PM, David Lonie <david.lonie at kitware.com>wrote:

> Sorry for the noise -- message got sent too early last time...
>
> Hi list,
>
> I'm writing a test for some new functionality that will generate
> several vtkImageData instances and render them at different positions.
>
> I'm setting up a vtkImageSlice like this:
>
> vtkNew<vtkImageData> image1;
> // Generate image...
> vtkNew<vtkImageSliceMapper> mapper1;
> mapper1->SetInputData(image1.GetPointer());
> vtkNew<vtkImageSlice> actor1;
> actor1->SetMapper(mapper1.GetPointer());
> actor1->SetPosition(10, 10, 10);
>
> then adding the actor to the renderer as usual. The docs for vtkImageSlice
> say:
>
> "Prop3D methods such as SetPosition() and RotateWXYZ() change the
> position and orientation of the data with respect to VTK world
> coordinates."
>
> Trouble is, no matter what I set the position of the actor to, the
> image appears in the center of the scene. Is this expected behavior?
> Is there a better class to use for this sort of thing?
>
> Thanks,
>
> Dave


I would imagine a ResetCamera() is getting called somewhere after you add
the image (which I believe "looks at" the center of the bounding box of all
of the actors in the scene). Try adding something else to the scene (say a
sphereSource->GetOutput()) at (0,0,0) and see if you image is in the
correct position relative to that. If so, then we'll have to figure out how
to suppress that ResetCamera() call.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121113/57438de3/attachment.htm>


More information about the vtkusers mailing list