#mesh #graphics #graph #half #edge

half_edge_mesh

A basic implementation of the half-edge mesh data structure. It has a bunch of the functions you probably want in a half-edge mesh, but probably not all of them. I’m intending to add more methods and mutation techniques, as I need them for other projects or as I think of them. Pull requests welcome!

7 stable releases

1.1.8 Aug 30, 2018
1.0.8 Sep 27, 2016
1.0.7 Aug 3, 2016
1.0.6 Jun 10, 2016
1.0.3 Mar 27, 2016

#155 in Data structures

44 downloads per month
Used in 1 crate

MIT license

57KB
1K SLoC

Half-Edge Mesh

This is an implementation of the half-edge mesh data structure in Rust. Suggestions and pull requests welcome!

The most notable implementation detail is that links to other parts of the mesh (of which there are many) are Option<Weak<RefCell<T>>>. This is in order to allow the references to be initialized to null, then set later during mutation methods. Since a half-edge mesh is a graph with many cycles, and some circular references, the entities require null references at some point during initialization (due to the circular references). I believe this implementation is the only way to construct this kind of structure within Rust's borrowing system, short of using raw pointers and unsafe code everywhere. I suppose that in the far future, I could refactor this project to use raw pointers for performance.

Currently, this data structure is built with mathematical primitives from cgmath. Vectors are cgmath::Vector3<f32>, and points are cgmath::Point3<f32>. This makes the API somewhat simpler, since it doesn't need to be type-parameterized for primitive types. It would be possible to refactor out this dependency at some point in the future.

Dependencies

~1MB
~16K SLoC