Struct startin::Triangulation

source ·
#[repr(C)]
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

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

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.

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 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 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(&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(&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 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 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§

default 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>,

§

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>,

§

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.