[vtkusers] ImageReslice question - Grad student in need of graduation!

Romuald BERTRAND beromuald at wanadoo.fr
Fri May 2 02:54:21 EDT 2008


Hi Ken,

Maybe this can help you
==>  http://devsample.org/index.php?option=com_content&task=view&id=48&Itemid=27

Bye
 
 
 

> Message du 01/05/08 23:41
> De : "Ken Urish" 
> A : vtkusers at vtk.org
> Copie à : 
> Objet : [vtkusers] ImageReslice question - Grad student in need ofgraduation!
> 
> Help!
> 
> Ive been stuck on this for a while now. I am viewing a 3d dicom image
> slice by slice based off teh the "ImageReslice1.cxx" example with teh
> imageReslice class.
> I am trying to pick 3d points on the image. I can pick x,y points
> fine. BUt I have no way to figure out where I am on teh z-axis.
> 
> Ive been having trouble so Ive just been trying to get the program to
> output the z-slice I am on when I hit a right mouse click. It give me
> a number that does not change and is incorrect.
> 
> I threw an actor into the callback to see if I could call "GetZSlice"
> but this always gives me a "0". Similarly if I try to see my bounds or
> set bounds off the actor, nothing works. Ive lost a week on this
> really simple step and it driving me up the wall.
> 
> 
> Thanks
> --Ken--
> 
> 
> The code for the callback is below.
> 
> 
> // The mouse motion callback, to turn "Slicing" on and off
> class vtkImageInteractionCallback : public vtkCommand
> {
> public:
> 
>   static vtkImageInteractionCallback *New() {
>     return new vtkImageInteractionCallback; };
> 
>   vtkImageInteractionCallback() {
>     this->Slicing = 0;
>     this->ImageReslice = 0;
>     this->Interactor = 0; };
> 
>   void SetImageReslice(vtkImageReslice *reslice) {
>     this->ImageReslice = reslice; };
> 
>  void SetACtor(vtkImageActor *actor) {
>      this->Actor = actor; };
> 
>   vtkImageReslice *GetImageReslice() {
>     return this->ImageReslice; };
> 
>   vtkImageActor *GetImageActor() {
>     return this->Actor; };
> 
> 
>   void SetInteractor(vtkRenderWindowInteractor *interactor) {
>     this->Interactor = interactor; };
> 
>   vtkRenderWindowInteractor *GetInteractor() {
>     return this->Interactor; };
> 
>   virtual void Execute(vtkObject *, unsigned long event, void *)
>     {
>     vtkRenderWindowInteractor *interactor = this->GetInteractor();
> 
>     int lastPos[2];
>     interactor->GetLastEventPosition(lastPos);
>     int currPos[2];
>     interactor->GetEventPosition(currPos);
> 
>     if (event == vtkCommand::LeftButtonPressEvent)
>       {
>       this->Slicing = 1;
>       }
>     else if (event == vtkCommand::LeftButtonReleaseEvent)
>       {
>       this->Slicing = 0;
>       }
>     else if (event == vtkCommand::MouseMoveEvent)
>       {
>       if (this->Slicing)
>         {
>         vtkImageReslice *reslice = this->ImageReslice;
> 
>         // Increment slice position by deltaY of mouse
>         int deltaY = lastPos[1] - currPos[1];
> 
>         reslice->GetOutput()->UpdateInformation();
>         double sliceSpacing = reslice->GetOutput()->GetSpacing()[2];
>         vtkMatrix4x4 *matrix = reslice->GetResliceAxes();
>         // move the center point that we are slicing through
>         double point[4];
>         double center[4];
>         point[0] = 0.0;
>         point[1] = 0.0;
>         point[2] = sliceSpacing * deltaY;
>         point[3] = 1.0;
>         matrix->MultiplyPoint(point, center);
>         matrix->SetElement(0, 3, center[0]);
>         matrix->SetElement(1, 3, center[1]);
>         matrix->SetElement(2, 3, center[2]);
>         int z = actor->GetZSlice();
>         interactor->Render();
>         }
>       else
>         {
>         vtkInteractorStyle *style = vtkInteractorStyle::SafeDownCast(
>           interactor->GetInteractorStyle());
>         if (style)
>           {
>           style->OnMouseMove();
>           }
>         }
>       }
>     };
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080502/ea9eeb36/attachment.htm>


More information about the vtkusers mailing list