[vtkusers] Re: vtkPointPicker - position identification problem

George Kamucha kamucha at hfm.e-technik.uni-kassel.de
Wed Oct 9 08:36:50 EDT 2002


Hi
Thanks a lot for testing the code. Now that it works in your system and not in
mine, I am left even more confused. All my hairs are now gone.
I have written the same code in tcl and it works fine and so I think it is not a

problem with hardware (I have a Matrox Millenium G400 graphic card). But I need
the code in C++ for compatibility with the inferfacing program based on QT. Is
it my vtk which is not in order (I use vtk 3.1)? Any suggestion would  be highly

appreciated.
George

"Gopalakrishnan, Gowri" wrote:

"Gopalakrishnan, Gowri" wrote:

> Hello
>
> I just tried your code and I do not see the problem you see.
> When I click on a point I see the glyph sphere you put (in blue). The sphere
> appears when you press the letter p. It appears immediately. Only it appears
> little above the mouse position.
> (Also I used your code with one of my vtk files. )
> I clicked three different points and I get three blue spheres. So there is
> nothing wrong with your code. It could come from hardware (may be , I am not
> sure). But I can guarantee that your code is correct and your update is
> fine.
>
> Gowri
>
> -----Original Message-----
> From: George Kamucha [mailto:kamucha at hfm.e-technik.uni-kassel.de]
> Sent: 09 October 2002 09:16
> To: Jeff Lee; vtkusers at public.kitware.com
> Subject: [vtkusers] Re: vtkPointPicker - position identification problem
>
> Hi Jeff,
> I have tried before to use renWin->Render() after the pick (within the
> function pickControl, as
> shown in the snippet below) but the problem still persists. Or am I not
> doing it in the right
> way?
>
> Regards
> George
>
> static void pickControl(void *);
>
> static vtkRenderer *ren1;
>
> static vtkRenderWindow *renWin;
>
> void main( int argc, char *argv[] )
>
> {
>
> // create pipeline
> vtkPolyDataReader *reader = vtkPolyDataReader::New();
>       reader->SetFileName ("../../../vtkdata/Bone_CTNewdrR.vtk");
>       reader->Update();
>
> vtkPolyDataMapper *dataMapper = vtkPolyDataMapper::New();
>       dataMapper->SetInput(reader->GetOutput());
>       dataMapper->ScalarVisibilityOff();
>
> vtkActor *dataActor = vtkActor::New();
>        dataActor->SetMapper(dataMapper);
>        dataActor->GetProperty()->SetColor(0.5, 0.5, 1);
>        dataActor->GetProperty()->SetOpacity(0.5);
>
> vtkPointPicker *pointpicker = vtkPointPicker::New();
>
> ren1 = vtkRenderer::New();
> renWin = vtkRenderWindow::New();
>     renWin->AddRenderer(ren1);
>   vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>     iren->SetRenderWindow(renWin);
>     iren->SetPicker(pointpicker);
>     iren->SetEndPickMethod(pickControl, (void *)iren);
>
> ren1->AddActor(dataActor);
>
> // render the image
>     ren1->SetBackground(1, 1, 1);
>     renWin->SetSize(500,500);
>     iren->Initialize();
>     renWin->Render();
>     iren->Start();
>
> //Clean up
>
> ren1->Delete();
> renWin->Delete();
> iren->Delete();
> reader->Delete();
> dataMapper->Delete();
> dataActor->Delete();
> pointpicker->Delete();
>
>  }
>
> // Define picking method
>
> static void pickControl(void *arg)
> {
> float *selPt;
> float *pickpos;
>
> vtkRenderWindowInteractor *iren = (vtkRenderWindowInteractor *)arg;
>   vtkPointPicker *pointpicker = (vtkPointPicker *)iren->GetPicker();
>
>   selPt = pointpicker->GetSelectionPoint();
>
>     cout<<"Screen location:"<<selPt[0]<<" "<<selPt[1]<<"\n";
>
>  if ( pointpicker->GetPointId() >= 0 )
>     {
>     pickpos = pointpicker->GetPickPosition();
>
>     cout<<"Point location:"<<pickpos[0]<<" "<<pickpos[1]<<"
> "<<pickpos[2]<<"\n";
>
> //Define method for placing spheres
> vtkPoints *points=vtkPoints::New();
>        points-> InsertNextPoint(pickpos);
>        points-> Modified();
>
> vtkPolyData *profile=vtkPolyData::New();
>    profile->SetPoints(points);
>
> vtkSphereSource *sphere=vtkSphereSource::New();
>   sphere->SetRadius(2);
>
> vtkGlyph3D *glyph=vtkGlyph3D::New();
>     glyph->SetInput(profile);
>     glyph->SetSource(sphere->GetOutput());
>
> vtkPolyDataMapper *glyphMapper=vtkPolyDataMapper::New();
>      glyphMapper->SetInput(glyph->GetOutput());
>
> vtkActor *glyphActor=vtkActor::New();
>   glyphActor->SetMapper(glyphMapper);
>   glyphActor->GetProperty()->SetColor(0, 0, 1);
>
> ren1-> AddActor(glyphActor);
>
> renWin->Render();
>
> points-> Delete();
> profile->  Delete();
> sphere->  Delete();
> glyph->  Delete();
> glyphMapper->  Delete();
> glyphActor->  Delete();
>    }
>    else
>    {
>          cout<<"No point picked here!"<<"\n";
>    }
>
> }
>
> Jeff Lee wrote:
>
> > Do you render after the pick?
> > -Jeff
> >
> > George Kamucha wrote:
> >
> > >Hi all,
> > >I am selecting points on a surface using vtkPointPicker, and then placing
> small
> > >spheres in the selected locations. The problem I am facing is that, when
> I
> > >select the first location,  a sphere is not immediately placed there
> until a
> > >second location is selected. That is, I can only see the position of the
> > >previously selected location and not the current one. I have checked the
> > >archives but have not found anything related to my problem. If anybody
> has an
> > >idea on this issue, please bail me out before I lose all my hair :).
> Below is
> > >the snippet.
> > >
> > >Best regards
> > >George
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers

--
=======================================
George Kamucha
Fachgebiet Hochfrequenztechnik(FB 16),
Universitaet Kassel,
Wilhelmshoeher Allee 73,
34121 Kassel, Germany.
__________________________________________________________________________
Phone : +49 -561-804 6528 (Office); +49 -561-870 5662 (Resi.)
Fax   : +49 -561-804 6529 (Office)

__________________________________________________________________________





More information about the vtkusers mailing list