I made a mistake when using vtkBooleanOperationPolyDataFilter。
ERROR: In E:\VTKLib\VTK-8.2.0\Common\DataModel\vtkPointLocator.cxx, line 866
vtkPointLocator (0x15aa4068): No points to subdivide
Generic Warning: In E:\VTKLib\VTK-8.2.0\Filters\General\vtkIntersectionPolyDataFilter.cxx, line 2516
No Intersection between objects
ERROR: In E:\VTKLib\VTK-8.2.0\Filters\General\vtkDistancePolyDataFilter.cxx, line 78
vtkDistancePolyDataFilter (0x159f4600): No points/cells to operate on
ERROR: In E:\VTKLib\VTK-8.2.0\Filters\General\vtkDistancePolyDataFilter.cxx, line 78
vtkDistancePolyDataFilter (0x159f4600): No points/cells to operate on
This is my code。
auto cylinder = vtkSmartPointer::New();
cylinder->SetCenter(0,0,0);
cylinder->SetHeight(5);
cylinder->SetRadius(3);
cylinder->Update();
auto cylinder1 = vtkSmartPointer<vtkCylinderSource>::New();
cylinder1->SetCenter(0,0,0);
cylinder1->SetHeight(10);
cylinder1->SetRadius(2);
cylinder1->Update();
auto booleanOperation = vtkSmartPointer<vtkBooleanOperationPolyDataFilter>::New();
booleanOperation->SetOperationToUnion();
booleanOperation->SetInputData(0,cylinder->GetOutput());
booleanOperation->SetInputData(1,cylinder1->GetOutput());
booleanOperation->Update();
auto appendMapper = vtkSmartPointer::New();
appendMapper->SetInputData(booleanOperation->GetOutput());
auto actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(appendMapper);
actor->GetProperty()->SetOpacity(0.4);
auto renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(actor);
auto window = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();
window->AddRenderer(renderer);