1 / 21

The Half-Edge Data Structure

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

amato
Download Presentation

The Half-Edge Data Structure

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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. e_v1[4] v1 f1 e f2 v2 e_v2[4] 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. Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  7. The Doubly-Connected-Edge-List (DCEL) • DCEL is a directed half-edgeB-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. f e_next HE_edge v_orig e_twin e_prev 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; }; Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  9. edge HE_vert p=(x,y) 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. 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. innerComps[0] HE_face outerComp 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; }; Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  12. v2 f1 edge f2 v1 Adjacency Queries • Given a half-edge edge, we can perform queries in constant time. • Example: HE_vert *v1 = edgev_orig; HE_vert *v2 = edgee_twinv_orig; HE_vert *f1 = edgef; HE_vert *f2 = edge e_twinf; Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  13. DCEL Example 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; v1p = new Point(1,2); v1egde = e_12; HE_face f1; f1outerComp = e_15; f1innerComp[0] = e_67; HE_edge e_54; e_54v_orig = v5; e_54e_twin = e_45; e_54f = f1; e_54e_next = e_43; e_54e_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 = faceouterComp; do { // Do something with edge. edge = edgenext; } while (edge != faceouterComp); HE_edge *edge = vertexedge; do { // Do something with edge, edgee_twin, etc. edge = edgee_twinnext; } while (edge != vertexedge); Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann

  15. Face Records 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 vertexv 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. c6 c3 c2 c7 c5 c1 c8 c4 Top Level DCEL Representation 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. Holes c3 c1 c8 c6 c2 c7 c5 Outside c4 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 ev_orig ee_twin e2 p e2e_twin e1 ev_orig e1e_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 ev_orig e2 v e1 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. 2 1 3 3 1 7 4 5 8 8 L 7 2 1 P U(P) C(P) 7 3 1 3 C(P) 2 Handling Intersections • Additional handling of ‘intersection’ event points: • Split and re-direct edges. • Check new nearest-neighbours for intersections. • Recall (from Lecture 3): 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

More Related