Voronoi tessellation in a cylinder
Voronoi tessellation in a cylinder (See example)

A general overview

Voro++ is a open source software library for the computation of the Voronoi diagram, a widely-used tessellation that has applications in many scientific fields. While there are other software packages available to carry out these computations, Voro++ is written in way that makes it particularly suited for certain applications. Three main design features are:

The structure of the code makes it particularly well-suited to many problems in physics and materials science, where Voronoi cells can be a useful method of analyzing particle packings. However, the library is also used in many other fields, including biological modeling, mesh generation, and computer graphics.


In addition to the C++ routines for carrying out the Voronoi tessellation, Voro++ has a number of other features:

A single cell with degenerate vertices
A single cell with degenerate vertices (See example)

C++ code structure

The code is structured around several C++ classes. The voronoicell class contains all of the routines for constructing a single Voronoi cell. It represents the cells as a collection of vertices that are connected by edges. To compute the Voronoi cell, it is first initialized as a large rectangular box filling the domain, and is then repeatedly cut with planes that correspond to the perpendicular bisectors between on point and its neighbors. The plane function will recompute the cell after cutting with a single plane. Once the cell is computed, it can be drawn using functions such as draw_gnuplot and draw_pov. Numerous routines exist for computing features of the cell, like its surface area, volume, or centroid.

The container class represents a 3D rectangular box of particles. The constructor for this class sets up the coordinate ranges, sets whether each direction is periodic or not, and divides the box into a rectangular grid of blocks. Particles can be added to the container using the put function, that adds a particle's position and an integer numerical ID label, to the container by adding it to the corresponding block. The function import can be used to read in large numbers of particles from a text file.

The Voronoi computations are carried out by the voro_compute template. This class contains a function called compute_cell, which can analyze the particles in an associated container class to create a single Voronoi cell for a particle in the container. Various functions utilize calls to compute_cell to carry out analyses of the particle arrangement.

The radical Voronoi tessellation is handled by the container_poly class, which is a variant of the container class, where the put function accepts an additional argument for the particle radius. Neighbor computations are carried out using the voronoi_neighbor class, which is a variant of voronoicell that has additional data structures for associating the IDs of neighboring particles with each Voronoi cell face. These variants are created by exploiting C++ templates.

Wall computations are handled by making use of a pure virtual wall class. Specific wall types are derived from this class, and have a routine called point_inside that tests to see if a point is inside a wall or not, and a routine called cut_cell that cuts a cell according to the wall's position. The walls can be added to the container using the add_wall function, and these are called each time a compute_cell function is carried out. The library contains a number of other small helper classes, such as c_loop classes that allow the computation routines to iterate over a specific subset of particles within a container.


Voro++ is written and maintained by Chris H. Rycroft, a visiting assistant professor in mathematics at UC Berkeley and the Lawrence Berkeley Laboratory. A preliminary version of the code was written at MIT during 2005–2006 to carry out local packing fraction computations during doctoral thesis work on flow in granular materials. After receiving feedback from a number of different research groups, the code was completely rewritten and extended during 2007–2008, to allow it to be publicly released during Summer 2008.