quadedge

package
v0.0.0-...-d322e89 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2018 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package quadedge provides a way to describe and manipulate the topology of planar maps (i.e., the topology of any closed polygonal mesh).

It implements the quad-edge data structure described in:

"Primitives for the Manipulation of General Subdivisions and the Computation
 of Voronoi Diagrams"

 P. Guibas, J. Stolfi, ACM TOG, April 1985

This structure represents at the same time the primal and dual of the map, as well as their mirror images. It allows to switch from one to another in constant time.

For example, a list of quad-edges that describe the topology a Delaunay triangulation also describe the corresponding Voronoi diagram.

The structure does not hold (nor use) any geometrical information, but contains 32bit IDs that can be used to identify vertices and faces.

Note that in this package, each (undirected) edge of the map is represented by four directed Edge objects.

Index

Constants

View Source
const (
	// Nil is the value used to initialize the origin, destination, left and
	// right fields of new Edge objects.
	Nil = 0xFFFFFFFF
)

Variables

This section is empty.

Functions

func Delete

func Delete(e Edge)

Delete removes the quad-edge from any edge ring it belongs to.

Note that freeing the corresponding slot in the pool is not yet implemented, so the freed edge still counts as created in regards to pool capacity.

func Splice

func Splice(a, b Edge)

Splice implements the second operator from Guibas and Stolfi Quad-Edge article.

It affects the two origin edge rings of a and b, as well as their two left edge rings: if the two rings are distinct, they are combined into one; if the two rings are the same, they are broken in separate pieces.

In the origin edge rings, the change happens immediately after a.Orig() and b.Orig() (in counterclockwise order); and in the left edge rings, the change happens immediately before a.Left() and b.Left().

func SwapTriangles

func SwapTriangles(e Edge)

SwapTriangles disconnects e, which must have two triangles as left and right faces, and reconnect it to the other two vertices of the quadrilateral formed by the first step. For example, if v1, v2, v3 and v4 form a quadrilateral, and e is a diagonal between v1, and v3, after the swap e will connect v2 to v4.

Types

type Edge

type Edge struct {
	// contains filtered or unexported fields
}

An Edge identifies one of the four directed edges of a specific quad-edge. It corresponds to what Guibas and Stolfi call an edge reference. To obtain a new Edge, create a new quad-edge with Pool.New().

Note that for convenience, Edge objects contain a pointer to the pool used to create it.

func Connect

func Connect(a, b Edge) Edge

Connect creates and returns a new edge connecting the destination of a to the origin of b, in such a way that a, e and b share the same left face. For convenience, it also sets the origin and destination vertex ID of the new edge (but not the right and left face ID).

func Delaunay

func Delaunay(points []coord.XY) Edge

Delaunay returns the delaunay triangulation of a set of points.

func New

func New(p *Pool) Edge

New creates a new isolated quad-edge, and returns its canonical directed Edge. It's the MakeEdge operator from Guibas and Stolfi Quad-Edge article.

The quad-edge is set up with separate origin and destination vertices, but same left and right faces. To obtain a loop instead (same origin and destination, different left and right), use New().Rot().

func (Edge) Canonical

func (e Edge) Canonical() Edge

Canonical returns the canonical representation of e. All four edges of a quad-edge return the same value.

func (Edge) Dest

func (e Edge) Dest() uint32

Dest returns the vertex ID of the destination of e.

func (Edge) DestLoop

func (e Edge) DestLoop(visit func(e Edge))

DestLoop calls visit on every edges in the destination edge-ring of e, in conter-clockwise order (starting with e).

func (Edge) DestNext

func (e Edge) DestNext() Edge

DestNext returns the next counter-clockwise edge with the same destination vertex.

func (Edge) DestPrev

func (e Edge) DestPrev() Edge

DestPrev returns the previous counter-clockwise edge with the same destination vertex.

func (Edge) Left

func (e Edge) Left() uint32

Left returns the face ID at the left of e.

func (Edge) LeftLoop

func (e Edge) LeftLoop(visit func(e Edge))

LeftLoop calls visit on every edges in the left edge-ring of e, in conter-clockwise order (starting with e).

func (Edge) LeftNext

func (e Edge) LeftNext() Edge

LeftNext returns the next counter-clockwise edge with the same left face.

func (Edge) LeftPrev

func (e Edge) LeftPrev() Edge

LeftPrev returns the previous counter-clockwise edge with the same left face.

func (Edge) Orig

func (e Edge) Orig() uint32

Orig returns the vertex ID of the origin of e.

func (Edge) OrigLoop

func (e Edge) OrigLoop(visit func(e Edge))

OrigLoop calls visit on every edges in the origin edge-ring of e, in conter-clockwise order (starting with e).

func (Edge) OrigNext

func (e Edge) OrigNext() Edge

OrigNext returns the next counter-clockwise edge with the same origin vertex.

func (Edge) OrigPrev

func (e Edge) OrigPrev() Edge

OrigPrev returns the previous counter-clockwise edge with the same origin vertex.

func (Edge) Pool

func (e Edge) Pool() *Pool

Pool returns the allocator that was used to create e.

func (Edge) Right

func (e Edge) Right() uint32

Right returns the face ID at the right of e.

func (Edge) RightLoop

func (e Edge) RightLoop(visit func(e Edge))

RightLoop calls visit on every edges in the right edge-ring of e, in conter-clockwise order (starting with e).

func (Edge) RightNext

func (e Edge) RightNext() Edge

RightNext returns the next counter-clockwise edge with the same right face.

func (Edge) RightPrev

func (e Edge) RightPrev() Edge

RightPrev returns the previous counter-clockwise edge with the same right face.

func (Edge) Rot

func (e Edge) Rot() Edge

Rot returns the rotated version of e (counter-clockwise), i.e. the edge that belongs to the same quad-edge, but is the dual of e, directed from right to left.

func (Edge) SameRing

func (e Edge) SameRing(o Edge) bool

SameRing returns true if o is in the origin edge-ring of e (i.e., if the two directed edges share the same origin).

func (Edge) SetDest

func (e Edge) SetDest(data uint32)

SetDest changes the vertex ID of the destination of e. If there is other edges in the same destination edge ring, they will not be updated.

func (Edge) SetLeft

func (e Edge) SetLeft(data uint32)

SetLeft changes the face ID at the left of e. Note that if there is other edges with the same left face, they will not be updated.

func (Edge) SetOrig

func (e Edge) SetOrig(data uint32)

SetOrig changes the vertex ID of the origin of e. Note that if there is other edges with the same origin, they will not be updated.

func (Edge) SetRight

func (e Edge) SetRight(data uint32)

SetRight changes the face ID at the right of e. Note that if there is other edges with the same right face, they will not be updated.

func (Edge) String

func (e Edge) String() string

func (Edge) Sym

func (e Edge) Sym() Edge

Sym returns the symmetric of e, i.e. the edge that belongs to the same quad-edge but with opposite direction.

func (Edge) Tor

func (e Edge) Tor() Edge

Tor returns the inverse rotated version of e (so, clockwise), i.e. the edge that belongs to the same quad-edge, but is the dual of e, directed from left to right. (It is notated Rot⁻¹ in the article)

func (Edge) Walk

func (e Edge) Walk(visit func(e Edge))

Walk calls visit for every undirected primal edge reachable from e.

It does so by a chain of Sym() and OrigNext() calls, but ensures that in each quad-edge, only one edge is visited (i.e. the symetric of an already encountered edge is never visited).

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

A Pool is an allocator for quad-edges.

func NewPool

func NewPool(capacity uint32) *Pool

NewPool returns a newly allocated Pool capable of holding capacity quad-edges.

Note: dynamically growing the pool is not yet implemented, so creating more than capacity edges will panic.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL