Download presentation
1
The Half-Edge Data Structure
Computational Geometry, WS 2006/07 Lecture 9, Part I Prof. Dr. Thomas Ottmann Khaireel A. Mohamed Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für Angewandte Wissenschaften Albert-Ludwigs-Universität Freiburg
2
Overview Planar subdivision representation
Adjacency relationships and queries Boundary representation structure Baumgart’s winged-edge data structure Doubly-connected-edge-list (DCEL) Overlaying planar subdivisions Analyses Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
3
Representing a Polygon Mesh
We require a convenient and efficient way to represent a planar subdivision. Components in the planar subdivision: A list of vertices A list of edges A list of faces storing pointers for its vertices Must preserve adjacency relationships between components. Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
4
Possible Adjacency Queries
Point anywhere on the polygon mesh and ask: Which faces use this vertex? Which edges use this vertex? Which faces border this edge? Which edges border this face? Which faces are adjacent to this face? Planar subdivision Euler’s formular: v – e + f = 2 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
5
Boundary Representation Structures
To represent such queries efficiently, we use the boundary representation (B-rep) structure. B-rep explicitly model the edges, vertices, and faces of the planar subdivision PLUS additional adjacency information stored inside. Two most common examples of B-rep: Baumgart’s winged-edge data structure Doubly-connect-edge-list (DCEL) Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
6
Baumgart’s Winged-Edge DS
The Edge DS is augmented with pointers to: the two vertices it touches (v1, v2), the two faces it borders (f1, f2), and pointers to four of the edges which emanate from each end point (e_v1[4], v2[4]). We can determine which faces or vertices border a given edge in constant time. Other types of queries can require more expensive processing. e v1 v2 f2 f1 e_v1[4] e_v2[4] Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
7
The Doubly-Connected-Edge-List (DCEL)
DCEL is a directed half-edge B-rep data structure. Allows all adjacency queries in constant time (per piece of information gathered). That is, for example; When querying all edges adjacent to a vertex, the operation will be linear in the number of edges adjacent to the vertex, but constant time per edge. The DCEL is excellent in representing manifold surfaces: Every edge is bordered by exactly two faces. Cross junctions and internal polygons are not allowed. Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
8
DCEL Component – Half-edge
The half-edges in the DCEL that border a face form a circular linked-list around its perimeter (anti-clockwise); i.e. each half-edge in the loop stores a pointer to the face it borders (incident). Each half-edge is directed and can be described in C as follows: struct HE_edge { HE_vert *v_orig; HE_edge *e_twin; HE_face *f; HE_edge *e_next; HE_edge *e_prev; }; HE_edge f e_next e_prev v_orig e_twin Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
9
DCEL Component - Vertex
Vertices in the DCEL stores: their actual point location, and a pointer to exactly ONE of the HE_edge, which uses the vertex as its origin. There may be several HE_edge whose origins start at the same vertex. We need only one, and it does not matter which one. HE_vert edge p=(x,y) struct HE_vert { Gdiplus::PointF p; HE_edge *edge; }; Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
10
DCEL Component – Face I The “bare-bones” version of the face component needs only to store a single pointer to one of the half-edges it borders. In the implementation by de Berg et al. (2000), edge is the pointer to the circular loop of the OuterComponent (or the outer-most boundary) of the incident face. For the unbounded face, this pointer is NULL. struct HE_face_barebone { HE_edge *edge; }; HE_face_barebone edge Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
11
DCEL Component – Face II
All holes contained inside an incident face are considered as InnerComponents. A list of pointers to half-edges of unique holes is maintained in HE_face as follows. In the case that there are no holes in an incident face, innerComps is set to NULL. struct HE_face { HE_edge *outerComp; HE_edge **innerComps; }; HE_face outerComp innerComps[0] Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
12
Adjacency Queries Given a half-edge edge, we can perform queries in constant time. Example: HE_vert *v1 = edgev_orig; HE_vert *v2 = edgee_twinv_orig; HE_vert *f1 = edgef; HE_vert *f2 = edge e_twinf; edge f1 v2 v1 f2 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
13
DCEL Example In terms of the structure definitions: Example
vertex v1 = { (1, 2), h_edge(12) } face f1 = {h_edge(15), [h_edge(67)] } h_edge(54) = { v5, h_edge(45), f1, h_edge(43), h_edge(15) } In terms of the structure definitions: HE_vert v1; v1p = new Point(1,2); v1egde = e_12; HE_face f1; f1outerComp = e_15; f1innerComp[0] = e_67; HE_edge e_54; e_54v_orig = v5; e_54e_twin = e_45; e_54f = f1; e_54e_next = e_43; e_54e_prev = e_15; Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
14
Iterated Adjacency Queries
Iterating over the half-edges adjacent to a given face. Iterating over the half-edges that are adjacent to a given vertex. HE_edge *edge = faceouterComp; do { // Do something with edge. edge = edgenext; } while (edge != faceouterComp); HE_edge *edge = vertexedge; do { // Do something with edge, edgee_twin, etc. edge = edgee_twinnext; } while (edge != vertexedge); Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
15
Face Records f Determining the boundary-type:
Is a complete edge-loop (boundary-cycle) an outer-boundary, or the boundary of a hole in the face? Select the face f that we are interested in. Identify the lowest of the left-most vertex v of any edge-loop. Consider the two half-edges passing through v, and compute their angle . If is smaller than 180°, then the edge-loop is an outer-boundary. f Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
16
Top Level DCEL Representation
Holes c8 c2 c6 c7 c5 Outside c4 Construct a graph G to representy boundary-cycles. For every boundary-cycle, there is a node in G (+ imaginary bound). An arc joins two cycles iff one is a boundary of a hole and the other has a half-edge immediately to the left of the left-most vertex of that hole. Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
17
Splitting an Edge Given an edge e and a point p on e, we can split e into two sub-edges e1 and e2 in constant time. e p ev_orig ee_twin e2 p e2e_twin e1 ev_orig e1e_twin Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
18
Splitting and Re-directing Edges
Given an edge e and a vertex v of degree deg(v) on e, we can split and redirect the sub-edges of the DCEL at v in time O(1 + deg(v)). e Insertion of new edges into the flow: » Iterate edges at v. » Exercise. v ev_orig e2 e1 v Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
19
Overlaying Two Planar Subdivisions
Plane sweep! Event-points (maintained in balanced binary search tree): Vertices of S1 and S2 All intersections between edges in S1 and S2 Status-structure (per event): Neighbouring edges sorted in increasing x-order. Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
20
Handling Intersections
Additional handling of ‘intersection’ event points: Split and re-direct edges. Check new nearest-neighbours for intersections. Recall (from Lecture 3): 2 1 3 7 8 U(P) C(P) 4 5 P L Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
21
Analysis For a total of n vertices in both S1 and S2:
Sorting of n vertices: O(n log n) time Runtime per ‘intersection’-vertex: O(1 + deg(v)) Time to retrieve neighbouring edges per ‘interection’-vertex: O(log n) Total ‘intersection’-vertices: k Total runtime: O(n log n + k log n) Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.