C
The public C API is split across two single-header files:
jc_voronoi.hgenerates and traverses Voronoi diagrams and Delaunay adjacency.jc_voronoi_clip.hadds a ready-made clipper for convex polygons.
Both headers are C99-compatible and can be included from C++. They allocate no
caller-visible objects: callers provide input arrays and output structures, while
the generated diagram owns its internal storage until jcv_diagram_free is called.
Typical lifecycle
- Zero-initialize a
jcv_diagram. - Generate a full Voronoi diagram with
jcv_diagram_generate, or adjacency only withjcv_delaunay_generate. - Read sites, vertices, and edges through the accessors and iterators.
- Call
jcv_diagram_freeexactly once when finished.
jcv_diagram diagram = {0};
jcv_diagram_generate(num_points, points, NULL, NULL, &diagram);
/* Read diagram data here. */
jcv_diagram_free(&diagram);Pointers returned by the API and pointers stored in edge values belong to the diagram. They become invalid when that diagram is regenerated or freed.
Last updated on