View Source Evision.Subdiv2D (Evision v0.1.21)

Link to this section Summary

Types

t()

Type that represents an Evision.Subdiv2D struct.

Functions

Returns the edge destination.

Returns the edge origin.

Finds the subdivision vertex closest to the given point.

Returns one of the edges related to the given edge.

Returns a list of all edges.

Returns a list of the leading edge ID connected to each triangle.

Returns a list of all triangles.

Returns vertex location from vertex ID.

Returns a list of all Voronoi facets.

Creates a new empty Delaunay subdivision

Variant 1:

Insert multiple points into a Delaunay triangulation.

Returns the location of a point within a Delaunay triangulation.

Returns next edge around the edge origin.

Returns another edge of the same quad-edge.

Subdiv2D

Subdiv2D

Link to this section Types

@type t() :: %Evision.Subdiv2D{ref: reference()}

Type that represents an Evision.Subdiv2D struct.

  • ref. reference()

    The underlying erlang resource variable.

Link to this section Functions

@spec edgeDst(t(), integer()) ::
  {integer(), {number(), number()}} | {:error, String.t()}

Returns the edge destination.

Positional Arguments
  • self: Evision.Subdiv2D.t()

  • edge: int.

    Subdivision edge ID.

Return
  • retval: int

  • dstpt: Point2f*.

    Output vertex location.

@returns vertex ID.

Python prototype (for reference only):

edgeDst(edge) -> retval, dstpt
@spec edgeOrg(t(), integer()) ::
  {integer(), {number(), number()}} | {:error, String.t()}

Returns the edge origin.

Positional Arguments
  • self: Evision.Subdiv2D.t()

  • edge: int.

    Subdivision edge ID.

Return
  • retval: int

  • orgpt: Point2f*.

    Output vertex location.

@returns vertex ID.

Python prototype (for reference only):

edgeOrg(edge) -> retval, orgpt
@spec findNearest(
  t(),
  {number(), number()}
) :: {integer(), {number(), number()}} | {:error, String.t()}

Finds the subdivision vertex closest to the given point.

Positional Arguments
  • self: Evision.Subdiv2D.t()

  • pt: Point2f.

    Input point.

Return
  • retval: int

  • nearestPt: Point2f*.

    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.

Python prototype (for reference only):

findNearest(pt) -> retval, nearestPt
Link to this function

getEdge(self, edge, nextEdgeType)

View Source
@spec getEdge(t(), integer(), integer()) :: integer() | {:error, String.t()}

Returns one of the edges related to the given edge.

Positional Arguments
  • self: Evision.Subdiv2D.t()

  • edge: int.

    Subdivision edge ID.

  • nextEdgeType: int.

    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 )
Return
  • retval: int

sample output @returns edge ID related to the input edge.

Python prototype (for reference only):

getEdge(edge, nextEdgeType) -> retval
@spec getEdgeList(t()) ::
  [{number(), number(), number(), number()}] | {:error, String.t()}

Returns a list of all edges.

Positional Arguments
  • self: Evision.Subdiv2D.t()
Return
  • edgeList: [Vec4f].

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

Python prototype (for reference only):

getEdgeList() -> edgeList
Link to this function

getLeadingEdgeList(self)

View Source
@spec getLeadingEdgeList(t()) :: [integer()] | {:error, String.t()}

Returns a list of the leading edge ID connected to each triangle.

Positional Arguments
  • self: Evision.Subdiv2D.t()
Return
  • leadingEdgeList: [int].

    Output vector.

The function gives one edge ID for each triangle.

Python prototype (for reference only):

getLeadingEdgeList() -> leadingEdgeList
@spec getTriangleList(t()) ::
  [{number(), number(), number(), number(), number(), number()}]
  | {:error, String.t()}

Returns a list of all triangles.

Positional Arguments
  • self: Evision.Subdiv2D.t()
Return
  • triangleList: [Vec6f].

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

Python prototype (for reference only):

getTriangleList() -> triangleList
@spec getVertex(t(), integer()) ::
  {{number(), number()}, integer()} | {:error, String.t()}

Returns vertex location from vertex ID.

Positional Arguments
  • self: Evision.Subdiv2D.t()

  • vertex: int.

    vertex ID.

Return
  • retval: Point2f

  • firstEdge: int*.

    Optional. The first edge ID which is connected to the vertex.

@returns vertex (x,y)

Python prototype (for reference only):

getVertex(vertex) -> retval, firstEdge
Link to this function

getVoronoiFacetList(self, idx)

View Source
@spec getVoronoiFacetList(t(), [integer()]) ::
  {[[{number(), number()}]], [{number(), number()}]} | {:error, String.t()}

Returns a list of all Voronoi facets.

Positional Arguments
  • self: Evision.Subdiv2D.t()

  • idx: [int].

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

Return
  • facetList: [[Point2f]].

    Output vector of the Voronoi facets.

  • facetCenters: [Point2f].

    Output vector of the Voronoi facets center points.

Python prototype (for reference only):

getVoronoiFacetList(idx) -> facetList, facetCenters
Link to this function

initDelaunay(self, rect)

View Source
@spec initDelaunay(t(), {number(), number(), number(), number()}) ::
  :ok | {:error, String.t()}

Creates a new empty Delaunay subdivision

Positional Arguments
  • self: Evision.Subdiv2D.t()

  • rect: Rect.

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

Python prototype (for reference only):

initDelaunay(rect) -> None
@spec insert(t(), [{number(), number()}]) :: :ok | {:error, String.t()}
@spec insert(
  t(),
  {number(), number()}
) :: integer() | {:error, String.t()}

Variant 1:

Insert multiple points into a Delaunay triangulation.

Positional Arguments
  • self: Evision.Subdiv2D.t()

  • ptvec: [Point2f].

    Points to insert.

The function inserts a vector of points into a subdivision and modifies the subdivision topology appropriately.

Python prototype (for reference only):

insert(ptvec) -> None

Variant 2:

Insert a single point into a Delaunay triangulation.

Positional Arguments
  • self: Evision.Subdiv2D.t()

  • pt: Point2f.

    Point to insert.

Return
  • retval: int

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.

Python prototype (for reference only):

insert(pt) -> retval
@spec locate(
  t(),
  {number(), number()}
) :: {integer(), integer(), integer()} | {:error, String.t()}

Returns the location of a point within a Delaunay triangulation.

Positional Arguments
  • self: Evision.Subdiv2D.t()

  • pt: Point2f.

    Point to locate.

Return
  • retval: int

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

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.

Python prototype (for reference only):

locate(pt) -> retval, edge, vertex
@spec nextEdge(t(), integer()) :: integer() | {:error, String.t()}

Returns next edge around the edge origin.

Positional Arguments
  • self: Evision.Subdiv2D.t()

  • edge: int.

    Subdivision edge ID.

Return
  • retval: int

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

Python prototype (for reference only):

nextEdge(edge) -> retval
Link to this function

rotateEdge(self, edge, rotate)

View Source
@spec rotateEdge(t(), integer(), integer()) :: integer() | {:error, String.t()}

Returns another edge of the same quad-edge.

Positional Arguments
  • self: Evision.Subdiv2D.t()

  • 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))
Return
  • retval: int

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

Python prototype (for reference only):

rotateEdge(edge, rotate) -> retval
@spec subdiv2D() :: t() | {:error, String.t()}

Subdiv2D

Return

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

Python prototype (for reference only):

Subdiv2D() -> <Subdiv2D object>
@spec subdiv2D({number(), number(), number(), number()}) :: t() | {:error, String.t()}

Subdiv2D

Positional Arguments
  • rect: Rect.

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

Return

Has overloading in C++

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.

Python prototype (for reference only):

Subdiv2D(rect) -> <Subdiv2D object>
@spec symEdge(t(), integer()) :: integer() | {:error, String.t()}

symEdge

Positional Arguments
  • self: Evision.Subdiv2D.t()
  • edge: int
Return
  • retval: int

Python prototype (for reference only):

symEdge(edge) -> retval