2 unstable releases
Uses new Rust 2024
| 0.2.0 | Jan 17, 2026 |
|---|---|
| 0.1.0 | Jan 16, 2026 |
#2653 in Algorithms
Used in mesh-cli
1.5MB
33K
SLoC
Shell generation around 3D meshes using SDF-based offset.
This crate provides tools for generating printable shells around 3D meshes using signed distance field (SDF) based offset techniques.
Features
- SDF-based offset: Robust offset that avoids self-intersections
- Variable offset: Per-vertex offset values for complex shapes
- Shell generation: Create watertight shells with walls
- Rim generation: Clean boundary edges connecting inner and outer surfaces
- Builder API: Fluent builder pattern for ergonomic configuration
Quick Start with ShellBuilder
The recommended way to generate shells is using the ShellBuilder:
use mesh_repair::Mesh;
use mesh_shell::ShellBuilder;
let mesh = Mesh::load("scan.stl").unwrap();
// Simple: generate shell with defaults
let result = ShellBuilder::new(&mesh)
.offset(2.0) // 2mm outward offset
.wall_thickness(2.5) // 2.5mm walls
.build()
.unwrap();
result.mesh.save("shell.3mf").unwrap();
Advanced Configuration
use mesh_repair::Mesh;
use mesh_repair::progress::ProgressCallback;
use mesh_shell::ShellBuilder;
let mesh = Mesh::load("scan.stl").unwrap();
let callback: ProgressCallback = Box::new(|progress| {
println!("{}%: {}", progress.percent(), progress.message);
true // continue
});
let result = ShellBuilder::new(&mesh)
.offset(3.0)
.wall_thickness(2.0)
.voxel_size(0.5) // Fine resolution
.high_quality() // SDF-based walls
.use_gpu(true) // GPU acceleration
.with_progress(callback)
.build()
.unwrap();
Low-Level API
For more control, use the low-level functions directly:
use mesh_repair::Mesh;
use mesh_shell::{apply_sdf_offset, generate_shell, SdfOffsetParams, ShellParams};
let mut mesh = Mesh::load("scan.stl").unwrap();
// Set offset values on vertices
for v in &mut mesh.vertices {
v.offset = Some(2.0);
}
// Apply SDF offset
let params = SdfOffsetParams::default();
let result = apply_sdf_offset(&mesh, ¶ms).unwrap();
// Generate shell with walls
let shell_params = ShellParams::default();
let (shell, stats) = generate_shell(&result.mesh, &shell_params);
shell.save("shell.3mf").unwrap();
Dependencies
~34–71MB
~1M SLoC