pub trait Generator: Sized {
fn vertices<A>(
&self
) -> Generate<'_, Self, Self::State, <Self as AttributeVertexGenerator<A>>::Output>ⓘNotable traits for Generate<'a, G, S, P>impl<'a, G, S, P> Iterator for Generate<'a, G, S, P> where
G: 'a, type Item = P;
where
Self: AttributeVertexGenerator<A>,
A: Attribute,
{ ... }
fn vertices_from<A>(
&self,
state: Self::State
) -> Generate<'_, Self, Self::State, <Self as AttributeVertexGenerator<A>>::Output>ⓘNotable traits for Generate<'a, G, S, P>impl<'a, G, S, P> Iterator for Generate<'a, G, S, P> where
G: 'a, type Item = P;
where
Self: AttributeVertexGenerator<A>,
A: Attribute,
{ ... }
fn polygons<A>(
&self
) -> Generate<'_, Self, Self::State, <Self as AttributePolygonGenerator<A>>::Output>ⓘNotable traits for Generate<'a, G, S, P>impl<'a, G, S, P> Iterator for Generate<'a, G, S, P> where
G: 'a, type Item = P;
where
Self: AttributePolygonGenerator<A>,
A: Attribute,
{ ... }
fn polygons_from<A>(
&self,
state: Self::State
) -> Generate<'_, Self, Self::State, <Self as AttributePolygonGenerator<A>>::Output>ⓘNotable traits for Generate<'a, G, S, P>impl<'a, G, S, P> Iterator for Generate<'a, G, S, P> where
G: 'a, type Item = P;
where
Self: AttributePolygonGenerator<A>,
A: Attribute,
{ ... }
fn indexing_polygons<A>(&self) -> Generate<'_, Self, (), Self::Output>ⓘNotable traits for Generate<'a, G, S, P>impl<'a, G, S, P> Iterator for Generate<'a, G, S, P> where
G: 'a, type Item = P;
where
Self: IndexingPolygonGenerator<A>,
A: Attribute,
{ ... }
}
Expand description
Functions for iterating over the topology and geometry of polytopes.
Provided Methods
Gets an iterator over the set of unique vertices with the given attribute data.
Each geometric attribute has an independent set of unique values. For
example, Cube
generates six unique surface normals and eight unique
positions.
This can be paired with the
indexing_polygons
function to index
the set of vertices.
Examples
use nalgebra::Point3;
use plexus::prelude::*;
use plexus::primitive::cube::Cube;
use plexus::primitive::generate::Position;
type E3 = Point3<f64>;
let cube = Cube::new();
let positions = cube.vertices::<Position<E3>>().collect::<Vec<_>>();
let indices = cube
.indexing_polygons::<Position>()
.triangulate()
.vertices()
.collect::<Vec<_>>();
fn vertices_from<A>(
&self,
state: Self::State
) -> Generate<'_, Self, Self::State, <Self as AttributeVertexGenerator<A>>::Output>ⓘNotable traits for Generate<'a, G, S, P>impl<'a, G, S, P> Iterator for Generate<'a, G, S, P> where
G: 'a, type Item = P;
where
Self: AttributeVertexGenerator<A>,
A: Attribute,
G: 'a, type Item = P;
Gets an iterator over the set of polygons with the given attribute data.
Examples
use decorum::R64;
use nalgebra::Point3;
use plexus::index::HashIndexer;
use plexus::prelude::*;
use plexus::primitive::cube::Cube;
use plexus::primitive::generate::Position;
use plexus::primitive::Tetragon;
let (indices, positions) = Cube::new()
.polygons::<Position<Point3<R64>>>()
.index_vertices::<Tetragon<usize>, _>(HashIndexer::default());
fn polygons_from<A>(
&self,
state: Self::State
) -> Generate<'_, Self, Self::State, <Self as AttributePolygonGenerator<A>>::Output>ⓘNotable traits for Generate<'a, G, S, P>impl<'a, G, S, P> Iterator for Generate<'a, G, S, P> where
G: 'a, type Item = P;
where
Self: AttributePolygonGenerator<A>,
A: Attribute,
G: 'a, type Item = P;
Gets an iterator over a set of polygons that index the unique set of vertices with the given attribute.
Indexing differs per geometric attribute, because each attribute has an
independent set of unique values. For example, Cube
generates six
unique surface normals and eight unique positions.
When used with meta-attribute types like Position
, input types are
not needed and default type parameters can be used instead. For example,
if Position<Point3<f64>>
is used to generate positional data, then
Position<()>
(or Position
) can be used to generate indexing
polygons.
Examples
use nalgebra::Point3;
use plexus::buffer::MeshBuffer4;
use plexus::prelude::*;
use plexus::primitive::cube::Cube;
use plexus::primitive::generate::Position;
type E3 = Point3<f64>;
let cube = Cube::new();
let buffer = MeshBuffer4::<usize, E3>::from_raw_buffers(
cube.indexing_polygons::<Position>(),
cube.vertices::<Position<E3>>(),
);