[vtkusers] Getting point value on picking besides the coordinates
abhinay
abhinaynagpal at gmail.com
Sun Nov 21 11:31:09 EST 2010
Hi David
Thanks a bunch
However none of them give me the data value
Picking pixel: 259 238 259
Picked value: 0 0 0
Thats all i keep on getting 0 0 0 instead of th input values
Thanks and best regards
abhinay
"Stanford beats Cal!!"
On Sun, Nov 21, 2010 at 5:37 AM, David Doria-2-3 [via VTK] <
ml-node+3274314-1328040372-144542 at n5.nabble.com<ml-node%2B3274314-1328040372-144542 at n5.nabble.com>
> wrote:
> On Sat, Nov 20, 2010 at 9:49 PM, abhinay <[hidden email]<http://user/SendEmail.jtp?type=node&node=3274314&i=0>>
> wrote:
>
> >
> > HI
> >
> > I have a vtkwidget which i am using to show k means clustering in 3d , I
> am
> > stuck with getting the value of the point which was clicked I am just
> able
> > to get the value of the pixel. Here is what I do
> >
> >
> > vtkSmartPointer<vtkPoints> points =
> > vtkSmartPointer<vtkPoints>::New();
> >
> > points->InsertNextPoint ( 0.0, 0.0, 0.0 );
> > points->InsertNextPoint ( 3.0, 3.0, 3.0 );
> > points->InsertNextPoint ( 0.1, 0.1, 0.1 );
> > .
> > .
> >
> > //get the points into the format needed for KMeans
> > vtkSmartPointer<vtkTable> inputData =
> > vtkSmartPointer<vtkTable>::New();
> >
> >
> >
> > //display
> >
> > vtkSmartPointer<vtkVertexGlyphFilter> glyphFilter =
> > vtkSmartPointer<vtkVertexGlyphFilter>::New();
> > glyphFilter->SetInputConnection(polydata->GetProducerPort());
> > glyphFilter->Update();
> >
> > //Create a mapper and actor
> > vtkSmartPointer<vtkPolyDataMapper> mapper =
> > vtkSmartPointer<vtkPolyDataMapper>::New();
> > mapper->SetInputConnection(glyphFilter->GetOutputPort());
> >
> > vtkSmartPointer<vtkActor> actor =
> > vtkSmartPointer<vtkActor>::New();
> > actor->SetMapper(mapper);
> > actor->GetProperty()->SetPointSize(3);
> >
> > //Create a renderer, render window, and interactor
> > vtkSmartPointer<vtkRenderer> renderer =
> > vtkSmartPointer<vtkRenderer>::New();
> > vtkSmartPointer<vtkRenderWindow> renderWindow =
> > vtkSmartPointer<vtkRenderWindow>::New();
> > renderWindow->AddRenderer(renderer);
> > vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
> > vtkSmartPointer<vtkRenderWindowInteractor>::New();
> > renderWindowInteractor->SetRenderWindow(renderWindow);
> >
> >
> >
> > renderer->AddActor(actor);
> >
> > vtkSmartPointer<MouseInteractorStylePP> style =
> > vtkSmartPointer<MouseInteractorStylePP>::New();
> > renderWindowInteractor->SetInteractorStyle( style );
> >
> > Now in the mouse interactor I have the following :
> >
> > class MouseInteractorStylePP : public vtkInteractorStyleTrackballCamera
> > {
> > public:
> > static MouseInteractorStylePP* New();
> > vtkTypeMacro(MouseInteractorStylePP,
> vtkInteractorStyleTrackballCamera);
> >
> > MouseInteractorStylePP()
> > {
> > this->SelectedMapper = vtkSmartPointer<vtkDataSetMapper>::New();
>
> > this->SelectedActor = vtkSmartPointer<vtkActor>::New();
> > this->SelectedActor->SetMapper(SelectedMapper);
> > }
> >
> > virtual void OnLeftButtonDown()
> > {
> > std::cout << "Picking pixel: " <<
> > this->Interactor->GetEventPosition()[0] << " " <<
> > this->Interactor->GetEventPosition()[1]<< " " <<
> > this->Interactor->GetEventPosition()[2] << std::endl;
> >
> >
> this->Interactor->GetPicker()->Pick(this->Interactor->GetEventPosition()[0],
>
> > this->Interactor->GetEventPosition()[1],
> > this->Interactor->GetEventPosition()[2], //
> always
> > zero.
> >
> > this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
>
> > double picked[3],data;
> > this->Interactor->GetPicker()->GetPickPosition(picked);
> > std::cout << "Picked value: " << picked[0] << " " << picked[1] << "
> "
> > << picked[2] << std::endl;
> >
> > how do i get the polydata value associated with this pixel at the
> time
> > of the click?
> >
> > ====
> >
> > Am i supposed to do something like th following? (and how?)
> >
> > vtkSmartPointer<vtkVertexGlyphFilter> glyphFilter =
> > vtkSmartPointer<vtkVertexGlyphFilter>::New();
> >
> > glyphFilter->SetInputConnection(extractGeometry->GetOutputPort());
> > glyphFilter->Update();
> >
> > vtkPolyData* selected = glyphFilter->GetOutput();
> > std::cout << "Selected " << selected->GetNumberOfPoints() << "
> > points." << std::endl;
> > std::cout << "Selected " << selected->GetNumberOfCells() << "
> > cells." << std::endl;
> > this->SelectedMapper->SetInput(selected);
> >
> >
> > Please advise
> >
> > Thanks and best regards
> > abhinay
>
> Take a look at these examples:
>
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/PointPicker
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/WorldPointPicker
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/MoveAVertex
>
> David
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
> ------------------------------
> View message @
> http://vtk.1045678.n5.nabble.com/Getting-point-value-on-picking-besides-the-coordinates-tp3274056p3274314.html
> To unsubscribe from Getting point value on picking besides the coordinates,
> click here<http://vtk.1045678.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3274056&code=YWJoaW5heW5hZ3BhbEBnbWFpbC5jb218MzI3NDA1Nnw5OTU2ODM5Njg=>.
>
>
--
View this message in context: http://vtk.1045678.n5.nabble.com/Getting-point-value-on-picking-besides-the-coordinates-tp3274056p3274443.html
Sent from the VTK - Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101121/717a7b24/attachment.htm>
More information about the vtkusers
mailing list