Closed frewsxcv closed 6 months ago
I think this would be a good addition!
Some design thoughts:
Should we have a separate trait method for returning triangle indices?
Do you mean vertex indices? Otherwise I don't understand why an individual triangle would ever appear more than once.
I've only recently started doing any graphics programming, but the API I typically want is one which returns vertices and their indices - something like:
pub trait Triangulate {
// returns `(triangles, vertices)` where each `triangle` is represented
// by three indices, corresponding to its corners in `vertices`
fn triangulate(&self) -> (Vec<(usize, usize, usize)>, Vec<Coordinate>);
}
fn triangulate(&self) -> Vec<Triangle>;
Maybe better?: fn triangle_iter(&self) -> impl Iter<Item=Triangle<T>>
If we have a compressed vertex representation (as above) this might be a slightly smaller and more flexible way to store things. I'm not familiar enough with how the underlying triangulation algorithms work to know if this is actually useful though — if they're just internally building up essentially a fully expanded list of triangles, then this doesn't get us anything meaningful.
A new algorithm for triangulating geometries with areas.
Thoughts: