pub struct ManifoldSolid { /* private fields */ }Expand description
A Manifold solid together with metadata keyed by Manifold OriginalID.
Implementations§
Source§impl ManifoldSolid
impl ManifoldSolid
pub fn manifold(&self) -> &Manifold
pub fn into_manifold(self) -> Manifold
pub fn metadata(&self) -> &HashMap<u32, SurfaceMetadata>
pub fn surface_metadata(&self, id: TriangleSourceId) -> Option<&SurfaceMetadata>
Sourcepub fn triangle_source_ids(
&self,
) -> Result<Vec<TriangleSourceId>, ProvenanceError>
pub fn triangle_source_ids( &self, ) -> Result<Vec<TriangleSourceId>, ProvenanceError>
Expand Manifold’s triangle runs into one provenance ID per triangle.
Methods from Deref<Target = Manifold>§
pub fn to_meshgl64(&self) -> MeshGL64
pub fn to_meshgl64(&self) -> MeshGL64
Extract mesh data as f64 vertex properties and u64 triangle indices.
Returns the full [MeshGL64] container, including run metadata, face
IDs, merge vectors, and tangents when present.
pub fn to_meshgl64_with_normals(&self, normal_idx: i32) -> MeshGL64
pub fn to_meshgl64_with_normals(&self, normal_idx: i32) -> MeshGL64
Extract mesh data as f64 with normals baked into vertex properties.
Returns the full [MeshGL64] container. See
to_mesh_f64_with_normals for the
normal_idx semantics.
pub fn to_mesh_f64(&self) -> (Vec<f64>, usize, Vec<u64>)
pub fn to_mesh_f64(&self) -> (Vec<f64>, usize, Vec<u64>)
Extract mesh data as f64 vertex properties and u64 triangle indices.
Returns (vert_props, n_props, tri_indices).
pub fn to_mesh_f64_with_normals(
&self,
normal_idx: i32,
) -> (Vec<f64>, usize, Vec<u64>)
pub fn to_mesh_f64_with_normals( &self, normal_idx: i32, ) -> (Vec<f64>, usize, Vec<u64>)
Extract mesh data as f64 with normals baked into vertex properties.
The normals are stored starting at property index normal_idx (3
consecutive f64 values per vertex: nx, ny, nz). If the mesh doesn’t
already have properties at that index, they are added.
Returns (vert_props, n_props, tri_indices).
pub fn to_mesh_f32_with_normals(
&self,
normal_idx: i32,
) -> (Vec<f32>, usize, Vec<u32>)
pub fn to_mesh_f32_with_normals( &self, normal_idx: i32, ) -> (Vec<f32>, usize, Vec<u32>)
Extract mesh data as f32 with normals baked into vertex properties.
See to_mesh_f64_with_normals for details.
pub fn to_meshgl(&self) -> MeshGL
pub fn to_meshgl(&self) -> MeshGL
Extract mesh data as f32 vertex properties and u32 triangle indices.
Returns the full [MeshGL] container, including run metadata, face IDs,
merge vectors, and tangents when present.
pub fn to_meshgl_with_normals(&self, normal_idx: i32) -> MeshGL
pub fn to_meshgl_with_normals(&self, normal_idx: i32) -> MeshGL
Extract mesh data as f32 with normals baked into vertex properties.
Returns the full [MeshGL] container. See
to_mesh_f64_with_normals for the
normal_idx semantics.
pub fn to_mesh_f32(&self) -> (Vec<f32>, usize, Vec<u32>)
pub fn to_mesh_f32(&self) -> (Vec<f32>, usize, Vec<u32>)
Extract mesh data as f32 vertex properties and u32 triangle indices.
Returns (vert_props, n_props, tri_indices).
pub fn translate(&self, x: f64, y: f64, z: f64) -> Manifold
pub fn translate(&self, x: f64, y: f64, z: f64) -> Manifold
Translate by (x, y, z). Returns a new Manifold.
pub fn rotate(&self, x_deg: f64, y_deg: f64, z_deg: f64) -> Manifold
pub fn rotate(&self, x_deg: f64, y_deg: f64, z_deg: f64) -> Manifold
Rotate by Euler angles (degrees), applied in z-y’-x“ order. Multiples of 90deg use exact arithmetic internally.
pub fn transform(&self, m: &[f64; 12]) -> Manifold
pub fn transform(&self, m: &[f64; 12]) -> Manifold
Apply a 4x3 affine transformation (column-major).
The 12 values represent:
| m[0] m[3] m[6] m[9] | col1 = X basis
| m[1] m[4] m[7] m[10] | col2 = Y basis
| m[2] m[5] m[8] m[11] | col3 = Z basis
col4 = translationpub fn split_by_plane(
&self,
normal: [f64; 3],
offset: f64,
) -> (Manifold, Manifold)
pub fn split_by_plane( &self, normal: [f64; 3], offset: f64, ) -> (Manifold, Manifold)
Split into two halves along a plane.
The plane is normal · point = offset.
Returns (positive_half, negative_half).
pub fn trim_by_plane(&self, normal: [f64; 3], offset: f64) -> Manifold
pub fn trim_by_plane(&self, normal: [f64; 3], offset: f64) -> Manifold
Trim to one side of a plane, keeping the positive half.
Note: Upstream issue #1516: trimmed halves may not reassemble via boolean union due to coincident faces.
pub fn slice_at_z(&self, height: f64) -> Vec<Vec<[f64; 2]>>
pub fn slice_at_z(&self, height: f64) -> Vec<Vec<[f64; 2]>>
Slice at a given Z height, returning 2D polygon contours.
Returns a list of polygon rings (each ring is a list of [x, y] points).
pub fn slice_to_cross_section(&self, height: f64) -> CrossSection
pub fn slice_to_cross_section(&self, height: f64) -> CrossSection
Slice at a given Z height, returning a [CrossSection] object.
The cross-section can be offset, extruded, and boolean’d in 2D.
Uses the upstream default [FillRule::Positive], which treats
positively oriented contours as filled regions and negatively oriented
contours as holes. For other winding semantics (e.g. slices whose
contour orientation you don’t control), use
slice_to_cross_section_with_fill_rule.
pub fn slice_to_cross_section_with_fill_rule(
&self,
height: f64,
fill_rule: FillRule,
) -> CrossSection
pub fn slice_to_cross_section_with_fill_rule( &self, height: f64, fill_rule: FillRule, ) -> CrossSection
Slice at a given Z height with a specified fill rule, returning a
[CrossSection] object.
The fill rule determines how the sliced contours are interpreted into
filled regions. See [FillRule] for details.
pub fn surface_area(&self) -> f64
pub fn surface_area(&self) -> f64
Total surface area.
pub fn bounding_box(&self) -> Option<BoundingBox>
pub fn bounding_box(&self) -> Option<BoundingBox>
Axis-aligned bounding box.
Returns a [BoundingBox] with spatial query methods (containment,
overlap, union, transforms). Returns None if the manifold is empty.
pub fn difference(&self, other: &Manifold) -> Manifold
pub fn difference(&self, other: &Manifold) -> Manifold
Boolean difference: self - other.
pub fn union(&self, other: &Manifold) -> Manifold
pub fn union(&self, other: &Manifold) -> Manifold
Boolean union: self + other.
pub fn intersection(&self, other: &Manifold) -> Manifold
pub fn intersection(&self, other: &Manifold) -> Manifold
Boolean intersection: self ∩ other.
pub fn boolean(&self, other: &Manifold, op: OpType) -> Manifold
pub fn boolean(&self, other: &Manifold, op: OpType) -> Manifold
Generic boolean operation with an explicit operation type.
Prefer the specific methods (union,
difference, intersection)
or operator overloads (+, -, ^) for readability. This method
is useful when the operation type is determined at runtime.
pub fn hull(&self) -> Manifold
pub fn hull(&self) -> Manifold
Convex hull of this manifold.
pub fn mirror(&self, normal: [f64; 3]) -> Manifold
pub fn mirror(&self, normal: [f64; 3]) -> Manifold
Mirror across a plane through the origin with the given normal.
pub fn refine(&self, n: i32) -> Manifold
pub fn refine(&self, n: i32) -> Manifold
Increase the density of the mesh by splitting each edge into n pieces.
pub fn refine_to_length(&self, length: f64) -> Manifold
pub fn refine_to_length(&self, length: f64) -> Manifold
Refine until no edge is longer than length.
pub fn refine_to_tolerance(&self, tolerance: f64) -> Manifold
pub fn refine_to_tolerance(&self, tolerance: f64) -> Manifold
Refine until the deviation from the true surface is less than tolerance.
pub fn set_tolerance(&self, tolerance: f64) -> Manifold
pub fn set_tolerance(&self, tolerance: f64) -> Manifold
Set the tolerance of the manifold, returning a new manifold.
pub fn simplify(&self, tolerance: f64) -> Manifold
pub fn simplify(&self, tolerance: f64) -> Manifold
Simplify the mesh, removing vertices until the error exceeds tolerance.
pub fn smooth_by_normals(&self, normal_idx: i32) -> Manifold
pub fn smooth_by_normals(&self, normal_idx: i32) -> Manifold
Smooth the manifold by converting sharp edges to smooth curves, using vertex normals at the given property index.
pub fn smooth_out(&self, min_sharp_angle: f64, min_smoothness: f64) -> Manifold
pub fn smooth_out(&self, min_sharp_angle: f64, min_smoothness: f64) -> Manifold
Smooth out the manifold, making sharp edges smoother.
min_sharp_angle (degrees): edges sharper than this are candidates.
min_smoothness: minimum smoothness applied (0-1).
pub fn split(&self, cutter: &Manifold) -> (Manifold, Manifold)
pub fn split(&self, cutter: &Manifold) -> (Manifold, Manifold)
Split by another manifold (instead of a plane).
pub fn minkowski_sum(&self, other: &Manifold) -> Manifold
pub fn minkowski_sum(&self, other: &Manifold) -> Manifold
Minkowski sum of two manifolds.
pub fn minkowski_difference(&self, other: &Manifold) -> Manifold
pub fn minkowski_difference(&self, other: &Manifold) -> Manifold
Minkowski difference of two manifolds.
pub fn project(&self) -> Vec<Vec<[f64; 2]>>
pub fn project(&self) -> Vec<Vec<[f64; 2]>>
Project the manifold onto the XY plane, returning 2D polygons.
pub fn get_tolerance(&self) -> f64
pub fn get_tolerance(&self) -> f64
Tolerance of the manifold (public API, distinct from the epsilon testing hook).
pub fn num_prop_vert(&self) -> usize
pub fn num_prop_vert(&self) -> usize
Number of property vertices (may differ from num_vert when vertices
are split to accommodate different property values).
pub fn genus(&self) -> i32
pub fn genus(&self) -> i32
Genus of the manifold (topological measure: 0 for sphere, 1 for torus, etc).
pub fn original_id(&self) -> i32
pub fn original_id(&self) -> i32
Original ID of this manifold (for tracking through operations).
pub fn as_original(&self) -> Manifold
pub fn as_original(&self) -> Manifold
Mark this manifold as an original, assigning it a unique ID for tracking through boolean operations.
Use original_id to retrieve the assigned ID,
and [reserve_ids] to pre-allocate ID ranges.
pub fn min_gap(&self, other: &Manifold, search_length: f64) -> f64
pub fn min_gap(&self, other: &Manifold, search_length: f64) -> f64
Minimum gap between this manifold and another, searching up to search_length.
pub fn status(&self) -> Result<(), CsgError>
pub fn status(&self) -> Result<(), CsgError>
Force evaluation of this manifold’s lazy CSG tree.
Manifold operations are lazy: building a CSG tree is cheap and
synchronous; the actual evaluation happens when something queries
the result. Most queries (num_tri, mesh extraction, volume,
etc.) also force evaluation as a side effect, but not all of them
observe an attached ExecutionContext.
This method is the primary way to force evaluation under a context
without consuming a property.
To run the evaluation under a cancellable
ExecutionContext, use
[Manifold::with_context] first:
let ctx = ExecutionContext::new();
manifold.with_context(&ctx).status()?;pub fn raw_status(&self) -> ManifoldError
pub fn raw_status(&self) -> ManifoldError
Force evaluation of this manifold’s lazy CSG tree and return the raw manifold3d status code.
Prefer status when you only need success/failure.
pub fn with_context(&self, ctx: &ExecutionContext) -> Manifold
pub fn with_context(&self, ctx: &ExecutionContext) -> Manifold
Return a copy of this manifold with ctx attached. The next eager op
that consumes an execution context (such as status
or refine*) on the returned value observes ctx. Deferred ops
(booleans, transforms, batch ops) ignore the attached context
and produce results with no attached context.
See the execution module docs for the
full pattern. Equivalent to upstream’s manifold_with_context.
The returned Manifold internally holds a shared_ptr to the
context’s state (managed on the C++ side via std::atomic_store),
so it remains valid even if ctx is dropped before the eager op
runs:
// Build a deferred CSG tree whose eager evaluation will need to
// consult the attached context, then attach + drop ctx + eval.
let tree = &Manifold::cube(1.0, 1.0, 1.0, true)
- &Manifold::sphere(0.6, 32);
let attached = {
let ctx = ExecutionContext::new();
tree.with_context(&ctx)
// ctx drops here; `attached` still holds the inner state
// via shared_ptr, so the eager op below is safe.
};
attached.status()?;pub fn ray_cast(&self, origin: [f64; 3], end: [f64; 3]) -> Vec<RayHit>
pub fn ray_cast(&self, origin: [f64; 3], end: [f64; 3]) -> Vec<RayHit>
Cast a ray against this manifold, returning all intersection hits.
The ray goes from origin to end. Returns a list of RayHit
results, each containing the face ID, distance, hit position, and
surface normal.
pub fn calculate_normals(
&self,
normal_idx: i32,
min_sharp_angle: f64,
) -> Manifold
pub fn calculate_normals( &self, normal_idx: i32, min_sharp_angle: f64, ) -> Manifold
Calculate normals and store them as vertex properties at normal_idx.
Edges sharper than min_sharp_angle (degrees) get sharp normals.
pub fn calculate_curvature(&self, gaussian_idx: i32, mean_idx: i32) -> Manifold
pub fn calculate_curvature(&self, gaussian_idx: i32, mean_idx: i32) -> Manifold
Calculate Gaussian and mean curvature and store as vertex properties.
pub fn warp<F>(&self, f: F) -> Manifold
pub fn warp<F>(&self, f: F) -> Manifold
Apply a warp function to deform each vertex.
The closure receives (x, y, z) and returns [x', y', z'].
pub fn set_properties<F>(&self, num_prop: usize, f: F) -> Manifold
pub fn set_properties<F>(&self, num_prop: usize, f: F) -> Manifold
Set custom vertex properties using a callback.
The closure receives (new_props, position, old_props) where:
new_props: mutable slice ofnum_propf64s to writeposition: the vertex position[x, y, z]old_props: the existing properties (length = currentself.num_prop())
Trait Implementations§
Source§impl AsRef<Manifold> for ManifoldSolid
impl AsRef<Manifold> for ManifoldSolid
Source§impl Clone for ManifoldSolid
impl Clone for ManifoldSolid
Source§fn clone(&self) -> ManifoldSolid
fn clone(&self) -> ManifoldSolid
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ManifoldSolid
impl RefUnwindSafe for ManifoldSolid
impl Send for ManifoldSolid
impl Sync for ManifoldSolid
impl Unpin for ManifoldSolid
impl UnsafeUnpin for ManifoldSolid
impl UnwindSafe for ManifoldSolid
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§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>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§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.§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.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more