Skip to main content

ManifoldImpl

Struct ManifoldImpl 

Source
pub struct ManifoldImpl {
    pub bbox: Box,
    pub epsilon: f64,
    pub tolerance: f64,
    pub num_prop: usize,
    pub status: Error,
    pub vert_pos: Vec<Vec3>,
    pub halfedge: Vec<Halfedge>,
    pub properties: Vec<f64>,
    pub vert_normal: Vec<Vec3>,
    pub face_normal: Vec<Vec3>,
    pub halfedge_tangent: Vec<Vec4>,
    pub mesh_relation: MeshRelationD,
}
Expand description

Internal halfedge mesh representation, mirroring Manifold::Impl in C++.

Fields§

§bbox: Box§epsilon: f64§tolerance: f64§num_prop: usize§status: Error§vert_pos: Vec<Vec3>§halfedge: Vec<Halfedge>§properties: Vec<f64>§vert_normal: Vec<Vec3>§face_normal: Vec<Vec3>§halfedge_tangent: Vec<Vec4>§mesh_relation: MeshRelationD

Implementations§

Source§

impl ManifoldImpl

Source

pub fn new() -> Self

Source

pub fn num_vert(&self) -> usize

Source

pub fn num_halfedge(&self) -> usize

Source

pub fn num_edge(&self) -> usize

Source

pub fn num_tri(&self) -> usize

Source

pub fn num_prop_vert(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn make_empty(&mut self, status: Error)

Source

pub fn for_vert<F: FnMut(usize)>(&self, halfedge_idx: usize, func: F)

Apply func to each halfedge index around the vertex starting from halfedge_idx.

Source

pub fn calculate_bbox(&mut self)

Source

pub fn set_epsilon(&mut self, min_epsilon: f64, use_single: bool)

Source

pub fn is_finite(&self) -> bool

Source

pub fn is_manifold(&self) -> bool

Check that the halfedge data structure is consistent (oriented even manifold).

Source

pub fn is_2_manifold(&self) -> bool

Check that the mesh is a 2-manifold (no duplicate edges).

Source

pub fn create_halfedges(&mut self, tri_prop: &[IVec3], tri_vert: &[IVec3])

Build the halfedge data structure from triangle lists.

  • tri_prop: property vertex indices per triangle (also geometry if tri_vert is empty)
  • tri_vert: geometry vertex indices per triangle (may be empty)

When tri_vert is empty, tri_prop is used for both geometry and properties. When tri_vert is present, tri_prop[i][j] = propVert, tri_vert[i][j] = startVert.

Source

pub fn initialize_original(&mut self)

Set up the mesh relation for a newly created original mesh.

Source

pub fn all_have_normals(&self) -> bool

True only when every meshID carries normals at slot 0..2 — the condition under which get_mesh_gl(-1) can safely auto-substitute that slot. A mixed Boolean output (some meshIDs with normals, some without) returns false; the output MeshGL’s per-run bit 1 still marks the with-normals runs individually. AND semantics across meshIDs. Per C++ #1718.

Source

pub fn tri_has_normals(&self, tri: usize) -> bool

True iff the meshID owning tri has hasNormals set. False when the meshID isn’t in mesh_id_transform (treat as no-normals). Per C++ #1718.

Source

pub fn eager_transform_prop_normals( halfedge: &[Halfedge], mesh_relation: &MeshRelationD, normal_transform: Mat3, properties: &mut [f64], num_prop_vert: usize, stride: usize, offset: usize, )

Eager-transform slot 0..2 of properties for propVerts whose meshID carries hasNormals. Used by both transform and compose so world-frame normals stay in sync with vert_pos / face_normal across any sequence of transforms (including mixed-input Boolean/Compose outputs where some meshIDs carry normals and others don’t). Per C++ #1718.

properties is laid out as properties[(offset + prop) * stride + i], so callers can target an in-place properties_ vector (offset=0) or a per-node slice of a combined array (offset=propVertIndices, stride=numPropOut). Re-normalizes as it transforms so non-orthogonal transforms (scale) and upstream barycentric interpolation don’t leave non-unit values that compound downstream.

Source

pub fn increment_mesh_ids(&mut self)

Allocates fresh unique mesh IDs and remaps all triRef.meshID values. This ensures boolean results don’t collide with source mesh IDs.

Source

pub fn dedupe_prop_verts(&mut self)

Deduplicates property vertices that share identical property values across paired halfedges within the same mesh.

Source

pub fn remove_unreferenced_verts(&mut self)

Mark unreferenced vertices as NaN (to be cleaned up by later passes).

Source

pub fn set_normals_and_coplanar(&mut self)

Compute face normals, assign coplanar IDs, and calculate vertex normals.

Source

pub fn sort_geometry(&mut self)

Reorder mesh geometry for cache efficiency using Morton codes.

Source

pub fn tetrahedron(transform: &Mat3x4) -> Self

Source

pub fn cube(transform: &Mat3x4) -> Self

Source

pub fn octahedron(transform: &Mat3x4) -> Self

Source

pub fn transform(&self, t: &Mat3x4) -> Self

Apply affine transform, returning a new ManifoldImpl.

Source§

impl ManifoldImpl

Source

pub fn slice(&self, height: f64) -> Polygons

Slice the mesh at the given Z height, returning 2D polygon loops. Mirrors Manifold::Impl::Slice in src/face_op.cpp.

Source

pub fn project(&self) -> Polygons

Project the mesh silhouette onto the XY plane, returning 2D polygon loops. Mirrors Manifold::Impl::Project in src/face_op.cpp.

Source§

impl ManifoldImpl

Source

pub fn get_property(&self, prop: Property) -> f64

Compute a global scalar property (volume or surface area) using Kahan summation for numerical stability.

Source

pub fn matches_tri_normals(&self) -> bool

Returns true if all triangles are CCW relative to their face normals.

Source

pub fn num_degenerate_tris(&self) -> i32

Returns the number of triangles that are colinear within epsilon.

Source

pub fn is_convex(&self) -> bool

Returns true if the manifold is genus 0 and contains no concave edges.

Source

pub fn calculate_curvature(&mut self, gaussian_idx: i32, mean_idx: i32)

Compute Gaussian and/or mean curvature per vertex, storing results into the property channels at the given indices. Pass -1 to skip.

Source

pub fn is_index_in_bounds(&self, tri_verts: &[IVec3]) -> bool

Checks that all indices in the given triVerts array are within the bounds of vert_pos.

Source§

impl ManifoldImpl

Source

pub fn vert_halfedge(&self) -> Vec<i32>

Source

pub fn sharpen_edges( &self, min_sharp_angle: f64, min_smoothness: f64, ) -> Vec<Smoothness>

Source

pub fn sharpen_tangent(&mut self, halfedge: usize, smoothness: f64)

Source

pub fn linearize_flat_tangents(&mut self)

Source

pub fn distribute_tangents(&mut self, fixed_halfedges: &[bool])

Source

pub fn create_tangents_from_normals(&mut self, normal_idx: usize)

Source

pub fn valid_tangents(&self) -> bool

Returns true if halfedge tangents form a valid quad/triangle arrangement. Checks that kInsideQuad (-1.0) markers are consistent: paired halfedges must agree, and marked halfedges cannot be adjacent within a triangle.

Source

pub fn create_tangents(&mut self, sharpened_edges: Vec<Smoothness>)

Source§

impl ManifoldImpl

Source

pub fn get_normal(&self, halfedge: usize, normal_idx: usize) -> Vec3

Source

pub fn tangent_from_normal(&self, normal: Vec3, halfedge: usize) -> Vec4

Source

pub fn is_inside_quad(&self, halfedge: usize) -> bool

Source

pub fn is_marked_inside_quad(&self, halfedge: usize) -> bool

Source

pub fn update_sharpened_edges( &self, sharpened_edges: &[Smoothness], ) -> Vec<Smoothness>

Source

pub fn flat_faces(&self) -> Vec<bool>

Source

pub fn vert_flat_face(&self, flat_faces: &[bool]) -> Vec<i32>

Source

pub fn set_normals(&mut self, normal_idx: i32, min_sharp_angle: f64)

Port of C++ Manifold::Impl::SetNormals() Fills in vertex properties with unshared normals across edges bent more than minSharpAngle (in degrees).

Source§

impl ManifoldImpl

Source

pub fn is_self_intersecting(&self) -> bool

Source

pub fn min_gap(&self, other: &ManifoldImpl, search_length: f64) -> f64

Source§

impl ManifoldImpl

Source

pub fn get_neighbor(&self, tri: i32) -> i32

Port of C++ Manifold::Impl::GetNeighbor(int tri)

Source

pub fn get_halfedges_quad(&self, tri: i32) -> IVec4

Port of C++ Manifold::Impl::GetHalfedges(int tri)

Source

pub fn subdivide( &mut self, edge_divisions: &dyn Fn(Vec3, Vec4, Vec4) -> i32, keep_interior: bool, ) -> Vec<Barycentric>

Port of C++ Manifold::Impl::Subdivide() edgeDivisions: takes (edge_vec, tangent0, tangent1) → number of new vertices

Trait Implementations§

Source§

impl Clone for ManifoldImpl

Source§

fn clone(&self) -> ManifoldImpl

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for ManifoldImpl

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.