[vtkusers] VtkResliceImageViewer cordinate system (world and display)

sfaisalali91 sfaisal.ali91 at gmail.com
Tue Nov 20 08:51:17 EST 2018


Hey Guys,

  Can someone please help me with understanding of display cordinates and
world cordinates on the image plane represented in vtkResliceImageViewer.

I am trying to add a node(restricted to a particular slice) on sagittal view
and replicate the same on coronal and axial views , based on others opinions
i tried two approaches , 


*1) using vtkCordinate*

int pickPosition[2];
vtkRenderWindowInteractor *rwi = dynamic_cast< vtkRenderWindowInteractor *
>(caller);
rwi->GetEventPosition(pickPosition);

vtkSmartPointer<vtkCoordinate> coordinate =
vtkSmartPointer<vtkCoordinate>::New();
coordinate->SetCoordinateSystemToDisplay();
coordinate->SetValue(pickPosition[0], pickPosition[1], 0);
			
double* world =
coordinate->GetComputedWorldValue(this->RIW[0]->GetRenderer());
int* Display =
coordinate->GetComputedDisplayValue(this->RIW[0]->GetRenderer());
std::cout << "Mouse World coordinate: " << world[0] << ", " << world[1] <<
", " << world[2] << std::endl;
std::cout << "Mouse Display coordinate: " << Display[0] << ", " <<
Display[1] << ", " << Display[2] << std::endl;


*2) using vtkPropPicker*

vtkImageActor* actor = this->RIW[0]->GetImageActor();
vtkSmartPointer<vtkPropPicker> m_propPicker =
vtkSmartPointer<vtkPropPicker>::New();
m_propPicker->PickFromListOn();
m_propPicker->AddPickList(actor);
this->RIW[0]->GetImageActor()->InterpolateOff();
m_propPicker->Pick(pickPosition[0], pickPosition[1], 0.0,
this->RIW[0]->GetRenderer());

vtkAssemblyPath* path = m_propPicker->GetPath();
bool validPick = false;
if (path)
{
  vtkCollectionSimpleIterator sit;
  path->InitTraversal(sit);
  vtkAssemblyNode *node;
  for (int i = 0; i < path->GetNumberOfItems() && !validPick; ++i)
 {
   node = path->GetNextNode(sit);
   if (actor == vtkImageActor::SafeDownCast(node->GetViewProp()))
   {validPick = true;}
 }
}
 if (!validPick){return;}

double pos[3];
m_propPicker->GetPickPosition(pos);
std::cout << "Picker World coordinate: " << pos[0] << ", " << pos[1] << ", "
<< pos[2] << std::endl;
		

I am able to achieve the conversion from display to world, but there is a
shift in points when visualized in other two views, to fix this i
implemented the logic below. I believe that always first slice cordinates
are being considered rather than the current slice. 


int image_coordinate[3];
int axis = this->RIW[0]->GetSliceOrientation();
switch (axis)
{
   case vtkImageViewer2::SLICE_ORIENTATION_XZ:
   image_coordinate[0] = vtkMath::Round(pos[0]);
   image_coordinate[1] = this->RIW[1]->GetSlice();
   image_coordinate[2] = vtkMath::Round(pos[2]);
   break;
   
   case vtkImageViewer2::SLICE_ORIENTATION_YZ:
   image_coordinate[0] =
(this->RIW[0]->GetSliceMax())-(this->RIW[0]->GetSlice());
   image_coordinate[1] = vtkMath::Round(pos[1]);
   image_coordinate[2] = vtkMath::Round(pos[2]);
   break;

   default:  // vtkImageViewer2::SLICE_ORIENTATION_XY
   image_coordinate[0] = vtkMath::Round(pos[0]);
   image_coordinate[1] = vtkMath::Round(pos[1]);
   image_coordinate[2] = this->RIW[2]->GetSlice();
   break;
}


Still no luck, please can someone guide me with what have i been missing in
this logic!? 
*Note* - Reslice cursor widget is disabled in all views.*


Thank you for the help in advance. 

Regards 
Syed Faisal Ali





--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list