You can read/write STL files using StlReader
and StlWriter
structs. Ony binary STLs are supported.
```rust use std::path::Path;
use babyshark::{ io::stl::{StlReader, StlWriter}, mesh::cornertable::prelude::CornerTableF };
fn main() { let mut reader = StlReader::new(); let mesh: CornerTableF = reader.readstlfrom_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");
} ```
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)
).
rust
let remesher = IncrementalRemesher::new()
.with_iterations_count(10)
.with_split_edges(true)
.with_collapse_edges(true)
.with_flip_edges(true)
.with_shift_vertices(true)
.with_project_vertices(true);
remesher.remesh(&mut mesh, 0.002f32);
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
rust
let mut decimator = EdgeDecimator::new()
.max_error(Some(0.0005))
.min_faces_count(Some(10000));
decimator.decimate(&mut mesh);
Triangulation2
struct implements fast 2D delaunay triangulation of points set.
```rust let mut triangulation = Triangulation2::new(); triangulation.triangulate(&vec![ Point2::new(1.0, 2.0), Point2::new(5.0, 1.0), Point2::new(8.0, 6.0), Point2::new(2.0, 8.0) ]);