[vtkusers] vtkImageReslice axes direction, based on a vtkPlane
David Gobbi
david.gobbi at gmail.com
Thu Sep 22 11:20:15 EDT 2011
Hi Timjen,
The vtkImageSlice class is a vtkProp3D, so the only way to view the
slice like a 2D image is to move the camera into the right position.
So you will need to write some code that will set the camera
orientation from the normal of your plane. It isn't that hard to do,
just follow these steps:
1) call camera->ParallelProjectionOn(), you don't want perspective in a 2D view
2) call camera->SetParallelScale(100), use the image size in place of 100
3) call renderer->ResetCamera() to automatically set the camera focal point
4) use the following code to set the view:
double focalPoint[3];
double camPosition[3];
double camDistance = camera->GetDistance();
camera->GetFocalPoint(focalPoint);
camPosition[0] = focalPoint[0] + camDistance*normal[0];
camPosition[1] = focalPoint[1] + camDistance*normal[1];
camPosition[2] = focalPoint[2] + camDistance*normal[2];
camera->SetPosition(position);
camera->SetViewUp(0,1,0); // whatever "up" should be
renderer->ResetCameraClippingRange();
Use SetParallelScale() to change the magnification and
use SetViewUp() to change the rotation around the normal.
The ResampleToScreenPixels() doesn't do what you think.
It is just a quality setting.
I can't answer about the vtkShader2 object, the slice rendering does
not use shaders.
- David
On Thu, Sep 22, 2011 at 5:03 AM, Tijmen Klein <T.R.Klein at student.rug.nl> wrote:
> Hi David,
> This is exactly what I was looking for, thank you! Got the newest VTK
> version from git, compiled it and modified my program
> (using http://vtk.org/gitweb?p=VTK.git;a=blob;f=Examples/ImageProcessing/Python/ImageInteractorReslice.py as
> an example). vtkImageResliceMapper really makes a world of difference, and
> makes the slicing a lot easier.
> However, there is still one small issue for me. I would like to display this
> slice as if it was a 2D image. Would you have an idea how to do this? If I
> simply add the vtkImageSlice to my renderer, it shows up at the exact
> location of the cut (which is to be expected). I could set the camera
> position + focal point based on the origion and normal of the cutting plane,
> but I would like the slice to fill the whole viewport. The
> method ResampleToScreenPixelsOn() seems to be designed to do this, using
> this however does not change a thing for me.
> Cheers,
> Tijmen
>
> On Wed, Sep 21, 2011 at 5:06 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>
>> Hi Tijmen,
>>
>> If you are able to grab the devel version of VTK from git, your
>> best option is to use the new image rendering classes:
>> http://www.vtk.org/Wiki/VTK/Image_Rendering_Classes
>> The vtkImageResliceMapper has a method called SetSlicePlane(),
>> so all you have to do is set the image as the input, then set the
>> plane you want to slice with. The mapper will do everything else.
>>
>> - David
>>
>>
>> On Wed, Sep 21, 2011 at 3:42 AM, Tijmen Klein <T.R.Klein at student.rug.nl>
>> wrote:
>> > Hello Everyone,
>> > I have a volume that I cut off using a vtkPlane
>> > (volume->AddClippingPlane()), which works really well. But sometimes I
>> > also
>> > need to show to cut itself. First I tried to use a vtkCutter for this,
>> > the
>> > geometry of the output is fine, but the texture is incorrect.
>> > So I'm now used a vtkImageReslice, which gives the desired output.
>> > However,
>> > the textured plane of the output does not always cover the whole area of
>> > the
>> > vtkCutter. For example, see this
>> > image: http://dl.dropbox.com/u/27566470/slice_and_cut.png The red bar
>> > indicates the geometry of the vtkCutter, the blue plane is the slice of
>> > the
>> > vtkImageReslice.
>> > How can I make sure that the output of vtkImageReslice covers the whole
>> > vtkCutter? I have the feeling that my current method is too complex. I
>> > want
>> > an output that is equal to the output of creating a slice in Paraview.
>> > Cheers,
>> > Tijmen
>
>
More information about the vtkusers
mailing list