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§
sourcetype Index: VertexIndex + 'p
type Index: VertexIndex + 'p
A type used to uniquely identify a Vertex (e.g. usize for a Vec<[f32, f32]>)
Required Methods§
sourcefn vertex_count(&self) -> usize
fn vertex_count(&self) -> usize
Provides the number of vertices of the polygon.
sourcefn iter_indices<'i>(&'i self) -> Self::Iter<'i>where
Self: 'i,
Self::Vertex: 'i,
'p: 'i,
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.
sourcefn get_vertex(&self, index: Self::Index) -> &Self::Vertex
fn get_vertex(&self, index: Self::Index) -> &Self::Vertex
Get the Polygon::Vertex uniquely identified by the Polygon::Index value
Provided Methods§
sourcefn as_polygon_list(&self) -> &SinglePolygon<'p, Self>
fn as_polygon_list(&self) -> &SinglePolygon<'p, Self>
Treat this Polygon as a PolygonList containing a single polygon
sourcefn 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 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
sourcefn trapezoidize(
&'p self
) -> Result<Trapezoidation<'p, SinglePolygon<'p, Self>>, TrapezoidationError>
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.
sourcefn 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>>
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