'VTK: Why vtkBooleanOperationPolyDataFilter can not dectect intersection between a plane and a sphere

I want to make an intersection with a plane and a sphere with vtkBooleanOperationPolyDataFilter, but it tells me there is no intersection between two objects even though the two objects are intersected. Could anyone explain to me why?

the code is here:

#include <vtkActor.h>
#include <vtkBooleanOperationPolyDataFilter.h>
#include <vtkCleanPolyData.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkPlaneSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
#include <vtkTriangleFilter.h>

#include <vtkBYUReader.h>
#include <vtkOBJReader.h>
#include <vtkPLYReader.h>
#include <vtkPolyDataReader.h>
#include <vtkSTLReader.h>
#include <vtkXMLPolyDataReader.h>

#include <vtkSphereSource.h>
#include <vtksys/SystemTools.hxx>

int main(int argc, char* argv[]) {
  vtkSmartPointer<vtkPolyData> input1;
  vtkSmartPointer<vtkPolyData> input2;

  vtkNew<vtkSphereSource> sphereSource1;
  sphereSource1->SetCenter(-0.15, 0, 0);
  sphereSource1->SetPhiResolution(20);
  sphereSource1->SetThetaResolution(20);
  sphereSource1->Update();
  input1 = sphereSource1->GetOutput();

  vtkNew<vtkPlaneSource> plane;
  plane->SetXResolution(100);
  plane->SetYResolution(100);
  plane->SetOrigin(-1, -1, 0);
  plane->SetPoint1(1, -1, 0);
  plane->SetPoint2(-1, 1, 0);
  plane->Update();
  input2 = plane->GetOutput();

  vtkNew<vtkNamedColors> colors;

  vtkNew<vtkPolyDataMapper> input1Mapper;
  input1Mapper->SetInputData(input1);
  input1Mapper->ScalarVisibilityOff();
  vtkNew<vtkActor> input1Actor;
  input1Actor->SetMapper(input1Mapper);

  vtkNew<vtkPolyDataMapper> input2Mapper;
  input2Mapper->SetInputData(input2);
  input2Mapper->ScalarVisibilityOff();
  vtkNew<vtkActor> input2Actor;
  input2Actor->SetMapper(input2Mapper);

  vtkNew<vtkBooleanOperationPolyDataFilter> booleanOperation;
  booleanOperation->SetOperationToIntersection();
  booleanOperation->SetInputData(0, input1);
  booleanOperation->SetInputData(1, input2);

  vtkNew<vtkPolyDataMapper> booleanOperationMapper;
  booleanOperationMapper->SetInputConnection(booleanOperation->GetOutputPort());
  booleanOperationMapper->ScalarVisibilityOff();

  vtkNew<vtkActor> booleanOperationActor;
  booleanOperationActor->SetMapper(booleanOperationMapper);

  vtkNew<vtkRenderer> renderer;
  renderer->AddActor(booleanOperationActor);
  renderer->AddActor(input2Actor);
  renderer->AddActor(input1Actor);
  renderer->SetBackground(colors->GetColor3d("Silver").GetData());
  vtkNew<vtkRenderWindow> renderWindow;
  renderWindow->AddRenderer(renderer);
  renderWindow->SetSize(640, 480);
  renderWindow->SetWindowName("BooleanOperationPolyDataFilter");

  vtkNew<vtkRenderWindowInteractor> renWinInteractor;
  renWinInteractor->SetRenderWindow(renderWindow);

  renderWindow->Render();
  renWinInteractor->Start();

  return EXIT_SUCCESS;
}

This image shows the two objects are intersected:

enter image description here

This is the debug log of vtk saying the two objects are not intersected:

ERROR: In C:\Users\micha\Documents\vtk\Common\DataModel\vtkPointLocator.cxx, line 845
vtkPointLocator (000001AE26DA9270): No points to subdivide

Generic Warning: In C:\Users\micha\Documents\vtk\Filters\General\vtkIntersectionPolyDataFilter.cxx, line 2410
No Intersection between objects 

ERROR: In C:\Users\micha\Documents\vtk\Filters\General\vtkDistancePolyDataFilter.cxx, line 81
vtkDistancePolyDataFilter (000001AE26F75FF0): No points/cells to operate on

ERROR: In C:\Users\micha\Documents\vtk\Filters\General\vtkDistancePolyDataFilter.cxx, line 81
vtkDistancePolyDataFilter (000001AE26F75FF0): No points/cells to operate on


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source