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).
Sourcepub fn get_snap_tolerance(&self) -> f64
pub fn get_snap_tolerance(&self) -> f64
Get the snap tolerance for the insertion of new points. Default is 0.001unit (thus 1mm for most datasets).
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.
pub fn get_jump_and_walk(&self) -> bool
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 set_duplicates_handling(&mut self, method: DuplicateHandling)
pub fn set_duplicates_handling(&mut self, method: DuplicateHandling)
Set the method to used to handle duplicates (Last by default)
Sourcepub fn get_duplicates_handling(&self) -> String
pub fn get_duplicates_handling(&self) -> String
Get the method to used to handle duplicates
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- aVecof[f64; 3]strategy- theInsertionStrategyto use for the insertion
Sourcepub fn insert_one_pt(
&mut self,
px: f64,
py: f64,
pz: f64,
) -> Result<usize, (usize, bool)>
pub fn insert_one_pt( &mut self, px: f64, py: f64, pz: f64, ) -> Result<usize, (usize, bool)>
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 a tuple
indicating 1) the vertex ID of the existing vertex; 2) true/false whether the
z-value and attributes were updated.
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 get_attributes_schema(&self) -> Vec<(String, String)>
pub fn get_attributes_schema(&self) -> Vec<(String, String)>
TODO: write the docs
Sourcepub fn set_attributes_schema(
&mut self,
att_schema: Vec<(String, String)>,
) -> Result<(), StartinError>
pub fn set_attributes_schema( &mut self, att_schema: Vec<(String, String)>, ) -> Result<(), StartinError>
Configure the extra attributes that each vertex can store. Each entry is a name (eg “classification”) and a data type (the allowed types are: “f64”, “i64”, “u64”, “bool”, and “String” (given as a String)). This resets all the extra attributes that were potentially stored with a previous schema.
pub fn get_vertex_attributes(&self, vi: usize) -> Result<Value, StartinError>
pub fn add_vertex_attributes( &mut self, vi: usize, a: Value, ) -> Result<bool, StartinError>
Sourcepub fn all_attributes(&self) -> Option<Vec<Value>>
pub fn all_attributes(&self) -> Option<Vec<Value>>
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 normal_vertex(&self, vi: usize) -> Result<Vec<f64>, StartinError>
pub fn normal_vertex(&self, vi: usize) -> Result<Vec<f64>, StartinError>
Returns the normal of the vertex with ID vi.
pub fn normal_triangle(&self, tr: &Triangle) -> Result<Vec<f64>, StartinError>
pub fn area2d_triangle(&self, tr: &Triangle) -> Result<f64, StartinError>
pub fn area3d_triangle(&self, tr: &Triangle) -> Result<f64, StartinError>
pub fn volume_triangle( &self, tr: &Triangle, planez: f64, ) -> Result<f64, 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(&mut self, px: f64, py: f64) -> Result<Triangle, StartinError>
pub fn locate(&mut 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(&mut self, px: f64, py: f64) -> Result<usize, StartinError>
pub fn closest_point(&mut 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 isviis on the convex hull. This is used byinterpolation::NNIwhen 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.
Sourcepub fn update_vertex_z_value(
&mut self,
vi: usize,
z: f64,
) -> Result<bool, StartinError>
pub fn update_vertex_z_value( &mut self, vi: usize, z: f64, ) -> Result<bool, StartinError>
Update/set the z-value for a given vertex
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.