vtkExtractSelection with empty vtkSelection uninformative error message

Hi,
I would like to suggest an improvement in vtkExtractSelection because I had some difficulty understanding a bug in my software:
if vtkExtractSelection is updated but the vtkSelection used as inputData is empty (no vtkSelectionNode), an error is displayed in the console.
Two suggestions:

  • the behavior should not trigger an error, and just not extract anything with no error message
  • If the current behavior is needed for some reason, at least the message in the console should report the real issue (no vtkSelectionNode in the vtkSelection) instead of this:
    2025-07-23 18:59:54.470 ( 0.001s) [ 2E83B780]vtkExtractSelection.cxx:201 ERR| vtkExtractSelection (0x6172983bff30): Selection has selection nodes with inconsistent field types. 2025-07-23 18:59:54.470 ( 0.001s) [ 2E83B780] vtkExecutive.cxx:752 ERR| vtkCompositeDataPipeline (0x6172983c08e0): Algorithm vtkExtractSelection(0x6172983bff30) returned failure for request: vtkInformation (0x6172983c12a0) Debug: Off Modified Time: 388 Reference Count: 1 Registered Events: (none) Request: REQUEST_DATA FROM_OUTPUT_PORT: 0 ALGORITHM_AFTER_FORWARD: 1 FORWARD_DIRECTION: 0

To reproduce the issue, just get ExtractSelection example and either remove the selection.AddNode(selectionNode); (line 54) or add selection->RemoveAllNodes(); (in line 55)

The message comes from vtkExtractSelection::RequestData because the call to vtkExtractSelection::GetAttributeTypeOfSelection sets the parameter sane to false if the vtkSelection has no nodes.

There might be a good reason for this error being triggered by an empty vtkSelection, but if the message was improved it might save some debugging time for others !
Thanks !

That sounds fine to me, please open a MR to change that behavior.

I am using VTK 9.1 from Ubuntu 24.04, but it seems that the current vtk already has a fix for this, which checks the number of nodes. I suppose using the current vtk should solve this issue.
Thanks !