[vtkusers] SetCutPlane not working in vtkImageResliceMapper

David Gobbi david.gobbi at gmail.com
Tue Oct 16 15:10:10 EDT 2012


Hi Debjit,

If you can't move the camera around in order to get the slice you
need, then you can try applying a transform to the vtkImageSlice
object instead.

When you set the SlicePlane for vtkImageResliceMapper, you are setting
the slice plane in VTK world coordinates.  And by using
vtkImageSlice::SetUserTransform() you can move and rotate your
ultrasound data volume relative to the slice plane.

 - David

On Tue, Oct 16, 2012 at 12:24 PM, Debjit Ghosh <dghosh at chla.usc.edu> wrote:
> Thanks for the explanation David. I tried it and works the way that you said
> it would. However, it messes up what I was trying to do. Allow me to explain
> and your suggestions are very valuable.
>
>
>
> I need to extract slices from a given volume as per a position and
> orientation of a cut plane and display the image on the center of the screen
> - just like we would see on the screen in ultrasonography as we move the
> probe around.
>
>
>
> Have I been going about the wrong way using the ImageResliceMapper? Or is
> there a simpler way of going about it?
>
>
>
> Thanks.
>
>
>
>
>
> From: David Gobbi [via VTK] [mailto:ml-node+[hidden email]]
> Sent: Monday, October 15, 2012 1:58 PM
>
>
> To: Ghosh, Debjit
> Subject: Re: SetCutPlane not working in vtkImageResliceMapper
>
>
>
> Just a short addendum to my last email, that might make the
>
> SliceFacesCamera option easier to understand.
>
> When SliceFacesCamera and SliceAtFocalPoint are on, the
> vtkImageResliceMapper will automatically set the SlicePlane
> to the focal plane.  The "focal plane" is the plane that faces
> the camera and passes through the focal point.  In other words,
> setting the camera's FocalPoint sets the "Origin" of the slice
> plane, and moving the camera's Position relative to the focal
> point controls the "Normal" of the slice plane.  The slice is
> always facing the camera.
>
>  - David
>
> On Mon, Oct 15, 2012 at 2:23 PM, David Gobbi <[hidden email]> wrote:
>
>
>> Hi Debjit,
>>
>> If you want to "slap it to the screen" then you need to use
>> SliceFacesCameraOn instead of using the vtkPlane to control the
>> slicing.
>>
>> With SliceFacesCameraOn, you can control the slicing by changing the
>> pose of the camera (i.e. by changing the Position, FocalPoint, and
>> ViewUp).  With SliceFacesCameraOn, you cannot change the slicing with
>> the vtkPlane (because SliceFacesCameraOn overrides the vtkPlane).
>> However, from what you are trying to do, it sounds like
>> SliceFacesCameraOn + camera positioning is a much better way for you
>> to control the slicing than with the vtkPlane.
>>
>>  - David
>>
>>
>> On Mon, Oct 15, 2012 at 11:56 AM, Debjit Ghosh <[hidden email]> wrote:
>>> Thank you very much. You are right!
>>>
>>>
>>>
>>> So I turned SliceFacesCamera Off and it SetSlicePlane with a vtkPlane
>>> object. Now, though the corresponding slice has been extracted, there are
>>> two issues that I face, that I would appreciate your advice on,
>>> immensely.
>>>
>>>
>>>
>>> - The image is getting visualized as a plane slanted in 3D space which I
>>> had
>>> to move with Shift + LeftMousePressed to align - How do I slap it onto
>>> the
>>> screen so it is straight?
>>>
>>> - I was updating the normal in a Timer and incrementing it to test
>>> whether I
>>> can do this dynamically and it took effect only the first time
>>>
>>>
>>>
>>> Perhaps it's due to my lack of experience in 3D slicing but these are the
>>> updates that I have tried calling:
>>>
>>>
>>>
>>>                TimerEvent()
>>>
>>>                {
>>>
>>>                                              vtkSmartPointer<vtkPlane>
>>> slicePlane = vtkSmartPointer<vtkPlane>::New();
>>>
>>>                                              slicePlane =
>>> resliceMapper->GetSlicePlane();
>>>
>>>
>>> slicePlane->Print(std::cout);
>>>
>>>                                              x+=0.01; y +=0.01; z+=0.01;
>>>
>>>                                              slicePlane->SetNormal(x, y,
>>> z);
>>>
>>>                                              slicePlane->SetOrigin(103.5,
>>> 111.5, 175.5);
>>>
>>>
>>> resliceMapper->SetSlicePlane(slicePlane);
>>>
>>>
>>>
>>>                                              resliceMapper->Modified();
>>>
>>>
>>> imageSlice->Render(renderer);
>>>
>>>
>>>
>>>                                              renderer->ResetCamera();
>>>
>>>                                              interactor->Modified();
>>>
>>>                                              interactor->Render();
>>>
>>>                }
>>>
>>>
>>>
>>> Basically, I have tried all the possible updates that I could :| But in
>>> vain. Could you please advise which update needs to be called?
>>>
>>>
>>>
>>> Thank you!
>>>
>>>
>>>
>>>
>>>
>>> From: David Gobbi [via VTK] [mailto:ml-node+[hidden email]]
>>>
>>> Sent: Friday, October 12, 2012 5:23 PM
>>> To: Ghosh, Debjit
>>> Subject: Re: SetCutPlane not working in vtkImageResliceMapper
>>>
>>>
>>>
>>> Hi Debjit,
>>>
>>> You probably have SliceFacesCamera turned on for the mapper.  This
>>> will override any plane that you set manually.
>>>
>>> If you are using SliceFacesCamera and SliceAtFocalPoint, then the way
>>> to change the slice is by changing the camera's position and focal
>>> point.
>>>
>>>  - David
>>>
>>>
>>> On Fri, Oct 12, 2012 at 6:01 PM, Debjit Ghosh <[hidden email]> wrote:
>>>> I have been facing an issue where I called the SetSlicePlane(vtkPlane*)
>>>> with
>>>> a normal and/or an origin but the visualization didn't change. I had
>>>> called
>>>> the interactor->Render(), called the Modified() on the
>>>> ImageResliceMapper
>>>> but neither made the difference.
>>>>
>>>> It would be great if someone could tell me what I am missing here.



More information about the vtkusers mailing list