我的建议是重新渲染除背景之外的所有内容。类似于以下内容
auto oldSB = renderWindow->GetSwapBuffers();
renderWindow->SwapBuffersOff();
// Hide the background (set visibility to false or whatever)
...
auto windowToImageFilter = vtkSmartPointer<vtkWindowToImageFilter>::New();
windowToImageFilter->SetInput(renderWindow);
windowToImageFilter->SetScale(1);
windowToImageFilter->SetInputBufferTypeToRGBA();
windowToImageFilter->ReadFrontBufferOff();
windowToImageFilter->Update(); // Issues a render on input
renderWindow->SetSwapBuffers(oldSB);
renderWindow->SwapBuffersOn();
// Show background again (set visibility to true or whatever)
...
auto img = windowToImageFilter->GetOutput();
下面的渲染调用将再次显示背景。