logo
pub trait Buildable: Sized {
    type Builder: MeshBuilder<Commit = Self, Error = Self::Error, Vertex = Self::Vertex, Facet = Self::Facet>;
    type Error: Debug;
    type Vertex;
    type Facet: Default;

    fn builder() -> Self::Builder;
}
Expand description

Polygonal mesh data structure that can be built incrementally.

This trait is the primary entrypoint into the builder API. Types that implement this trait expose a MeshBuilder that can be used to construct an instance of the type from surfaces and facets.

Required Associated Types

Vertex data.

This type represents the data associated with vertices in the mesh. This typically includes positional data, but no data is required and this type may be the unit type ().

Each builder trait also exposes such an associated type which is constrained by the Builder type.

Facet data.

This type represents the data associated with facets in the mesh. No data is required and this type may be the unit type ().

Each builder trait also exposes such an associated type which is constrained by the Builder type.

Required Methods

Implementors

Exposes a MeshBuilder that can be used to construct a MeshGraph incrementally from surfaces and facets.

See the builder module documentation for more.

Examples

Creating a MeshGraph from a triangle:

use nalgebra::Point2;
use plexus::builder::Buildable;
use plexus::graph::MeshGraph;
use plexus::prelude::*;

let mut builder = MeshGraph::<Point2<f64>>::builder();
let graph = builder
    .surface_with(|builder| {
        let a = builder.insert_vertex((0.0, 0.0))?;
        let b = builder.insert_vertex((1.0, 0.0))?;
        let c = builder.insert_vertex((0.0, 1.0))?;
        builder.facets_with(|builder| builder.insert_facet(&[a, b, c], ()))
    })
    .and_then(|_| builder.build())
    .unwrap();

Exposes a MeshBuilder that can be used to construct a MeshBuffer incrementally from surfaces and facets.

Note that the facet data for MeshBuffer is always the unit type ().

See the documentation for the builder module.

Examples

Creating a MeshBuffer from a triangle:

use nalgebra::Point2;
use plexus::buffer::MeshBuffer3;
use plexus::builder::Buildable;
use plexus::prelude::*;

let mut builder = MeshBuffer3::<usize, Point2<f64>>::builder();
let buffer = builder
    .surface_with(|builder| {
        let a = builder.insert_vertex((0.0, 0.0))?;
        let b = builder.insert_vertex((1.0, 0.0))?;
        let c = builder.insert_vertex((0.0, 1.0))?;
        builder.facets_with(|builder| builder.insert_facet(&[a, b, c], ()))
    })
    .and_then(|_| builder.build())
    .unwrap();