How to silently handle warnings and error messages from vtk functions / classes

This is an easy fix. Just fix it ? :slight_smile:

Just fix it. That’s easy for you to say.

I’ve looked at the code and can’t come up with anything because of all the inheritance and other slight of hand that takes place.

For instance, I’ve discovered that vtkIntersectionPolyDataFilter is a class that vtkBooleanOperationPolyDataFilter uses where the 1st error occurs. I’ve traced this to the SplitSecondOutputOn function call. But, I can’t find that function anywhere in the source code; so, I can’t see where or how the return value is set or otherwise interpreted. I’m stuck.

I think @mwestphal was saying that while it should be fixed it won’t be so simple in practice.

It’s because macros are used in VTK which expand to functions

  vtkGetMacro(SplitSecondOutput, vtkTypeBool);
  vtkSetMacro(SplitSecondOutput, vtkTypeBool);
  vtkBooleanMacro(SplitSecondOutput, vtkTypeBool);

Okay, I understand about the macros; these weren’t as complicated as I thought. I see where the names were “expanded” in this case.

So, I thought vtkBooleanOperationPolyDataFilter invoking vtkBooleanOperationPolyDataFilter’s SplitSecondOutputOn function, which just sets a boolean to true, was causing vtkBooleanOperationPolyDataFilter’s RequestData function to be called, but it is not. Must be the Update call.

This leads to the next question, which I hope makes sense. Can an Update be triggered in the pipeline without an explicit call to do so? (Not knowing about all of the inheritance makes me wonder about this.)

Can an Update be triggered in the pipeline without an explicit call to do so?

Yes. For example, a vtkRenderWindow::Render() method has the side effect of bringing the actor’s mapper up to date, which typically means updating the visualization pipeline.

Here is one approach:

// Redirect error messages to a file
vtkSmartPointer<vtkFileOutputWindow> fow = vtkSmartPointer<vtkFileOutputWindow>::New();
fow->SetFileName("testfile.txt");
vtkOutputWindow::SetInstance(fow);

Then after a difficult operation (in my case, vtkArrayCalculator), you can check testfile.txt to see if it got larger.