6 releases
(3 breaking)

tri-mesh

A triangle mesh data structure including basic operations.

Why another triangle mesh data structure crate you might ask.
Well, if you want a more feature complete crate than half_edge_mesh and a less generic crate than plexus,
then tri-mesh is probably something for you!

I want to stitch two meshes together, how do I do that?

usetri_mesh::prelude::*;fnmain(){// Construct two meshesletmut mesh1 =MeshBuilder::new().cube().build().unwrap();letmut mesh2 =MeshBuilder::new().cube().build().unwrap();
mesh2.translate(vec3(0.5,0.5,0.5));// Split the two meshes at their intersection creating two sets of sub mesheslet(mut meshes1,mut meshes2)= mesh1.split_at_intersection(&mut mesh2);// Choose two sub meshes to merge (here we just choose one sub mesh from each of the original meshes)letmut result = meshes1.first().unwrap().clone();
result.merge_with(meshes2.first().unwrap()).unwrap();}

How can I use tri-mesh to compute my own very special curvature measure?

usetri_mesh::prelude::*;fnmain(){// Construct any mesh, for simplicity, let's use a cube meshlet mesh =MeshBuilder::new().cube().build().unwrap();letmut curvature_measure =0.0;// Let's say that the curvature measure is a sum of a curvature measure for each vertex// which means we need to visit all verticesfor vertex_id in mesh.vertex_iter(){// Let's say that to compute the curvature of one vertex we need to visit the neighbouring faces// We will do that by iterating the half-edges pointing away from the vertex ..letmut curvature_measure_vertex =0.0;for halfedge_id in mesh.vertex_halfedge_iter(vertex_id){// .. and then create a walker from that halfedge and then get the face pointed to by that walkerifletSome(face_id)= mesh.walker_from_halfedge(halfedge_id).face_id(){// Finally, insert the code for computing your special vertex curvature measure right here!// curvature_measure_vertex += ??; }}
curvature_measure += curvature_measure_vertex;}}