# vtkVoronoi2D doesn't work with simple cube

**URL:** https://discourse.vtk.org/t/vtkvoronoi2d-doesnt-work-with-simple-cube/10169
**Category:** Support
**Created:** [December 12, 2022, 9:19pm UTC](https://discourse.vtk.org/t/vtkvoronoi2d-doesnt-work-with-simple-cube/10169 "2022-12-12T21:19:52Z")
**Posts on this page:** 2
**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 12, 2022, 9:19pm UTC](https://discourse.vtk.org/t/vtkvoronoi2d-doesnt-work-with-simple-cube/10169/1 "2022-12-12T21:19:52Z")

</div>

Hello,  
I’m reading an obj file “cube” which is a simple cube, and would like to project voronoi diagram on it.  
I’ve tried the following code, but it either crashes, or it stays in infinite loop.

Kindly find the attached cube file also and sample code

```auto
vtkSmartPointer<vtkOBJReader> reader =
		vtkSmartPointer<vtkOBJReader>::New();
	reader->SetFileName("untitled.obj");
	reader->Update();
	
	cout << reader->GetOutput()->GetNumberOfPoints();

	vornoi_2d = vtkSmartPointer<vtkVoronoi2D>::New();

	vornoi_2d->SetInputData(reader->GetOutput());
	vornoi_2d->SetGenerateScalarsToNone();
	vornoi_2d->SetGenerateScalarsToPointIds();
	vornoi_2d->SetPointOfInterest(-1);
	vornoi_2d->SetMaximumNumberOfTileClips(50);
	vornoi_2d->GetLocator()->SetNumberOfPointsPerBucket(15);
	//vornoi_2d->SetGenerateVoronoiFlower(1);
	vornoi_2d->Update();

	vtkNew<vtkOBJWriter> plyWriter;
	cout << vornoi_2d->GetOutput()->GetNumberOfPoints();
	cout << vornoi_2d->GetOutput()->GetNumberOfCells();

	plyWriter->SetFileName("final_vornoi.obj");
	plyWriter->SetInputData(vornoi_2d->GetOutput());
	plyWriter->Write();

```

[untitled.obj](https://discourse.vtk.org/uploads/short-url/7u3mCcwdVobySNR84HzOkoRrxQz.obj) (939 Bytes)

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dcthomp/32/60_2.png) [@dcthomp](https://discourse.vtk.org/u/dcthomp)
#### Post date: [December 13, 2022, 2:09am UTC](https://discourse.vtk.org/t/vtkvoronoi2d-doesnt-work-with-simple-cube/10169/2 "2022-12-13T02:09:10Z")

</div>

The 2D Voronoi algorithm expects planar input on the plane z=0.

You might try the 3D version and extract the surface geometry from the result.
