mesh_shell/
lib.rs

1//! Shell generation around 3D meshes using SDF-based offset.
2//!
3//! This crate provides tools for generating printable shells around 3D meshes
4//! using signed distance field (SDF) based offset techniques.
5//!
6//! # Features
7//!
8//! - **SDF-based offset**: Robust offset that avoids self-intersections
9//! - **Variable offset**: Per-vertex offset values for complex shapes
10//! - **Shell generation**: Create watertight shells with walls
11//! - **Rim generation**: Clean boundary edges connecting inner and outer surfaces
12//!
13//! # Example
14//!
15//! ```no_run
16//! use mesh_repair::Mesh;
17//! use mesh_shell::{apply_sdf_offset, generate_shell, SdfOffsetParams, ShellParams};
18//!
19//! // Load and prepare mesh
20//! let mut mesh = Mesh::load("scan.stl").unwrap();
21//!
22//! // Set offset values on vertices (uses mesh.vertices[i].offset field)
23//! for v in &mut mesh.vertices {
24//!     v.offset = Some(2.0); // 2mm outward offset
25//! }
26//!
27//! // Apply SDF offset to create the inner shell
28//! let params = SdfOffsetParams::default();
29//! let result = apply_sdf_offset(&mesh, &params).unwrap();
30//! let inner_shell = result.mesh;
31//!
32//! // Generate printable shell with walls
33//! let shell_params = ShellParams::default();
34//! let (shell, stats) = generate_shell(&inner_shell, &shell_params);
35//!
36//! shell.save("shell.3mf").unwrap();
37//! ```
38
39mod error;
40mod offset;
41mod shell;
42
43pub use error::{ShellError, ShellResult};
44
45// SDF offset
46pub use offset::{
47    apply_sdf_offset, SdfOffsetParams, SdfOffsetResult, SdfOffsetStats,
48};
49
50// Shell generation (rename to avoid conflict with error::ShellResult)
51pub use shell::{
52    generate_shell, ShellParams, ShellResult as ShellGenerationResult,
53};