pub struct VoronoiCell<'v> { /* private fields */ }
Expand description

Represents a Voronoi cell. This is an ergonomic way to access cell details.

Use Voronoi::cell() or Voronoi::iter_cells() to obtain an instance of this type.

Implementations

Gets a reference to the position of the site associated with this cell.

Examples
 use voronoice::*;
 let sites = vec![Point { x: 0.0, y: 0.0 }, Point { x: 0.5, y: 0.0 }, Point { x: 0.0, y: 0.5 }];
 let v = VoronoiBuilder::default()
     .set_sites(sites.clone())
     .build()
     .unwrap();
 // the first site generated by generate_circle_sites is at the origin
 assert_eq!(&sites[0], v.cell(0).site_position());
 assert_eq!(&sites[1], v.cell(1).site_position());
 assert_eq!(&sites[2], v.cell(2).site_position());

Gets the index associated with the site for this cell.

Gets a slice of indices into Voronoi::vertices used to index the Points representing the voronoi cell vertices.

Semantically these values represent the Delaunay triangles associated with this voronoi cell. The Voronoi cell vertices are the circumcenters of the associated Delaunay triangles.

If this cell is on the hull of the diagram (cell.is_on_hull() == true), or has had one of its edges clipped, some indices will not match to Delaunay triangles, but to virtual points added during the process of hull closing and clipping. These values will still correctly index into the Voronoi::vertices() vector.

Gets an iterator for the vertices of this cell.

Vertices are returned in sequential counter-clockwise order. Please see Self::triangles and Voronoi::vertices for additional details regarding hull closing and clipping effects on vertices.

Gets an iterator that returns the index of each site that shared an edge with this cell/site, in a counter-clockwise manner.

Example
 use voronoice::*;
 let sites = vec![Point { x: -0.5, y: 0.0 }, Point { x: 0.5, y: 0.0 }, Point { x: 0.0, y: 0.0 }, Point { x: 0.0, y: 0.5 }, Point { x: 0.0, y: -0.5 }];
 let v = VoronoiBuilder::default()
     .set_sites(sites.clone())
     .build()
     .unwrap();
 let neighbors: Vec<usize> = v.cell(0).iter_neighbors().collect();
 assert_eq!(neighbors[0], 4);
 assert_eq!(neighbors[1], 2);
 assert_eq!(neighbors[2], 3);

Gets an iterator that returns the shortest path on the Voronoi diagram to the destination point, starting from the current cell.

Returns a boolean indicating whether this cell is on the hull (edge) of the diagram.

A Voronoi cell is on the hull if its associated site is on the Delaunay hull or if clipping is enabled and the cell intersects with the bounding box.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.