Crate mesh_shell

Crate mesh_shell 

Source
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, &params).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§

BoundaryAnalysis
Result of boundary topology analysis.
BoundaryLoop
A boundary loop representing a single closed boundary in the mesh.
RimResult
Result of rim generation.
SdfOffsetParams
Parameters for SDF offset operation.
SdfOffsetResult
Result of SDF offset operation.
SdfOffsetStats
Statistics from SDF offset operation.
ShellBuildResult
Result from ShellBuilder containing the generated mesh and statistics.
ShellBuilder
Fluent builder for shell generation.
ShellGenerationResult
Result of shell generation.
ShellParams
Parameters for shell generation.
ShellRepairResult
Result of shell auto-repair operation.
ShellValidationResult
Result of shell validation.

Enums§

ShellError
Errors that can occur during shell operations.
ShellIssue
Issues that can be found during shell validation.
WallGenerationMethod
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§

ShellResult
Result type alias for shell operations.