Expand description
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();Structs§
- Boundary
Analysis - Result of boundary topology analysis.
- Boundary
Loop - A boundary loop representing a single closed boundary in the mesh.
- RimResult
- Result of rim generation.
- SdfOffset
Params - Parameters for SDF offset operation.
- SdfOffset
Result - Result of SDF offset operation.
- SdfOffset
Stats - Statistics from SDF offset operation.
- Shell
Build Result - Result from ShellBuilder containing the generated mesh and statistics.
- Shell
Builder - Fluent builder for shell generation.
- Shell
Generation Result - Result of shell generation.
- Shell
Params - Parameters for shell generation.
- Shell
Repair Result - Result of shell auto-repair operation.
- Shell
Validation Result - Result of shell validation.
Enums§
- Shell
Error - Errors that can occur during shell operations.
- Shell
Issue - Issues that can be found during shell validation.
- Wall
Generation Method - Method for generating the outer surface of the shell.
Functions§
- analyze_
boundary - Analyze boundary topology of a mesh.
- apply_
sdf_ offset - Apply SDF-based offset to create a new mesh with variable offsets.
- generate_
rim - Generate rim faces to connect inner and outer surfaces at boundaries.
- generate_
rim_ advanced - Generate rim faces with full boundary analysis and reporting.
- generate_
rim_ for_ sdf_ shell - Generate rim faces for SDF-based shell where inner and outer surfaces have different vertex counts and no 1:1 correspondence.
- generate_
shell - Generate a printable shell from the inner surface.
- generate_
shell_ no_ validation - Generate a shell without automatic validation.
- generate_
shell_ with_ progress - Generate a printable shell with progress reporting.
- repair_
shell - Attempt to automatically repair minor issues in a shell mesh.
- validate_
and_ repair_ shell - Validate and optionally repair a shell mesh.
- validate_
boundary_ for_ rim - Validate that a mesh’s boundaries are suitable for rim generation.
- validate_
shell - Validate a shell mesh for 3D printing suitability.
Type Aliases§
- Shell
Result - Result type alias for shell operations.