pub struct ShellBuilder<'a> { /* private fields */ }Expand description
Fluent builder for shell generation.
ShellBuilder provides a chainable API for configuring shell generation parameters before executing the operation. This is the recommended way to generate shells when you need custom configuration.
§Example
use mesh_repair::Mesh;
use mesh_shell::ShellBuilder;
let mesh = Mesh::load("scan.stl").unwrap();
// Simple usage with defaults
let result = ShellBuilder::new(&mesh)
.offset(2.0)
.build()
.unwrap();
// Advanced usage with custom settings
let result = ShellBuilder::new(&mesh)
.offset(3.0)
.wall_thickness(2.0)
.voxel_size(0.5)
.use_gpu(true)
.high_quality()
.build()
.unwrap();Implementations§
Source§impl<'a> ShellBuilder<'a>
impl<'a> ShellBuilder<'a>
Sourcepub fn offset(self, offset: f64) -> Self
pub fn offset(self, offset: f64) -> Self
Set the offset distance in mm.
This is the distance to offset the surface outward (positive) or inward (negative). For custom-fit products like shoe insoles, this is typically 1-5mm.
§Arguments
offset- Offset distance in millimeters
§Example
use mesh_repair::Mesh;
use mesh_shell::ShellBuilder;
let mesh = Mesh::load("scan.stl").unwrap();
let result = ShellBuilder::new(&mesh)
.offset(2.5) // 2.5mm outward
.build()
.unwrap();Sourcepub fn voxel_size(self, size: f64) -> Self
pub fn voxel_size(self, size: f64) -> Self
Set the voxel size for SDF computation in mm.
Smaller voxels give more detail but use more memory and time. The default (0.75mm) is a good balance for most use cases.
§Arguments
size- Voxel size in millimeters
§Recommendations
- High quality: 0.3-0.5mm
- Standard: 0.5-1.0mm
- Fast/large meshes: 1.0-2.0mm
Sourcepub fn padding(self, padding: f64) -> Self
pub fn padding(self, padding: f64) -> Self
Set padding beyond mesh bounds in mm.
This ensures the SDF grid extends far enough beyond the mesh to capture the full offset surface.
Sourcepub fn max_voxels(self, max: usize) -> Self
pub fn max_voxels(self, max: usize) -> Self
Set maximum number of voxels (memory limit).
If the required grid would exceed this, an error is returned. Default is 50 million voxels (~200MB for SDF values).
Sourcepub fn adaptive(self, enable: bool) -> Self
pub fn adaptive(self, enable: bool) -> Self
Enable adaptive multi-resolution SDF.
Uses coarse voxels far from the surface and fine voxels near it. This significantly reduces memory usage for large meshes while maintaining detail quality near the surface.
Sourcepub fn use_gpu(self, enable: bool) -> Self
pub fn use_gpu(self, enable: bool) -> Self
Enable GPU acceleration for SDF computation.
When enabled and a GPU is available, SDF computation uses GPU compute shaders for significant speedup (3-68x faster for small-medium meshes).
Falls back to CPU if GPU is unavailable.
Sourcepub fn wall_thickness(self, thickness: f64) -> Self
pub fn wall_thickness(self, thickness: f64) -> Self
Set uniform wall thickness in mm.
This is the thickness of the shell walls. For 3D printing, typical values are 1.5-4mm depending on the application.
§Arguments
thickness- Wall thickness in millimeters
Sourcepub fn thickness_map(self, map: ThicknessMap) -> Self
pub fn thickness_map(self, map: ThicknessMap) -> Self
Set variable wall thickness using a thickness map.
This allows different wall thicknesses in different regions (e.g., thick heel cup, thin arch in a shoe insole).
§Arguments
map- ThicknessMap with per-vertex or per-region thickness values
Sourcepub fn min_thickness(self, thickness: f64) -> Self
pub fn min_thickness(self, thickness: f64) -> Self
Set minimum acceptable wall thickness in mm.
Used during validation to flag walls that are too thin for reliable 3D printing.
Sourcepub fn validate(self, enable: bool) -> Self
pub fn validate(self, enable: bool) -> Self
Enable or disable post-generation validation.
When enabled, the generated shell is validated for manifoldness, wall thickness, and other quality metrics.
Sourcepub fn fast_walls(self) -> Self
pub fn fast_walls(self) -> Self
Use normal-based wall generation (fast but less accurate).
Each vertex is offset along its normal. Fast, but wall thickness may vary at corners (thinner at convex, thicker at concave).
Sourcepub fn sdf_walls(self) -> Self
pub fn sdf_walls(self) -> Self
Use SDF-based wall generation (slower but consistent thickness).
Computes a signed distance field and extracts an isosurface. This ensures consistent wall thickness regardless of curvature.
Sourcepub fn high_quality(self) -> Self
pub fn high_quality(self) -> Self
Apply high-quality preset settings.
Uses SDF-based wall generation with fine voxel resolution for consistent wall thickness and smooth surfaces.
Sourcepub fn fast(self) -> Self
pub fn fast(self) -> Self
Apply fast preset settings.
Uses normal-based wall generation with coarser resolution. Good for quick previews or when speed is more important than quality.
Sourcepub fn large_mesh(self) -> Self
pub fn large_mesh(self) -> Self
Apply settings optimized for large meshes.
Uses adaptive resolution and larger voxels to handle meshes with hundreds of thousands of triangles.
Sourcepub fn with_progress(self, callback: ProgressCallback) -> Self
pub fn with_progress(self, callback: ProgressCallback) -> Self
Set a progress callback.
The callback receives:
progress: 0.0-1.0 completion percentagestage: Description of current stage
Return false from the callback to cancel the operation.
§Example
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(2.0)
.with_progress(callback)
.build();Sourcepub fn build(self) -> ShellResult<ShellBuildResult>
pub fn build(self) -> ShellResult<ShellBuildResult>
Build the shell with the configured parameters.
This executes the full shell generation pipeline:
- Apply SDF offset to create inner surface
- Generate outer surface with walls
- Create rim connecting inner and outer
- Validate result (if enabled)
§Returns
A ShellBuildResult containing the generated mesh and statistics.
§Errors
Returns an error if:
- The mesh is empty or invalid
- The voxel grid would exceed memory limits
- Shell generation fails for any reason
Sourcepub fn build_offset_only(self) -> ShellResult<SdfOffsetResult>
pub fn build_offset_only(self) -> ShellResult<SdfOffsetResult>
Build only the offset surface (no walls).
This is useful when you want the inner surface without generating a full shell with walls.
§Returns
The offset result containing the inner surface mesh.
Auto Trait Implementations§
impl<'a> Freeze for ShellBuilder<'a>
impl<'a> !RefUnwindSafe for ShellBuilder<'a>
impl<'a> Send for ShellBuilder<'a>
impl<'a> Sync for ShellBuilder<'a>
impl<'a> Unpin for ShellBuilder<'a>
impl<'a> !UnwindSafe for ShellBuilder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.