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
type Builder: MeshBuilder<Commit = Self, Error = Self::Error, Vertex = Self::Vertex, Facet = Self::Facet>
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.
Required Methods
Implementors
sourceimpl<G> Buildable for MeshGraph<G> where
G: GraphData,
impl<G> Buildable for MeshGraph<G> where
G: GraphData,
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();
sourceimpl<R, G> Buildable for MeshBuffer<R, G> where
R: Grouping,
Vec<R::Group>: IndexBuffer<R>,
BufferBuilder<R, G>: MeshBuilder<Error = BufferError, Commit = Self, Vertex = G, Facet = ()>,
impl<R, G> Buildable for MeshBuffer<R, G> where
R: Grouping,
Vec<R::Group>: IndexBuffer<R>,
BufferBuilder<R, G>: MeshBuilder<Error = BufferError, Commit = Self, Vertex = G, Facet = ()>,
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();