[vtkusers] Accessing the original IDs of selected points in vtkPolyData or vtkUnstructuredGrid

Zoltan Kovacs Zoltan.Kovacs at esi-group.com
Mon Nov 5 10:35:31 EST 2018


Dear All,

I try to access the ID list of nodes which are selected in a grid. Based on the example
https://lorensen.github.io/VTKExamples/site/Cxx/Picking/HighlightSelectedPoints/
I copied the
class InteractorStyle : public vtkInteractorStyleRubberBandPick
{...}

from the example to catch mouse events. In the function calling the member functions of this class
I have the code

...

  vtkSmartPointer<vtkUnstructuredGrid> grid             = vtkSmartPointer<vtkUnstructuredGrid>::New();
 vtkSmartPointer<vtkPolyData>                polydata     = vtkSmartPointer<vtkPolyData>::New();
  vtkSmartPointer<vtkPoints>                     points         = vtkSmartPointer<vtkPoints>::New();

...
filling 'points' with points from a point list
...

    grid->SetPoints(points);
    polydata->SetPoints(points);

    mapper->SetInputData(grid);
    actor->SetMapper(mapper);

    renderer->AddActor(actor);
    renderer->ResetCamera();

    renderWindowInteractor->SetPicker(picker);
    interactorStyle->SetPoints(polydata);
    renderWindowInteractor->SetInteractorStyle(interactorStyle);

This code can render the nodes from the grid and let one select nodes from the polydata via the rubber band picker. However, when I insert a vtkIdFilter and a vtkSurfaceFilter in the pipeline to save the original node IDs and use them in the selection, the selection does not work:

..

  vtkSmartPointer<vtkUnstructuredGrid> grid   = vtkSmartPointer<vtkUnstructuredGrid>::New();
 vtkSmartPointer<vtkPolyData>                polydata     = vtkSmartPointer<vtkPolyData>::New();
 vtkSmartPointer<vtkIdFilter>                    idFilter     = vtkSmartPointer<vtkIdFilter>::New();
  vtkSmartPointer<vtkSurfaceFilter>          surfaceFilter     = vtkSmartPointer<vtkSurfaceFilter>::New();
  vtkSmartPointer<vtkPoints>                      points = vtkSmartPointer<vtkPoints>::New();

...
filling 'points' with points from a point list.
...

    grid->SetPoints(points);
    polydata->SetPoints(points);

    idFilter->SetInputData(polydata);
    idFilter->SetIdsArrayName("OriginalIds");
    idFilter->Update();

    surfaceFilter->SetInputConnection(idFilter->GetOutputPort());
    surfaceFilter->Update();

    vtkPolyData *input        = surfaceFilter->GetOutput();

    mapper->SetInputData(grid);
    actor->SetMapper(mapper);

    renderer->AddActor(actor);
    renderer->ResetCamera();

    renderWindowInteractor->SetPicker(picker);
    interactorStyle->SetPoints(input);
    renderWindowInteractor->SetInteractorStyle(interactorStyle);

The code still renders the nodes from the grid but the rubber band picking does not select nodes from polydata -> idFilter -> surfaceFilter -> input. Is there any simple way to access the selected node IDs from vtkPolyData?  Or, even better, from vktUnstructuredGrid instead of vtkPolyData? Thanks a lot!

Kind regards,
Zoltan


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20181105/cd72a1e8/attachment.html>


More information about the vtkusers mailing list