[][src]Struct voronoice::Voronoi

pub struct Voronoi { /* fields omitted */ }

The dual Delauney-Voronoi graph.

To obtain an instance of this type, use VoronoiBuilder.

Implementations

impl Voronoi[src]

pub fn sites(&self) -> &Vec<Point>[src]

Borrows an immutable reference to the sites associated with the Voronoi graph. This is a reference to the unaltered site-point collection provided for the construction of this Voronoi graph.

pub fn cell(&self, site: usize) -> VoronoiCell<'_>[src]

Gets a representation of a Voronoi cell based on its site index.

Examples

 use voronoice::*;
 let v = VoronoiBuilder::default()
     .generate_square_sites(10)
     .build()
     .unwrap();
 println!("The following are the positions for the Voronoi cell 0: {:?}",
     v.cell(0).vertices().collect::<Vec<&Point>>());

pub fn iter_cells<'v>(&'v self) -> impl Iterator<Item = VoronoiCell<'v>> + Clone[src]

Gets an iterator to walk through all Voronoi cells. Cells are iterated in order with the vector returned by Self::sites().

pub fn cells(&self) -> &Vec<Vec<usize>>[src]

Gets a vector of Voronoi cell vectors that index the cell vertex positions.

Consider using Self::iter_cells() or Self::cell() instead for a more ergonomic way of accessing cell information. Use cases for accessing this directly would include graphical applications where you need to build an index buffer for point positions.

Examples

 use voronoice::*;
 let v = VoronoiBuilder::default()
     .generate_square_sites(10)
     .build()
     .unwrap();
 let first_cell = v.cells().first().unwrap();
 let vertices = v.vertices();
 println!("The following are the positions for the Voronoi cell 0: {:?}",
     first_cell.iter().copied().map(|v| &vertices[v]).collect::<Vec<&Point>>());

pub fn vertices(&self) -> &Vec<Point>[src]

Gets the a vector of the Voronoi cell vertices. These vertices are indexed by Self::cells(). Consider using Self::iter_cells() or Self::cell() instead for a more ergonomic way of accessing cell information.

For a given Voronoi cell, its vertices are the circumcenters of its associated Delauney triangles. Values whose indexes are greater than sites.len() - 1 are not actual triangle circumcenters but Voronoi cell vertices added to "close" sites on the convex hull or otherwise used for clipping edges that fell outside the bounding box region.

Please see Self::cells() documentation for examples.

pub fn delauney_triangles(&self) -> &Vec<usize>[src]

Gets a reference to a vector of indices to sites where each triple represents a triangle on the dual Delauney triangulation associated with this Voronoi graph. All triangles are directed counter-clockwise.

Trait Implementations

impl Debug for Voronoi[src]

impl From<&'_ Voronoi> for VoronoiBuilder[src]

pub fn from(v: &Voronoi) -> Self[src]

Creates a builder with same configurations that produced the original voronoi. Useful for performing Lloyd relaxation or storing the configuration to generate a identical diagram.

impl From<Voronoi> for VoronoiBuilder[src]

pub fn from(v: Voronoi) -> Self[src]

Creates a builder with same configurations that produced the original voronoi, consuming it. Useful for performing Lloyd relaxation or storing the configuration to generate a identical diagram.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.