Manifold

Struct Manifold 

Source
pub struct Manifold(/* private fields */);
Expand description

Manifold rust wrapper for C++ manifold object.

Implementations§

Source§

impl Manifold

Source

pub fn is_empty(&self) -> bool

Does Manifold contain triangles?

Source

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

Slice the manifold into a set of polygons.

Source

pub fn project(&self) -> Polygons

Project the manifold onto a plane and return the resulting polygons.

Source

pub fn trim_by_plane(&self, x: f64, y: f64, z: f64, offset: f64) -> Self

Trim by a plane.

Source

pub fn hull(&self) -> Self

Convex hull.

Source

pub fn translate(&self, x: f64, y: f64, z: f64) -> Self

Translate the manifold.

Source

pub fn scale(&self, x: f64, y: f64, z: f64) -> Self

Scale the manifold.

Source

pub fn rotate(&self, x: f64, y: f64, z: f64) -> Self

Rotate the manifold.

Source

pub fn empty() -> Self

Create empty manifold.

Source

pub fn tetrahedron() -> Self

Create tetrahedron manifold.

Source

pub fn sphere(radius: f64, segments: u32) -> Self

Create a sphere manifold.

Examples found in repository?
examples/simple.rs (line 2)
1fn main() {
2    let sphere = manifold_rs::Manifold::sphere(4.0, 32);
3    let vertices = sphere.to_mesh().vertices();
4    let indices = sphere.to_mesh().indices();
5
6    assert!(!vertices.is_empty());
7    assert!(!indices.is_empty());
8
9    println!("Vertices:\n{vertices:?}");
10    println!("Indices:\n{indices:?}");
11}
Source

pub fn cube(x_size: f64, y_size: f64, z_size: f64) -> Self

Create a cube manifold.

Source

pub fn cylinder( radius_low: f64, radius_high: f64, height: f64, segments: u32, ) -> Self

Create a cylinder manifold.

Source

pub fn union(&self, b: &Self) -> Self

Get the union of two manifolds.

Source

pub fn intersection(&self, b: &Self) -> Self

Get the intersection of two manifolds.

Source

pub fn difference(&self, b: &Self) -> Self

Get the difference of two manifolds.

Source

pub fn boolean_op(&self, b: &Self, op: BooleanOp) -> Self

Boolean operation on manifolds.

Source

pub fn extrude( multi_polygon_data: &[&[f64]], height: f64, n_divisions: u32, twist_degrees: f64, scale_top_x: f64, scale_top_y: f64, ) -> Self

Extrude a polygon to create a manifold.

Source

pub fn revolve( multi_polygon_data: &[&[f64]], circular_segments: u32, revolve_degrees: f64, ) -> Self

Revolve a polygon to create a manifold.

Source

pub fn refine(self: &Manifold, n: i32) -> Self

Refine manifold.

Source

pub fn refine_to_length(self: &Manifold, t: f64) -> Self

Refine manifold to Length.

Source

pub fn refine_to_tolerance(self: &Manifold, t: f64) -> Self

Refine to tolerance.

Source

pub fn smooth_by_normals(self: &Manifold, normal_idx: i32) -> Self

Smooth by normals.

Source

pub fn smooth_out( self: &Manifold, min_sharp_angle: f64, min_smoothness: f64, ) -> Self

Smooth out.

Source

pub fn calculate_normals( self: &Manifold, normal_idx: i32, min_sharp_angle: f64, ) -> Self

Calculate normals for the manifold and return a new one.

Source

pub fn to_mesh(&self) -> Mesh

Get the mesh representation of the manifold.

Examples found in repository?
examples/simple.rs (line 3)
1fn main() {
2    let sphere = manifold_rs::Manifold::sphere(4.0, 32);
3    let vertices = sphere.to_mesh().vertices();
4    let indices = sphere.to_mesh().indices();
5
6    assert!(!vertices.is_empty());
7    assert!(!indices.is_empty());
8
9    println!("Vertices:\n{vertices:?}");
10    println!("Indices:\n{indices:?}");
11}
Source

pub fn from_mesh(mesh: Mesh) -> Self

Create a manifold from a mesh.

Trait Implementations§

Source§

impl From<Manifold> for Mesh

Convert Manifold to Mesh struct

Source§

fn from(manifold: Manifold) -> Self

Converts to this type from the input type.
Source§

impl From<Mesh> for Manifold

Convert Mesh to Manifold struct

Source§

fn from(mesh: Mesh) -> Self

Converts to this type from the input type.

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> 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, 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.