[vtkusers] SetCutPlane not working in vtkImageResliceMapper

David Gobbi david.gobbi at gmail.com
Wed Apr 3 08:31:41 EDT 2013


Hi Debjit,

After reading the code, I understand your situation a little bit better:
1) the 6DOF sensor controls the camera (orientation only)
2) In addition, the user sets an orientation by rotating the actor
(the vtkImageSlice is a vtk "actor", in VTK-speak, so that's what
I'll call it for the remainder of this email.)

Generally I would recommend that instead of transforming the actor
here, you have an adjustable calibration matrix that is applied to
the matrix that comes from the 6DOF sensor.  But we'll skip that
for now and consider the way you have things implemented at the
present time.

Note that the RotateX, RotateY, and RotateZ that you are applying
to the actor are used to create the actor's 4x4 matrix, which you can
retrieve by calling actor->GetMatrix().  So you shouldn't be trying to
reconstruct this matrix yourself with sines and cosines, that is very
error-prone.  Just get the matrix from the actor, and if you need just
a 3x3 matrix, then convert it into a 3x3 matrix.

Or, instead of turning the 4x4 matrix into a 3x3 matrix, you can can
turn your a normal or vector into a 4-vector like so:
 double v4[4] = { v[0], v[1], v[2], 0.0 };
and then use vtkMatrix4x4::MultiplyPoint() to transform the vector.

I still think that you need to choose a vector (in the original image
coordinate system) that you want to be "up" on the screen.  Then
multiply the vector by the actor's matrix to put in into the VTK world
coordinate system (i.e. the coordinate system of the camera and
the slice).  Then project it onto the plane, and use it as the ViewUp.

Now of course I could be mistaken or I could have misunderstood
something.  Generally when I'm working on these problems I like
to have the code, the device, and my notebook all in front of me.

I appreciate your offer, but I can't really help you any further with
this.

 - David

On Tue, Apr 2, 2013 at 1:26 PM, Debjit Ghosh <dghosh at chla.usc.edu> wrote:
> Hi David,
>
> I understand that this is an open forum and I would like to know if there is
> anything I or our division at the Children's Hospital Los Angeles could do
> in return for your much needed help.
>
> After spending a few days on the problem and your suggested solution, I have
> observed and realized that it isn't just a matter of rotating the viewup
> vector based on the orientation of the volume pinned to the vtkImageSlice
> object. That is incorrect.
>
> I request you to go over the following setup one more time:
>
> Initial Setting:
> {
> vtkImageSlice->SliceFacesCameraOn();
> vtkImageSlice->SliceAtFocalPointOn();
> vtkImageSlice->SetOrigin(dimX/2, dimY/2, 0); //so that rotation of volume is
> applied around "tip" of cone
> vtkImageSlice->RotateX(angle_x);
> vtkImageSlice->RotateY(angle_y);
> vtkImageSlice->RotateZ(angle_z);
>
> viewup = {0, 0, 1};
> default_norm = {0, 0, 1};
> //I have tried using rotation matrices to convert angle_x, angle_y, angle_z
> and multiplying it with the //viewup but that isn't the solution and I feel
> it has to do with more camera settings that just the view up. //Please NOTE
> that the origin is not {0,0,0} but the tip of the cone
> }
>
> Execute on timer using 6DOF sensor input:
> {
> vtkSmartPointer<vtkMatrix3x3> matrix = vtkSmartPointer<vtkMatrix3x3>::New();
> GetSensorOrientation(matrix);
> vtkSmartPointer<vtkCamera> cam = renderer->GetActiveCamera();
> matrix->MultiplyPoint(default_norm, normal);
>
> //Calculate the focal point
> double focalPt[3];
> double centerofvol[] = {dimX/2, dimY/2, dimZ/2};
> vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::New();
> plane->SetOrigin(dimX/2, dimY/2, 0);
> plane->SetNormal(normal);
> plane->ProjectPoint( centerofvol, focalPt );
>
> position[0] = focalPt[0] + distfromcam * this->normal[0];
> position[1] = focalPt[1] + distfromcam * this->normal[1];
> position[2] = focalPt[2] + distfromcam * this->normal[2];
>
> cam->SetPosition(position);     //Orientation of the slice plane
> cam->SetFocalPoint(focalPt);    //Point at which my plane is fixed
> cam->SetViewUp(viewup);
> }



More information about the vtkusers mailing list