Segmented Voronoi for Rust
Boost 1.76.0 polygon::voronoi ported to 100% rust. This implementation of Fortune's algorithm works for line segments as well as points, making it useful for calculating centerlines (like the title image above).
Code still in development, there are still bugs. However, all the remaining bugs I've noticed are also present in C++ boost voronoi.
Gui example:
- Mouse click to place new points.
- Press and hold 'L' + mouse click to add a single line.
- Press and hold 'S' + mouse click to add strings of lines.
- Use mouse wheel to zoom.
- Mouse click and drag to pan.
API example:
use *;
type I = i32; // this is the integer input type
type F = f64; // this is the float output type
Edges will become curves when line segments are used as input, see the example code for discretization and interpolation.
Minimum Supported Rust Version (MSRV)
The crate is only tested on 1.56 and above.
The code uses #![feature(map_first_last)]
if run on +nightly, this is only emulated on +stable.
So +nightly should be somewhat faster.
Todo
- Try to fix the known problems in C++ Boost voronoi and port over.
- Add many more test cases for
voronoi_robust_ftp.rs
. - Benchmark and optimize.
- Replace C++ style boolean ordering functors.
- Replace builtin ulp with some rust crate (approx?).
- Take care of the
todo:
tags. - Builder pattern
- Hide implementation details with a workspace (w/o disabling doc-tests)
- Add
serde
toSyncDiagram
and other diagram types. - Specific type conversion tests (
cgmath
,glam
,mint
&geo
)
All credit goes to the original author (Andrii Sydorchuk) and the boost contributors, except the porting mistakes. They are all mine.