# [−][src]Trait plexus::primitive::generate::Generator

pub trait Generator: Sized {
fn vertices<A>(&self) -> Generate<Self, Self::State, Self::Output>    where        Self: AttributeVertexGenerator<A>,        A: Attribute,
{ ... }
fn vertices_from<A>(        &self,         state: Self::State    ) -> Generate<Self, Self::State, Self::Output>    where        Self: AttributeVertexGenerator<A>,        A: Attribute,
{ ... }
fn polygons<A>(&self) -> Generate<Self, Self::State, Self::Output>    where        Self: AttributePolygonGenerator<A>,        A: Attribute,
{ ... }
fn polygons_from<A>(        &self,         state: Self::State    ) -> Generate<Self, Self::State, Self::Output>    where        Self: AttributePolygonGenerator<A>,        A: Attribute,
{ ... }
fn indexing_polygons<A>(&self) -> Generate<Self, (), Self::Output>    where        Self: IndexingPolygonGenerator<A>,        A: Attribute,
{ ... }
}

Functions for iterating over the topological structures of generators.

## Provided methods

### fn vertices<A>(&self) -> Generate<Self, Self::State, Self::Output> where    Self: AttributeVertexGenerator<A>,    A: Attribute,

Provides 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 polygons<A>(&self) -> Generate<Self, Self::State, Self::Output> where    Self: AttributePolygonGenerator<A>,    A: Attribute,

Provides an iterator over the set of polygons with the given attribute data.

# Examples

use decorum::N64;
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<N64>>>()
.index_vertices::<Tetragon<usize>, _>(HashIndexer::default());

### fn indexing_polygons<A>(&self) -> Generate<Self, (), Self::Output> where    Self: IndexingPolygonGenerator<A>,    A: Attribute,

Provides 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;

let cube = Cube::new();
let buffer = MeshBuffer4::<usize, _>::from_raw_buffers(
cube.indexing_polygons::<Position>(),
cube.vertices::<Position<Point3<f64>>>(),
);