# VTKVornoi2D doesn't work probably

**URL:** <https://discourse.vtk.org/t/vtkvornoi2d-doesnt-work-probably/10138>\
**Category:** Development\
**Created:** [December 9, 2022, 2:04pm UTC](https://discourse.vtk.org/t/vtkvornoi2d-doesnt-work-probably/10138 "2022-12-09T14:04:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndreAhmed](https://discourse.vtk.org/user_avatar/discourse.vtk.org/andreahmed/32/6061_2.png) [@AndreAhmed](https://discourse.vtk.org/u/AndreAhmed)\
**Post date:** [December 9, 2022, 2:04pm UTC](https://discourse.vtk.org/t/vtkvornoi2d-doesnt-work-probably/10138/1 "2022-12-09T14:04:40Z")

</div>

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

 ![image](https://discourse.vtk.org/uploads/default/original/2X/9/908d52b3fee43e942a6bf8418b28977b2fb36214.jpeg)

> 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 ?

---

<div class="post-metadata">

**Author:** ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)\
**Post date:** [December 9, 2022, 2:10pm UTC](https://discourse.vtk.org/t/vtkvornoi2d-doesnt-work-probably/10138/2 "2022-12-09T14:10:25Z")

</div>

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).”

---

<div class="post-metadata">

**Author:** ![AndreAhmed](https://discourse.vtk.org/user_avatar/discourse.vtk.org/andreahmed/32/6061_2.png) [@AndreAhmed](https://discourse.vtk.org/u/AndreAhmed)\
**Post date:** [December 9, 2022, 2:50pm UTC](https://discourse.vtk.org/t/vtkvornoi2d-doesnt-work-probably/10138/3 "2022-12-09T14:50:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)\
**Post date:** [December 9, 2022, 3:41pm UTC](https://discourse.vtk.org/t/vtkvornoi2d-doesnt-work-probably/10138/4 "2022-12-09T15:41:37Z")

</div>

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.
