Subdiv2D
import { Subdiv2D } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Native object: release it with using or delete(). Factories can return null; check before calling methods.
subdiv2 d value in the OpenCV API.
Constructors and members
static new
creates an empty Subdiv2D object. To create a new empty Delaunay subdivision you need to use the #initDelaunay function.
new(rect: Rect): Subdiv2D;rectRectangle that includes all of the 2D points that are to be added to the subdivision.
The function creates an empty Delaunay subdivision where 2D points can be added using the function insert() . All of the points to be added must be within the specified rectangle, otherwise a runtime error is raised.
The Subdiv2D result.
static from2
Create an owned Subdiv2D instance with the supplied configuration.
from2(_0: Rect2f): Subdiv2D | null;_00 argument (Rect2f).
The Subdiv2D | null result.
clone
Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.
clone(): this;The this result.
initDelaunay
Creates a new empty Delaunay subdivision
initDelaunay(rect: Rect): void;rectRectangle that includes all of the 2D points that are to be added to the subdivision.
initDelaunay2f
Creates a new empty Delaunay subdivision
initDelaunay2f(rect: Rect2f): void;rectRectangle that includes all of the 2D points that are to be added to the subdivision.
insert
Insert a single point into a Delaunay triangulation.
Note: If the point is outside of the triangulation specified rect a runtime error is raised.
insert(pt: Point2f): number;ptPoint 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.
the ID of the point.
insert1
Insert multiple points into a Delaunay triangulation.
insert1(ptvec: Point2fVector): void;ptvecPoints to insert.
The function inserts a vector of points into a subdivision and modifies the subdivision topology appropriately.
locate
Returns the location of a point within a Delaunay triangulation.
locate(pt: Point2f): Subdiv2D_locateResult;ptPoint to locate.
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. Scalar output parameters are returned as named fields in this object. Release returned native handles with using or delete(), including handles nested in results.
findNearest
Finds the subdivision vertex closest to the given point.
findNearest(pt: Point2f): Subdiv2D_findNearestResult;ptInput point.
vertex ID. Scalar output parameters are returned as named fields in this object. Release returned native handles with using or delete(), including handles nested in results.
getEdgeList
Returns a list of all edges.
getEdgeList(edgeList: Vec4fVector): void;edgeListOutput destination, filled by the native operation. Output vector.
The function gives each edge as a 4 numbers vector, where each two are one of the edge vertices. i.e. org_x = v[0], org_y = v[1], dst_x = v[2], dst_y = v[3].
getLeadingEdgeList
Returns a list of the leading edge ID connected to each triangle.
getLeadingEdgeList(leadingEdgeList: IntVector): void;leadingEdgeListOutput destination, filled by the native operation. Output vector.
The function gives one edge ID for each triangle.
getTriangleList
Returns a list of all triangles.
getTriangleList(triangleList: Vec6fVector): void;triangleListOutput destination, filled by the native operation. Output vector.
The function gives each triangle as a 6 numbers vector, where each two are one of the triangle vertices. i.e. p1_x = v[0], p1_y = v[1], p2_x = v[2], p2_y = v[3], p3_x = v[4], p3_y = v[5].
getVoronoiFacetList
Returns a list of all Voronoi facets.
getVoronoiFacetList(idx: IntVector, facetList: std__vector_cv__Point2fVector, facetCenters: Point2fVector): void;idxVector of vertices IDs to consider. For all vertices you can pass empty vector.
facetListOutput destination, filled by the native operation. Output vector of the Voronoi facets.
facetCentersOutput destination, filled by the native operation. Output vector of the Voronoi facets center points.
getVertex
Returns vertex location from vertex ID.
getVertex(vertex: number): Subdiv2D_getVertexResult;vertexvertex ID.
vertex (x,y) Scalar output parameters are returned as named fields in this object. Release returned native handles with using or delete(), including handles nested in results.
getEdge
Returns one of the edges related to the given edge.
getEdge(edge: number, nextEdgeType: number): number;edgeSubdivision edge ID.
nextEdgeTypeParameter 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 )

edge ID related to the input edge.
nextEdge
Returns next edge around the edge origin.
nextEdge(edge: number): number;edgeSubdivision edge ID.
an integer which is next edge ID around the edge origin: eOnext on the picture above if e is the input edge).
rotateEdge
Returns another edge of the same quad-edge.
rotateEdge(edge: number, rotate: number): number;edgeSubdivision edge ID.
rotateParameter 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))
one of the edges ID of the same quad-edge as the input edge.
symEdge
Return the directed edge opposite to the supplied subdivision edge.
symEdge(edge: number): number;edgeedge argument (number).
The number result.
edgeOrg
Returns the edge origin.
edgeOrg(edge: number): Subdiv2D_edgeOrgResult;edgeSubdivision edge ID.
vertex ID. Scalar output parameters are returned as named fields in this object. Release returned native handles with using or delete(), including handles nested in results.
edgeDst
Returns the edge destination.
edgeDst(edge: number): Subdiv2D_edgeDstResult;edgeSubdivision edge ID.
vertex ID. Scalar output parameters are returned as named fields in this object. Release returned native handles with using or delete(), including handles nested in results.
These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.