[vtkusers] Getting Original 3d Point co-ordinate on mouse hover

mahendra mahendra123awale at gmail.com
Tue Apr 2 12:30:17 EDT 2013


Dear All,

Can some one guide me as how i can get the original 3d co-ordinates of
points on mouse over. I have approx 1 million 3d point which i rendered
using vtk. Now when i move mouse over the panel i would like to know the
original 3d co-ordinates of the corresponding point under mouse cursor.
Anyone has any idea how i can accomplished this? The Java code for rendering
is given below:

//READ xyz File
        BufferedReader br = new BufferedReader(new FileReader(args[0]));
        vtkPoints points = new vtkPoints();
        vtkCellArray vtkCellArray = new vtkCellArray();
        vtkUnsignedCharArray Colors = new vtkUnsignedCharArray();
        Colors.SetNumberOfComponents(3);
        Colors.SetName("Colors");

        String str;
        while ((str = br.readLine()) != null) {
            String s[] = str.split(" ");
            int id = points.InsertNextPoint(Float.valueOf(s[0]),
Float.valueOf(s[1]), Float.valueOf(s[2]));
            vtkCellArray.InsertNextCell(1);
            vtkCellArray.InsertCellPoint(id);
            
            int r=Integer.valueOf(s[3]);            
            int g=Integer.valueOf(s[4]);            
            int b=Integer.valueOf(s[5]);
            Colors.InsertNextTuple3(r, g, b);            
        }
        
        br.close();
        vtkPolyData polydata = new vtkPolyData();
        polydata.SetPoints(points);
        polydata.GetPointData().SetScalars(Colors);
        polydata.SetVerts(vtkCellArray);
        points.Delete();
        vtkCellArray.Delete();


        vtkPolyDataMapper mapper = new vtkPolyDataMapper();
        mapper.SetInput(polydata);

       
//======================================================================
        vtkActor myActor = new vtkActor();
        myActor.SetMapper(mapper);
        myActor.GetProperty().SetPointSize(8);

       
//======================================================================
        vtkRenderer ren1 = new vtkRenderer();
        ren1.AddActor(myActor);
        ren1.SetBackground(0, 0, 0);

        vtkRenderWindow renWin = new vtkRenderWindow();
        renWin.AddRenderer(ren1);
        renWin.SetSize(300, 300);

        ren1.ResetCamera();
        ren1.GetActiveCamera().Azimuth(90);

        vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow(renWin);

        vtkInteractorStyleTrackballCamera style =
                new vtkInteractorStyleTrackballCamera();
        iren.SetInteractorStyle(style);
        
        iren.Initialize();
        iren.Start();

//====================================================================================

Thanks for help!





--
View this message in context: http://vtk.1045678.n5.nabble.com/Getting-Original-3d-Point-co-ordinate-on-mouse-hover-tp5719771.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list