This code allows the construction of bounded 3D Voronoi diagrams inside an arbitrary polytope.
Given a set of seeds, the code first constructs the corresponding Delaunay triangulation using an iterative insertion flipping algorithm. Next, the dual Voronoi diagram is extracted. It is implemented in such a way that the Voronoi diagram is automatically bounded inside a specified polytope.
In the following example, we see how the code has been used to generate secondary pulmonary lobules inside a lung geometry.
The most high-level interface is in voronoi.h. The main function is construct_vd_from_txt. It reads the bounding polyhedron's coordinates from a .txt file, and generates inside of it a set of random seeds using the method of Poisson disc sampling with a user specified sizing function (local minimum distance between points). The output is the corresponding Voronoi diagram structure (vd_3d.h).
If the user needs to specify the seeds manually, they shall use lower-level already implemented functions.
Source for the Delaunay algorithm: Computing the 3D Voronoi Diagram Robustly: An Easy Explanation. Hugo Ledoux. Adaptive precision arithmetic: Adaptive Precision Floating-Point Arithmetic and Fast Robust Predicates for Computational Geometry. Jonathan Richard Shewchuk.