How to make empty space in vtkPolyData?

I want to create an empty space in one plane.

Each plane is made up of hexagons, and one plane contains the other and has a larger shape.

I tried to find the difference using vtkBooleanOperationPolyData, but I couldn’t find it.

How can I create an empty space on the plane?

vtkPoints points1 = vtkPoints.New();
vtkPoints points2 = vtkPoints.New();
// each vtkPoints has coordinates of hexagon

vtkPolygon polygon1 = vtkPolygon.New();
vtkPolygon polygon2 = vtkPolygon.New();
polygon1.GetPointIds().SetNumberOfIds(points1.GetNumberOfPoints());
for (int pointNum = 0; pointNum < points1.GetNumberOfPoints(); pointNum++)
    polygon1.GetPointIds().SetId(pointNum, pointNum);
polygon2.GetPointIds().SetNumberOfIds(points2.GetNumberOfPoints());
for (int pointNum = 0; pointNum < points2.GetNumberOfPoints(); pointNum++)
    polygon2.GetPointIds().SetId(pointNum, pointNum);

vtkCellArray polygons1 = vtkCellArray.New();
vtkCellArray polygons2 = vtkCellArray.New();
polygons1.InsertNextCell(polygon1);
polygons2.InsertNextCell(polygon2);

vtkPolyData polygonPolyData1 = vtkPolyData.New();
vtkPolyData polygonPolyData2 = vtkPolyData.New();
polygonPolyData1.SetPoints(points1);
polygonPolyData1.SetPolys(polygons1);
polygonPolyData2.SetPoints(points2);
polygonPolyData2.SetPolys(polygons2);

vtkBooleanOperationPolyDataFilter boPolyFilter = vtkBooleanOperationPolyDataFilter.New();
boPolyFilter.AddInputData(0, polygonPolyData1);
boPolyFilter.AddInputData(1, polygonPolyData2);
boPolyFilter.SetOperationToIntersection();
boPolyFilter.Update();

I am getting an error when updating boPolyFilter.

The error I get is:

ERROR: vtkPointLocator.cxx, line 845
vtkPointLocator (0000020A67105AC0): No points to subdivide

Generic Warning: vtkIntersectionPolyDataFilter.cxx, line 2410
No Intersection between objects

ERROR: vtkDistancePolyDataFilter.cxx, line 82
vtkDistancePolyDataFilter (0000020A66F83650): No points/cells to operate on

ERROR: vtkDistancePolyDataFilter.cxx, line 82
vtkDistancePolyDataFilter (0000020A66F83650): No points/cells to operate on

The vtkBooleanOperation expect watertight meshes defining a volume. If you want to cut your plane you may want to look at the vtkClipPolyData class.

Thank you.

But, with vtkClipPolyData the plane is gone.

I want to erase as much as the small white hexagons from the red big hexagons.

vtkPolyLine polyLine = vtkPolyLine.New();
polyLine.Initialize(Convert.ToInt32(points2.GetNumberOfPoints()), points2);

vtkPolyPlane polyPlane = vtkPolyPlane.New();
polyPlane.SetPolyLine(polyLine);

vtkClipPolyData clipPolyData = vtkClipPolyData.New();
clipPolyData.SetInputData(polygonPolyData1);
clipPolyData.SetClipFunction(polyPlane);
clipPolyData.InsideOutOn();
clipPolyData.Update();

image