5 releases

new 0.1.4 May 28, 2023
0.1.3 May 20, 2023
0.1.2 May 14, 2023
0.1.1 Mar 12, 2023
0.1.0 Mar 12, 2023

#282 in Math

Download history 31/week @ 2023-03-07 6/week @ 2023-03-14 2/week @ 2023-03-21 2/week @ 2023-03-28 3/week @ 2023-04-11 2/week @ 2023-04-18 1/week @ 2023-04-25 4/week @ 2023-05-02 25/week @ 2023-05-09 26/week @ 2023-05-16 22/week @ 2023-05-23

78 downloads per month

MIT license


Geometry processing library in pure Rust

❗ Under development. API may change.


  • Corner table implementation for efficient mesh traversal
  • STL reader/writer
  • Remeshing
  • Mesh simplification (decimation)
  • 2D triangulation
  • Spatial index
    • Bounding volume hierarchy of axis aligned bounding boxes
    • Infinite grid

Reading/writing mesh from/to STL file

You can read/write STL files using StlReader and StlWriter structs. Ony binary STLs are supported.


use std::path::Path;

use baby_shark::{
    io::stl::{StlReader, StlWriter}, 

fn main() {
    let mut reader = StlReader::new();
    let mesh: CornerTableF = reader.read_stl_from_file(Path::new("./read.stl"))
        .expect("Read mesh from STL file");

    let writer = StlWriter::new();
    writer.write_stl_to_file(&mesh, Path::new("./write.stl"))
        .expect("Save mesh to STL file");

Isotropic remeshing

This algorithm incrementally performs simple operations such as edge splits, edge collapses, edge flips, and Laplacian smoothing. All the vertices of the remeshed patch are reprojected to the original surface to keep a good approximation of the input. Any of those operations can be turned off using appropriate method (with_<operation>(false)).



let remesher = IncrementalRemesher::new()
remesher.remesh(&mut mesh, 0.002f32);

Mesh simplification (decimation)

This library implements incremental edge decimation algorithm. On each iteration edge with lowest collapse cost is collapsed. Several stop condition are supported:

  • Max error - algorithm stops when collapse lowest cost is bigger than given value
  • Min faces count - algorithm stops when faces count drops below given value



 let mut decimator = EdgeDecimator::new()
 decimator.decimate(&mut mesh);

2D triangulation

Triangulation2 struct implements fast 2D delaunay triangulation of points set.



let mut triangulation = Triangulation2::new();
    Point2::new(1.0, 2.0),
    Point2::new(5.0, 1.0),
    Point2::new(8.0, 6.0),
    Point2::new(2.0, 8.0)


~106K SLoC