[vtkusers] How to use vtkTransform with vtkImagePlaneWidget

Dean Inglis dean.inglis at sympatico.ca
Thu Aug 7 08:12:31 EDT 2008


Hi Uril,

 

If you look at the doxygen documentation for this class,

you will see that you can recover the center and normal of the plane,

GetCenter GetNormal, as well as the three points defining a pair of 

orthonormal axes corresponding to its bottom and left side edges:

GetOrigin, GetPoint1, GetPoint2.  vtkTransform can be used

to rotate those points around the plane normal, 

as long as you know the origin of the image data that it slices through:

 

vtkImagePlaneWidget widget  

widget->GetPoint1(pt1);

widget->GetPoint2(pt2);

widget->GetOrigin(wo);

widget->GetNormal(n);

 

vtkImageData image

image->GetOrigin(io);

 

vtkTransform transform

// may have to be transform->PreMultiply() or transform->PostMultiply() here
. I always forget

transform->Translate(io);

transform->RotateWXYZ(angle,n[0], n[1], n[2]);

transform->Translate(-io[0], -io[1], -io[2]);

 

 

vtkPoints points

points->InsertNextPoint(pt1);

points->InsertNextPoint(pt2);

points->InsertNextPoint(wo);

 

vtkPoints newpoints

 

transform->TransformPoints(points,newpoints);

 

widget->SetPoint1(newpoints->GetPoint(0));

widget->SetPoint2(newpoints->GetPoint(1));

widget->SetOrigin(newpoints->GetPoint(2));

widget->UpdatePlacement();

 

 

 

Dean

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080807/a70a8694/attachment.htm>


More information about the vtkusers mailing list