Table of Contents

Class Subdiv2D

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

Planar Subdivision

public class Subdiv2D : DisposableCvObject, IDisposable, ICvPtrHolder
Inheritance
Subdiv2D
Implements
Inherited Members

Constructors

Subdiv2D()

Creates an empty Subdiv2D object. To create a new empty Delaunay subdivision you need to use the #initDelaunay function.

public Subdiv2D()

Subdiv2D(Rect)

Creates an empty Subdiv2D object.

public Subdiv2D(Rect rect)

Parameters

rect Rect

Rectangle that includes all of the 2D points that are to be added to the subdivision.

Subdiv2D(Rect2f)

Creates an empty Subdiv2D object.

public Subdiv2D(Rect2f rect)

Parameters

rect Rect2f

Rectangle that includes all of the 2D points that are to be added to the subdivision.

Fields

NEXT_AROUND_DST

public const int NEXT_AROUND_DST = 34

Field Value

int

NEXT_AROUND_LEFT

public const int NEXT_AROUND_LEFT = 19

Field Value

int

NEXT_AROUND_ORG

public const int NEXT_AROUND_ORG = 0

Field Value

int

NEXT_AROUND_RIGHT

public const int NEXT_AROUND_RIGHT = 49

Field Value

int

PREV_AROUND_DST

public const int PREV_AROUND_DST = 51

Field Value

int

PREV_AROUND_LEFT

public const int PREV_AROUND_LEFT = 32

Field Value

int

PREV_AROUND_ORG

public const int PREV_AROUND_ORG = 17

Field Value

int

PREV_AROUND_RIGHT

public const int PREV_AROUND_RIGHT = 2

Field Value

int

PTLOC_ERROR

public const int PTLOC_ERROR = -2

Field Value

int

PTLOC_INSIDE

public const int PTLOC_INSIDE = 0

Field Value

int

PTLOC_ON_EDGE

public const int PTLOC_ON_EDGE = 2

Field Value

int

PTLOC_OUTSIDE_RECT

public const int PTLOC_OUTSIDE_RECT = -1

Field Value

int

PTLOC_VERTEX

public const int PTLOC_VERTEX = 1

Field Value

int

Methods

DisposeUnmanaged()

Releases unmanaged resources

protected override void DisposeUnmanaged()

EdgeDst(int, out Point2f)

Returns the edge destination.

public int EdgeDst(int edge, out Point2f dstPt)

Parameters

edge int

Subdivision edge ID.

dstPt Point2f

Output vertex location.

Returns

int

vertex ID.

EdgeOrg(int, out Point2f)

Returns the edge origin.

public int EdgeOrg(int edge, out Point2f orgPt)

Parameters

edge int

Subdivision edge ID.

orgPt Point2f

Output vertex location.

Returns

int

vertex ID.

FindNearest(Point2f, out Point2f)

Finds the subdivision vertex closest to the given point.

public int FindNearest(Point2f pt, out Point2f nearestPt)

Parameters

pt Point2f

Input point.

nearestPt Point2f

Output subdivision vertex point.

Returns

int

vertex ID.

GetEdge(int, NextEdgeType)

Returns one of the edges related to the given edge.

public int GetEdge(int edge, NextEdgeType nextEdgeType)

Parameters

edge int

Subdivision edge ID.

nextEdgeType NextEdgeType

Parameter specifying which of the related edges to return. The following values are possible: - NEXT_AROUND_ORG next around the edge origin ( eOnext on the picture below if e is the input edge) - NEXT_AROUND_DST next around the edge vertex ( eDnext ) - PREV_AROUND_ORG previous around the edge origin (reversed eRnext ) - PREV_AROUND_DST previous around the edge destination (reversed eLnext ) - NEXT_AROUND_LEFT next around the left facet ( eLnext ) - NEXT_AROUND_RIGHT next around the right facet ( eRnext ) - PREV_AROUND_LEFT previous around the left facet (reversed eOnext ) - PREV_AROUND_RIGHT previous around the right facet (reversed eDnext )

Returns

int

GetEdgeList()

Returns a list of all edges.

public Vec4f[] GetEdgeList()

Returns

Vec4f[]

Output vector.

GetLeadingEdgeList()

Returns a list of the leading edge ID connected to each triangle. The function gives one edge ID for each triangle.

public int[] GetLeadingEdgeList()

Returns

int[]

Output vector.

GetTriangleList()

Returns a list of all triangles.

public Vec6f[] GetTriangleList()

Returns

Vec6f[]

Output vector.

GetVertex(int, out int)

Returns vertex location from vertex ID.

public Point2f GetVertex(int vertex, out int firstEdge)

Parameters

vertex int

vertex ID.

firstEdge int

The first edge ID which is connected to the vertex.

Returns

Point2f

vertex (x,y)

GetVoronoiFacetList(IEnumerable<int>?, out Point2f[][], out Point2f[])

Returns a list of all Voronoi facets.

public void GetVoronoiFacetList(IEnumerable<int>? idx, out Point2f[][] facetList, out Point2f[] facetCenters)

Parameters

idx IEnumerable<int>

Vector of vertices IDs to consider. For all vertices you can pass empty vector.

facetList Point2f[][]

Output vector of the Voronoi facets.

facetCenters Point2f[]

Output vector of the Voronoi facets center points.

InitDelaunay(Rect)

Creates a new empty Delaunay subdivision

public void InitDelaunay(Rect rect)

Parameters

rect Rect

Rectangle that includes all of the 2D points that are to be added to the subdivision.

InitDelaunay(Rect2f)

Creates a new empty Delaunay subdivision

public void InitDelaunay(Rect2f rect)

Parameters

rect Rect2f

Rectangle that includes all of the 2D points that are to be added to the subdivision.

Insert(Point2f)

Insert a single point into a Delaunay triangulation.

public int Insert(Point2f pt)

Parameters

pt Point2f

Point to insert.

Returns

int

Insert(IEnumerable<Point2f>)

Insert multiple points into a Delaunay triangulation.

public void Insert(IEnumerable<Point2f> ptVec)

Parameters

ptVec IEnumerable<Point2f>

Points to insert.

Locate(Point2f, out int, out int)

Returns the location of a point within a Delaunay triangulation.

public int Locate(Point2f pt, out int edge, out int vertex)

Parameters

pt Point2f

Point to locate.

edge int

Output edge that the point belongs to or is located to the right of it.

vertex int

Optional output vertex the input point coincides with.

Returns

int

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.

NextEdge(int)

Subdivision edge ID.

public int NextEdge(int edge)

Parameters

edge int

Subdivision edge ID.

Returns

int

an integer which is next edge ID around the edge origin: eOnext on the picture above if e is the input edge).

Release()

Clean up any resources being used.

public void Release()

RotateEdge(int, int)

Returns another edge of the same quad-edge.

public int RotateEdge(int edge, int rotate)

Parameters

edge int

Subdivision edge ID.

rotate int

Parameter specifying which of the edges of the same quad-edge as the input one to return. The following values are possible: - 0 - the input edge ( e on the picture below if e is the input edge) - 1 - the rotated edge ( eRot ) - 2 - the reversed edge (reversed e (in green)) - 3 - the reversed rotated edge (reversed eRot (in green))

Returns

int

one of the edges ID of the same quad-edge as the input edge.

SymEdge(int)

public int SymEdge(int edge)

Parameters

edge int

Returns

int