Is it possible to implement rubber band picking from a vtkMultiBlockDataSet using vtkExtractGeometry and an ImplicitFunction?

Hello!!!

I’ve been experimenting with picking/selection in vtk and started with picking points and cells from a vtkUnstructuredGrid using the frustum from a vtkInteractorStyleRubberBandPick style in a vtkExtractGeometry filter.

When I extend this code to use a vtkMultiBlockDataSet consisting of a hierarchy of vtkUnstructuredGrids as input, the vtkExtractGeometry filter fails to return any cells. The code fragment below works just fine when “target” is a vtkUnstructuredGrid - extract contains the cells inside the frustum. But when mesh is a vtkMultiBlockDataSet, extracted is “None”

        frustum = self.GetInteractor().GetPicker().GetFrustum()

        extract_geometry = vtk.vtkExtractGeometry()
        extract_geometry.SetImplicitFunction(frustum)
        extract_geometry.SetInputData(target)
        extract_geometry.Update()

        extracted = extract_geometry.GetOutput() 

Any guidance on how to rubber band pick from a vtkMultiBlockDataSet will be gratefully received.

Doug

You can convert multiblock data set to simple polydata using vtkCompositeDataGeometryFilter. I’m not sure if the same works for unstructured grid, too, but if not then there should be a similar filter for that, too.

Figured it out…

When using vtkExtractGeometry with a vtkMultiBlockDataSet, the output is not returned via GetOutput, but instead via GetOutputDataObject(0).

    frustum = self.GetInteractor().GetPicker().GetFrustum()

    extract_geometry = vtk.vtkExtractGeometry()
    extract_geometry.SetImplicitFunction(frustum)
    extract_geometry.SetInputData(target)
    extract_geometry.Update()

    extracted = extract_geometry.***GetOutputDataObject(0)***

All(?) of the non composite aware filters return their output this away - in a vtkMultiBlockDataSet. So all downstream operations have to be updated to access vtkMultiBlockDataSets as input.

Works pretty well when you know how!!!

Doug