Struct startin::Triangulation
source · #[repr(C)]pub struct Triangulation { /* private fields */ }
Expand description
Represents a triangulation
Implementations§
source§impl Triangulation
impl Triangulation
pub fn new() -> Triangulation
sourcepub fn set_snap_tolerance(&mut self, snaptol: f64) -> f64
pub fn set_snap_tolerance(&mut self, snaptol: f64) -> f64
Set a snap tolerance when inserting new points: if the newly inserted
one is closer than snap_tol
to another one, then it is not inserted.
Avoids having very close vertices (like at 0.00007mm)
Default is 0.001unit (thus 1mm for most datasets).
pub fn get_snap_tolerance(&self) -> f64
sourcepub fn set_jump_and_walk(&mut self, b: bool)
pub fn set_jump_and_walk(&mut self, b: bool)
Activate/deactive the jump-and-walk strategy for Triangulation::locate()
.
(deactivated by default)
If deactivated, then the walk starts from the last inserted triangle.
sourcepub fn is_using_robust_predicates(&self) -> bool
pub fn is_using_robust_predicates(&self) -> bool
Is using robut predicates (with crate robust)? (activated by default)
sourcepub fn use_robust_predicates(&mut self, b: bool)
pub fn use_robust_predicates(&mut self, b: bool)
Activate/deactivate robust predictates
sourcepub fn insert(&mut self, pts: &Vec<[f64; 3]>, strategy: InsertionStrategy)
pub fn insert(&mut self, pts: &Vec<[f64; 3]>, strategy: InsertionStrategy)
Insert a Vec
of array
([f64; 3]
) values.
If InsertionStrategy::AsIs
is used, then Triangulation::insert_one_pt()
is called
for each point in the order given.
Arguments
pts
- aVec
of[f64; 3]
strategy
- theInsertionStrategy
to use for the insertion
sourcepub fn insert_one_pt(
&mut self,
px: f64,
py: f64,
pz: f64
) -> Result<usize, usize>
pub fn insert_one_pt( &mut self, px: f64, py: f64, pz: f64 ) -> Result<usize, usize>
Insert the point (px
, py
, pz
) in the triangulation.
Returns the vertex ID of the point if the vertex didn’t exist.
If there was a vertex at that location, an Error is thrown with the already
existing vertex ID.
sourcepub fn get_point(&self, vi: usize) -> Result<Vec<f64>, StartinError>
pub fn get_point(&self, vi: usize) -> Result<Vec<f64>, StartinError>
Returns the coordinates of the vertex v.
A StartinError
is returned if vi
doesn’t exist
or is a removed vertex.
sourcepub fn adjacent_triangles_to_triangle(
&self,
tr: &Triangle
) -> Result<Vec<Triangle>, StartinError>
pub fn adjacent_triangles_to_triangle( &self, tr: &Triangle ) -> Result<Vec<Triangle>, StartinError>
Returns the 3 adjacents (finite + infinite) Triangle
to a triangle.
sourcepub fn incident_triangles_to_vertex(
&self,
vi: usize
) -> Result<Vec<Triangle>, StartinError>
pub fn incident_triangles_to_vertex( &self, vi: usize ) -> Result<Vec<Triangle>, StartinError>
sourcepub fn degree(&self, vi: usize) -> Result<usize, StartinError>
pub fn degree(&self, vi: usize) -> Result<usize, StartinError>
Returns the degree of the vertex with ID vi
.
sourcepub fn adjacent_vertices_to_vertex(
&self,
vi: usize
) -> Result<Vec<usize>, StartinError>
pub fn adjacent_vertices_to_vertex( &self, vi: usize ) -> Result<Vec<usize>, StartinError>
Returns a list (Vec<usize>
) (ordered CCW) of the adjacent vertices to vi
.
sourcepub fn is_triangle(&self, tr: &Triangle) -> bool
pub fn is_triangle(&self, tr: &Triangle) -> bool
Returns whether a triplet of indices is a Triangle
in the triangulation.
sourcepub fn statistics_degree(&self) -> (f64, usize, usize)
pub fn statistics_degree(&self) -> (f64, usize, usize)
Returns some statistics about the triangulation.
sourcepub fn number_of_vertices(&self) -> usize
pub fn number_of_vertices(&self) -> usize
Returns number of finite vertices in the triangulation. The removed vertices are not counted.
sourcepub fn number_of_triangles(&self) -> usize
pub fn number_of_triangles(&self) -> usize
Returns number of finite triangles in the triangulation.
sourcepub fn number_of_removed_vertices(&self) -> usize
pub fn number_of_removed_vertices(&self) -> usize
Returns the number of vertices which are marked as “removed”
sourcepub fn is_vertex_removed(&self, vi: usize) -> Result<bool, StartinError>
pub fn is_vertex_removed(&self, vi: usize) -> Result<bool, StartinError>
Returns whether the vertex vi
is removed or not.
sourcepub fn convex_hull(&self) -> Vec<usize>
pub fn convex_hull(&self) -> Vec<usize>
Returns the convex hull of the dataset, oriented CCW. It is a list of vertex indices (first != last)
sourcepub fn number_of_vertices_on_convex_hull(&self) -> usize
pub fn number_of_vertices_on_convex_hull(&self) -> usize
Returns the size (ie the number of vertices) of the convex hull of the dataset
sourcepub fn is_vertex_convex_hull(&self, vi: usize) -> bool
pub fn is_vertex_convex_hull(&self, vi: usize) -> bool
Returns true
if the vertex vi
is part of the boundary of the convex
hull of the dataset; false
otherwise.
sourcepub fn locate(&self, px: f64, py: f64) -> Result<Triangle, StartinError>
pub fn locate(&self, px: f64, py: f64) -> Result<Triangle, StartinError>
Returns, if it exists, the Triangle
containing (px, py)
.
If it is direction on a vertex/edge, then one is randomly chosen.
sourcepub fn closest_point(&self, px: f64, py: f64) -> Result<usize, StartinError>
pub fn closest_point(&self, px: f64, py: f64) -> Result<usize, StartinError>
Returns closest point (in 2D) to a query point (x, y)
.
if (px, py)
is outside the convex hull then StartinError::OutsideConvexHull
is raised.
sourcepub fn all_vertices(&self) -> Vec<Vec<f64>>
pub fn all_vertices(&self) -> Vec<Vec<f64>>
sourcepub fn all_finite_edges(&self) -> Vec<usize>
pub fn all_finite_edges(&self) -> Vec<usize>
sourcepub fn all_triangles(&self) -> Vec<Triangle>
pub fn all_triangles(&self) -> Vec<Triangle>
sourcepub fn all_finite_triangles(&self) -> Vec<Triangle>
pub fn all_finite_triangles(&self) -> Vec<Triangle>
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Validates the Delaunay triangulation: (1) checks each triangle against each vertex (circumcircle tests); very slow (2) checks whether the convex hull is really convex
sourcepub fn remove(&mut self, vi: usize) -> Result<usize, StartinError>
pub fn remove(&mut self, vi: usize) -> Result<usize, StartinError>
Removes the vertex vi
from the Triangulation
and updates for the “Delaunay-ness”.
The vertex is not removed from memory but flagged as removed, thus all the other vertices keep their IDs. The following insertion of a point will reuse this ID. It is therefore possible to have an array that contains unused/removed vertices.
sourcepub fn printme(&self, withxyz: bool) -> String
pub fn printme(&self, withxyz: bool) -> String
Returns a String
containing different statistics about the triangulation.
sourcepub fn voronoi_cell_area(&self, vi: usize, ignore_infinity: bool) -> Option<f64>
pub fn voronoi_cell_area(&self, vi: usize, ignore_infinity: bool) -> Option<f64>
Returns the area of the Voronoi cell of vi
.
Arguments
vi
- the index of the vertexignore_infinity
- calculate the area even isvi
is on the convex hull. This is used byinterpolation::NNI
when neighbours have no area, this bounds arbitrarily the area and because we take the different the interpolated value is the same at the end.
sourcepub fn get_bbox(&self) -> Vec<f64>
pub fn get_bbox(&self) -> Vec<f64>
Returns the (axis-aligned) bounding box of the triangulation.
sourcepub fn vertical_exaggeration(&mut self, factor: f64)
pub fn vertical_exaggeration(&mut self, factor: f64)
Exaggerates vertically the z-values, used for visualisation mostly.
The value can be <1.0 to have negative exaggeration.
pub fn has_garbage(&self) -> bool
sourcepub fn collect_garbage(&mut self)
pub fn collect_garbage(&mut self)
Collect garbage, that is remove from memory the vertices marked as removed.
Watch out: the vertices get new IDs (and thus the triangles) too. And this can be a slow operation.