Triangulation

Struct Triangulation 

Source
pub struct Triangulation { /* private fields */ }
Expand description

Represents a triangulation

Implementations§

Source§

impl Triangulation

Source

pub fn new() -> Triangulation

Source

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).

Source

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).

Source

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.

Source

pub fn get_jump_and_walk(&self) -> bool

Source

pub fn is_using_robust_predicates(&self) -> bool

Is using robut predicates (with crate robust)? (activated by default)

Source

pub fn use_robust_predicates(&mut self, b: bool)

Activate/deactivate robust predictates

Source

pub fn set_duplicates_handling(&mut self, method: DuplicateHandling)

Set the method to used to handle duplicates (Last by default)

Source

pub fn get_duplicates_handling(&self) -> String

Get the method to used to handle duplicates

Source

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
Source

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.

Source

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.

Source

pub fn get_attributes_schema(&self) -> Vec<(String, String)>

TODO: write the docs

Source

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.

Source

pub fn get_vertex_attributes(&self, vi: usize) -> Result<Value, StartinError>

Source

pub fn add_vertex_attributes( &mut self, vi: usize, a: Value, ) -> Result<bool, StartinError>

Source

pub fn all_attributes(&self) -> Option<Vec<Value>>

Returns a Vec<Vec<Value>> of all the vertex attributes (including the infinite one and the removed ones)

Source

pub fn adjacent_triangles_to_triangle( &self, tr: &Triangle, ) -> Result<Vec<Triangle>, StartinError>

Returns the 3 adjacents (finite + infinite) Triangle to a triangle.

Source

pub fn incident_triangles_to_vertex( &self, vi: usize, ) -> Result<Vec<Triangle>, StartinError>

Returns a Vec of Triangles (finite + infinite) to the vertex vi.

Source

pub fn normal_vertex(&self, vi: usize) -> Result<Vec<f64>, StartinError>

Returns the normal of the vertex with ID vi.

Source

pub fn normal_triangle(&self, tr: &Triangle) -> Result<Vec<f64>, StartinError>

Source

pub fn area2d_triangle(&self, tr: &Triangle) -> Result<f64, StartinError>

Source

pub fn area3d_triangle(&self, tr: &Triangle) -> Result<f64, StartinError>

Source

pub fn volume_triangle( &self, tr: &Triangle, planez: f64, ) -> Result<f64, StartinError>

Source

pub fn degree(&self, vi: usize) -> Result<usize, StartinError>

Returns the degree of the vertex with ID vi.

Source

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.

Source

pub fn is_triangle(&self, tr: &Triangle) -> bool

Returns whether a triplet of indices is a Triangle in the triangulation.

Source

pub fn is_finite(&self, tr: &Triangle) -> bool

Returns whether a Triangle is finite, or not

Source

pub fn statistics_degree(&self) -> (f64, usize, usize)

Returns some statistics about the triangulation.

Source

pub fn number_of_vertices(&self) -> usize

Returns number of finite vertices in the triangulation. The removed vertices are not counted.

Source

pub fn number_of_triangles(&self) -> usize

Returns number of finite triangles in the triangulation.

Source

pub fn number_of_removed_vertices(&self) -> usize

Returns the number of vertices which are marked as “removed”

Source

pub fn is_vertex_removed(&self, vi: usize) -> Result<bool, StartinError>

Returns whether the vertex vi is removed or not.

Source

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)

Source

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

Source

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.

Source

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.

Source

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.

Source

pub fn all_vertices(&self) -> Vec<Vec<f64>>

Returns a Vec<Vec<f64>> of all the vertices (including the infinite one and the removed ones)

Source

pub fn all_finite_edges(&self) -> Vec<usize>

Returns a Vec<usize> of all the finite edges (implicitly grouped by 2)

Source

pub fn all_triangles(&self) -> Vec<Triangle>

Returns a Vec<Triangle> of all the (finite + infinite) triangles

Source

pub fn all_finite_triangles(&self) -> Vec<Triangle>

Returns a Vec<Triangle> of all the finite triangles

Source

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

Source

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.

Source

pub fn write_obj(&self, path: String) -> Result<()>

Write an OBJ file to disk.

Source

pub fn write_ply(&self, path: String) -> Result<()>

Write a PLY file to disk.

Source

pub fn printme(&self, withxyz: bool) -> String

Returns a String containing different statistics about the triangulation.

Source

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 vertex
  • ignore_infinity - calculate the area even is vi is on the convex hull. This is used by interpolation::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.
Source

pub fn get_bbox(&self) -> Vec<f64>

Returns the (axis-aligned) bounding box of the triangulation.

Source

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.

Source

pub fn update_vertex_z_value( &mut self, vi: usize, z: f64, ) -> Result<bool, StartinError>

Update/set the z-value for a given vertex

Source

pub fn has_garbage(&self) -> bool

Source

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.

Trait Implementations§

Source§

impl Default for Triangulation

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Triangulation

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.