[][src]Module plexus::builder

Incremental mesh construction.

This module provides traits for incrementally constructing mesh data structures. This API allows for meshes to be constructed in a way that is agnostic to the specific data structure used to represent the mesh.

Buildable is the primary trait of this API. It is implemented by mesh data structures and exposes various associated types that can be used to constrain geometry. Buildable exposes a builder type via the builder function. This builder type in turn provides additional builders that can be used to construct a mesh from surfaces and facets.


A function that generates a triangle from point geometry using builders:

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

fn trigon<B, T>(points: [T; 3]) -> Result<B, B::Error>
    B: Buildable,
    B::Vertex: FromGeometry<T>,
    let mut builder = B::builder();
    builder.surface_with(|builder| {
        let [a, b, c] = points;
        let a = builder.insert_vertex(a)?;
        let b = builder.insert_vertex(b)?;
        let c = builder.insert_vertex(c)?;
        builder.facets_with(|builder| builder.insert_facet(&[a, b, c], B::Facet::default()))

// `MeshBuffer` and `MeshGraph` implement the `Buildable` trait.
let graph: MeshGraph<Point2<f64>> = trigon([(0.0, 0.0), (0.0, 1.0), (1.0, 1.0)]).unwrap();
let buffer: MeshBuffer3<usize, Point2<f64>> =
    trigon([(0.0, 0.0), (0.0, 1.0), (1.0, 1.0)]).unwrap();



Mesh data structure that can be built incrementally.


Incremental mesh builder.