pub trait PolygonList<'p>: 'p {
    type Vertex: Vertex + 'p;
    type Index: VertexIndex + 'p;
    type IntoItem: Into<PolygonElement<Self::Index>>;
    type Iter<'i>: Iterator<Item = Self::IntoItem>
       where Self: 'i,
             Self::Vertex: 'i,
             'p: 'i;

    // Required methods
    fn vertex_count(&self) -> usize;
    fn iter_indices<'i>(&'i self) -> Self::Iter<'i>
       where Self: 'i,
             Self::Vertex: 'i,
             'p: 'i;
    fn get_vertex<'a>(&'a self, index: Self::Index) -> &'a Self::Vertex
       where 'p: 'a;

    // Provided methods
    fn index_with<Old: TryInto<New>, New: TryInto<Old>>(
        self
    ) -> IndexWith<'p, Self, Self::Index, Old, New>
       where Self: Sized,
             Self::Index: VertexIndex + Mappable<Old>,
             <Self::Index as Mappable<Old>>::Output<New>: VertexIndex + Mappable<New, Output<Old> = Self::Index> { ... }
    fn trapezoidize(
        &'p self
    ) -> Result<Trapezoidation<'p, Self>, TrapezoidationError> { ... }
    fn triangulate<FB: FanFormat<'p, Self>>(
        &'p self,
        format: FB
    ) -> Result<<FB::Builder as FanBuilder<'p, Self>>::Output, TriangulationError<<FB::Builder as FanBuilder<'p, Self>>::Error>> { ... }
}
Expand description

An indexable list of polygons and their vertices

Required Associated Types§

source

type Vertex: Vertex + 'p

The type of vertices of the polygons

source

type Index: VertexIndex + 'p

A type used to uniquely identify a Vertex (e.g. [usize; 2] for a Vec<Vec<[f32, f32]>>)

source

type IntoItem: Into<PolygonElement<Self::Index>>

source

type Iter<'i>: Iterator<Item = Self::IntoItem> where Self: 'i, Self::Vertex: 'i, 'p: 'i

The Iterator type that PolygonList::iter_indices returns

Required Methods§

source

fn vertex_count(&self) -> usize

Provides the total number of vertices among all polygons.

source

fn iter_indices<'i>(&'i self) -> Self::Iter<'i>where Self: 'i, Self::Vertex: 'i, 'p: 'i,

Iterate through all Indexes of all polygons. Indices must be returned in either clockwise or counter-clockwise order, without repeating the initial index. Between each polygon, implementers must return a NewPolygon value.

ContinuePolygon values must be yielded in successive groups of at least 3, otherwise triangulation will fail.

Successive NewPolygons are idempotent, and NewPolygons as the initial or final iteration values have no effect.

source

fn get_vertex<'a>(&'a self, index: Self::Index) -> &'a Self::Vertexwhere 'p: 'a,

Get the PolygonList::Vertex uniquely identified by index

Provided Methods§

source

fn index_with<Old: TryInto<New>, New: TryInto<Old>>( self ) -> IndexWith<'p, Self, Self::Index, Old, New>where Self: Sized, Self::Index: VertexIndex + Mappable<Old>, <Self::Index as Mappable<Old>>::Output<New>: VertexIndex + Mappable<New, Output<Old> = Self::Index>,

Substitute the PolygonList::Index type with another.

The old index type must be convertable via TryInto to the new index type, and vice versa, but will panic if the conversion fails

source

fn trapezoidize( &'p self ) -> Result<Trapezoidation<'p, Self>, TrapezoidationError>

Generate a Trapezoidation, which can later be triangulated.

Unless the Trapezoidation is needed for other reasons, this can be done in a single step with PolygonList::triangulate.

source

fn triangulate<FB: FanFormat<'p, Self>>( &'p self, format: FB ) -> Result<<FB::Builder as FanBuilder<'p, Self>>::Output, TriangulationError<<FB::Builder as FanBuilder<'p, Self>>::Error>>

Triangulate the polygons into the layout specified by format

Implementors§

source§

impl<'p, P: PolygonList<'p, Index = OldIndex>, OldIndex: VertexIndex + Mappable<Old>, New: TryInto<Old>, Old: TryInto<New>> PolygonList<'p> for IndexWith<'p, P, OldIndex, Old, New>where OldIndex::Output<New>: VertexIndex + Mappable<New, Output<Old> = OldIndex>,

§

type Vertex = <P as PolygonList<'p>>::Vertex

§

type Index = <OldIndex as Mappable<Old>>::Output<New>

§

type IntoItem = PolygonElement<<IndexWith<'p, P, OldIndex, Old, New> as PolygonList<'p>>::Index>

§

type Iter<'i> where Self: 'i, 'p: 'i = IndexWithIter<'i, <P as PolygonList<'p>>::Iter<'i>, OldIndex, New, Old>

source§

impl<'p, V: Vertex + 'p, P: 'p + Polygon<'p, Vertex = V, Index = usize>, D: 'p + Deref<Target = [P]>> PolygonList<'p> for D

§

type Vertex = V

§

type Index = [usize; 2]

§

type IntoItem = PolygonElement<<D as PolygonList<'p>>::Index>

§

type Iter<'i> where Self: 'i, Self::Vertex: 'i, 'p: 'i = VecVecIter<'i, 'p, V, P>