VTKVornoi2D doesn't work probably

Hello, I have two questions.

  1. I’m trying to use VTKVornoi to generate a 2D Mesh of voronoi graph, and the results is like the following picture

vtkSmartPointer poly_voronoi = vtkSmartPointer::New();
int i = 0;
while (i < 1000)
{

  points_voronoi->InsertPoint(i, rand()%800, rand()%600,0);
  i++;

}
poly_voronoi->SetPoints(points_voronoi);
cout << poly_voronoi->GetNumberOfPoints();
vornoi_2d = vtkSmartPointer::New();

vornoi_2d->SetInputData(poly_voronoi);
vornoi_2d->SetGenerateScalarsToNone();
vornoi_2d->SetGenerateScalarsToPointIds();
vornoi_2d->SetPointOfInterest(1);
vornoi_2d->SetMaximumNumberOfTileClips(10000);
vornoi_2d->GetLocator()->SetNumberOfPointsPerBucket(2);
vornoi_2d->SetGenerateVoronoiFlower(1);
vornoi_2d->Update();

vtkNew plyWriter;
plyWriter->SetFileName(“curve.obj”);
plyWriter->SetInputData(vornoi_2d->GetOutput());
plyWriter->Write();

However I’m genearating 1000 points, the results look the same, did I miss something ?

  1. I would like to cut the voronoi mesh with another 2D mesh, would VTKBoolean operation works in that purpose, or it must use a 3D Mesh instead x,y,z ?

My guess, based on the filter documentation, is that setting a point of interest is the problem:
“When the point of interest is specified (i.e., to a non-negative number) then the
algorithm will only process this single point (whose id is the PointOfInterest).”

@will.schroeder
Thanks it works now. What about the second question of Clipping a 2D mesh against a 2D mesh using vtkpolycut ?

The output of voroni2d is simply a vtkPolyData (containing convex polygons). Usually any filter that operates on vtkPolyData will work, however there are some filters that require a input triangle mesh - you may have to triangulate with vtkTriangleFilter.