pub struct Voronoi { /* private fields */ }
Expand description
The dual Delaunay-Voronoi graph.
To obtain an instance of this type, use VoronoiBuilder.
Implementations
sourceimpl Voronoi
impl Voronoi
sourcepub fn sites(&self) -> &Vec<Point>
pub fn sites(&self) -> &Vec<Point>
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.
sourcepub fn cell(&self, site: usize) -> VoronoiCell<'_>
pub fn cell(&self, site: usize) -> VoronoiCell<'_>
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).iter_vertices().collect::<Vec<&Point>>());
sourcepub fn iter_cells<'v>(&'v self) -> impl Iterator<Item = VoronoiCell<'v>> + Clone
pub fn iter_cells<'v>(&'v self) -> impl Iterator<Item = VoronoiCell<'v>> + Clone
Gets an iterator to walk through all Voronoi cells. Cells are iterated in order with the vector returned by Self::sites().
sourcepub fn cells(&self) -> &Vec<Vec<usize>>
pub fn cells(&self) -> &Vec<Vec<usize>>
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>>());
sourcepub fn vertices(&self) -> &Vec<Point>
pub fn vertices(&self) -> &Vec<Point>
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 Delaunay 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.
sourcepub fn triangulation(&self) -> &Triangulation
pub fn triangulation(&self) -> &Triangulation
Gets a reference to the underlying delaunay triangulation.
triangulation().triangles
is a vector of indices to sites where each triple represents a triangle on the dual Delaunay triangulation associated with this Voronoi graph.
All triangles are directed counter-clockwise.
sourcepub fn bounding_box(&self) -> &BoundingBox
pub fn bounding_box(&self) -> &BoundingBox
Gets a reference to the bounding box.
Trait Implementations
sourceimpl From<&'_ Voronoi> for VoronoiBuilder
impl From<&'_ Voronoi> for VoronoiBuilder
Auto Trait Implementations
impl RefUnwindSafe for Voronoi
impl Send for Voronoi
impl Sync for Voronoi
impl Unpin for Voronoi
impl UnwindSafe for Voronoi
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more