[vtkusers] How to use vtkTransform with vtkImagePlaneWidget

Uril Yakubov uyakubov at rotman-baycrest.on.ca
Fri Sep 12 16:27:18 EDT 2008


Hi Dean,

Thank you very much!!!

Is it not enough to make transform just origin coordinate? Why we need
to transform point1 and point2?

I would like to make the same with the vtkImageViewer2. Should I just
call 
vtkImageViewer2  viewer
viewer->GetImageActor->RotateX(my angle) 

Thank you,

Uril.




On Thu, 2008-08-07 at 08:12 -0400, Dean Inglis wrote:
> 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
> 
> 




More information about the vtkusers mailing list