[vtkusers] mouse coordinates from a 3d volume with wrong y

Esmeralda Ruiz esmeralda.ruiz at alma3d.com
Wed Mar 20 08:55:19 EDT 2019


Dear all,
I want to get the positions of a volume using the mouse for segmentation.
But the y coordinate is wrong. I only get the x and z fine but the depth
(y) is not correct. I use this code to get the position. Is there any way
to obtain the slice (y position)

thanks


            // Get the location of the click (in window coordinates)
            int* pos = this->GetInteractor()->GetEventPosition();

            vtkSmartPointer<vtkCellPicker> picker =
                vtkSmartPointer<vtkCellPicker>::New();
            picker->SetTolerance(0.0005);


            //this->GetDefaultRenderer()->Clear();

            // Pick from this location.
            picker->Pick(pos[0], pos[1], 0, global_renderer);

            double* worldPosition = picker->GetPickPosition();
            std::cout << "Cell id is: " << picker->GetCellId() << std::endl;

            if (picker->GetCellId() != -1)
            {

                std::cout << "Pick position is: " << worldPosition[0] << "
" << worldPosition[1]
                    << " " << worldPosition[2] << endl;
            }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20190320/15f904ca/attachment.html>


More information about the vtkusers mailing list