Trait triangulate::Polygon

source ·
pub trait Polygon<'p>: 'p + Sized {
    type Vertex: Vertex + 'p;
    type Index: VertexIndex + 'p;
    type Iter<'i>: Iterator<Item = Self::Index>
       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(&self, index: Self::Index) -> &Self::Vertex;

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

An indexable polygon’s vertices

Required Associated Types§

source

type Vertex: Vertex + 'p

The type of vertices of the polygon

source

type Index: VertexIndex + 'p

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

source

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

The Iterator type that Polygon::iter_indices returns

Required Methods§

source

fn vertex_count(&self) -> usize

Provides the number of vertices of the polygon.

source

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

Iterate through all Polygon::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 PolygonElement::NewPolygon value.

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

Successive PolygonElement::NewPolygons are idempotent, and PolygonElement::NewPolygon`s as the initial or final iteration values are not required and have no effect.

source

fn get_vertex(&self, index: Self::Index) -> &Self::Vertex

Get the Polygon::Vertex uniquely identified by the Polygon::Index value

Provided Methods§

source

fn as_polygon_list(&self) -> &SinglePolygon<'p, Self>

Treat this Polygon as a PolygonList containing a single polygon

source

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

Create a PolygonList with the Polygon::Index type substituted 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, SinglePolygon<'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 Polygon::triangulate.

source

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

Triangulate the polygon into the layout specified by format

Implementors§

source§

impl<'p, V: 'p + Vertex, T: 'p + Deref<Target = [V]>> Polygon<'p> for T

§

type Vertex = V

§

type Index = usize

§

type Iter<'i> where Self: 'i, Self::Vertex: 'i, 'p: 'i = Range<usize>