About draw a cylindeical ring , use boolean operation

I want to use boolean operations to draw a cylinder ring:

  1. create two cylinder,
  2. use vtkTrianglefilters,
  3. and then Boolean operations,

but why is that?

code:

// Function to create a cylinder
vtkSmartPointer<vtkPolyData> CreateCylinder(double radius, double height)
{
    auto cylinderSource = vtkSmartPointer<vtkCylinderSource>::New();
    cylinderSource->SetCenter(0, 0, 0);
    cylinderSource->SetRadius(radius);
    cylinderSource->SetHeight(height);
    cylinderSource->SetResolution(100); // Controls smoothness of the circle
    cylinderSource->Update();

    auto triangFilter = vtkSmartPointer<vtkTriangleFilter>::New();
    triangFilter->SetInputData(cylinderSource->GetOutput());
    triangFilter->Update();

    return triangFilter->GetOutput();
}

int main(int, char*[])
{
    // Outer cylinder (the larger one)
    auto outerCylinder = CreateCylinder(2, 1);

    // Inner cylinder (the smaller one to subtract)
    auto innerCylinder = CreateCylinder(1, 1);

    // Boolean filter to subtract inner cylinder from the outer one
    auto booleanFilter = vtkSmartPointer<vtkBooleanOperationPolyDataFilter>::New();
    booleanFilter->SetOperationToUnion();
    booleanFilter->SetInputData(0, outerCylinder);
    booleanFilter->SetInputData(1, innerCylinder);
    booleanFilter->Update();

    // Mapper and actor for the resulting ring
    auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
    mapper->SetInputData(booleanFilter->GetOutput());
    mapper->ScalarVisibilityOff();

    auto actor = vtkSmartPointer<vtkActor>::New();
    actor->SetMapper(mapper);
    actor->GetProperty()->EdgeVisibilityOn();

    ....
}


Refer to: What’s the problem? Somebody help me - Support - VTK

Perhaps, you could use implicit functions instead, two vtkCylinder and two vtkPlane. Here I used two vtkCylinder and 4 vtkSphere