pub trait Subdiv2DTrait: Subdiv2DTraitConst {
// Required method
fn as_raw_mut_Subdiv2D(&mut self) -> *mut c_void;
// Provided methods
fn init_delaunay(&mut self, rect: Rect) -> Result<()> { ... }
fn insert(&mut self, pt: Point2f) -> Result<i32> { ... }
fn insert_multiple(&mut self, ptvec: &Vector<Point2f>) -> Result<()> { ... }
fn locate(
&mut self,
pt: Point2f,
edge: &mut i32,
vertex: &mut i32,
) -> Result<i32> { ... }
fn find_nearest(
&mut self,
pt: Point2f,
nearest_pt: &mut Point2f,
) -> Result<i32> { ... }
fn find_nearest_def(&mut self, pt: Point2f) -> Result<i32> { ... }
fn get_voronoi_facet_list(
&mut self,
idx: &Vector<i32>,
facet_list: &mut Vector<Vector<Point2f>>,
facet_centers: &mut Vector<Point2f>,
) -> Result<()> { ... }
}
Expand description
Mutable methods for crate::imgproc::Subdiv2D
Required Methods§
fn as_raw_mut_Subdiv2D(&mut self) -> *mut c_void
Provided Methods§
Sourcefn init_delaunay(&mut self, rect: Rect) -> Result<()>
fn init_delaunay(&mut self, rect: Rect) -> Result<()>
Creates a new empty Delaunay subdivision
§Parameters
- rect: Rectangle that includes all of the 2D points that are to be added to the subdivision.
Sourcefn insert(&mut self, pt: Point2f) -> Result<i32>
fn insert(&mut self, pt: Point2f) -> Result<i32>
Insert a single point into a Delaunay triangulation.
§Parameters
- pt: Point to insert.
The function inserts a single point into a subdivision and modifies the subdivision topology appropriately. If a point with the same coordinates exists already, no new point is added.
§Returns
the ID of the point.
Note: If the point is outside of the triangulation specified rect a runtime error is raised.
Sourcefn insert_multiple(&mut self, ptvec: &Vector<Point2f>) -> Result<()>
fn insert_multiple(&mut self, ptvec: &Vector<Point2f>) -> Result<()>
Insert multiple points into a Delaunay triangulation.
§Parameters
- ptvec: Points to insert.
The function inserts a vector of points into a subdivision and modifies the subdivision topology appropriately.
Sourcefn locate(
&mut self,
pt: Point2f,
edge: &mut i32,
vertex: &mut i32,
) -> Result<i32>
fn locate( &mut self, pt: Point2f, edge: &mut i32, vertex: &mut i32, ) -> Result<i32>
Returns the location of a point within a Delaunay triangulation.
§Parameters
- pt: Point to locate.
- edge: Output edge that the point belongs to or is located to the right of it.
- vertex: Optional output vertex the input point coincides with.
The function locates the input point within the subdivision and gives one of the triangle edges or vertices.
§Returns
an integer which specify one of the following five cases for point location:
- The point falls into some facet. The function returns [PTLOC_INSIDE] and edge will contain one of edges of the facet.
- The point falls onto the edge. The function returns [PTLOC_ON_EDGE] and edge will contain this edge.
- The point coincides with one of the subdivision vertices. The function returns [PTLOC_VERTEX] and vertex will contain a pointer to the vertex.
- The point is outside the subdivision reference rectangle. The function returns [PTLOC_OUTSIDE_RECT] and no pointers are filled.
- One of input arguments is invalid. A runtime error is raised or, if silent or “parent” error processing mode is selected, [PTLOC_ERROR] is returned.
Sourcefn find_nearest(&mut self, pt: Point2f, nearest_pt: &mut Point2f) -> Result<i32>
fn find_nearest(&mut self, pt: Point2f, nearest_pt: &mut Point2f) -> Result<i32>
Finds the subdivision vertex closest to the given point.
§Parameters
- pt: Input point.
- nearestPt: Output subdivision vertex point.
The function is another function that locates the input point within the subdivision. It finds the subdivision vertex that is the closest to the input point. It is not necessarily one of vertices of the facet containing the input point, though the facet (located using locate() ) is used as a starting point.
§Returns
vertex ID.
§C++ default parameters
- nearest_pt: 0
Sourcefn find_nearest_def(&mut self, pt: Point2f) -> Result<i32>
fn find_nearest_def(&mut self, pt: Point2f) -> Result<i32>
Finds the subdivision vertex closest to the given point.
§Parameters
- pt: Input point.
- nearestPt: Output subdivision vertex point.
The function is another function that locates the input point within the subdivision. It finds the subdivision vertex that is the closest to the input point. It is not necessarily one of vertices of the facet containing the input point, though the facet (located using locate() ) is used as a starting point.
§Returns
vertex ID.
§Note
This alternative version of Subdiv2DTrait::find_nearest function uses the following default values for its arguments:
- nearest_pt: 0
Sourcefn get_voronoi_facet_list(
&mut self,
idx: &Vector<i32>,
facet_list: &mut Vector<Vector<Point2f>>,
facet_centers: &mut Vector<Point2f>,
) -> Result<()>
fn get_voronoi_facet_list( &mut self, idx: &Vector<i32>, facet_list: &mut Vector<Vector<Point2f>>, facet_centers: &mut Vector<Point2f>, ) -> Result<()>
Returns a list of all Voronoi facets.
§Parameters
- idx: Vector of vertices IDs to consider. For all vertices you can pass empty vector.
- facetList: Output vector of the Voronoi facets.
- facetCenters: Output vector of the Voronoi facets center points.