Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Half-Edge Data Structure Computational Geometry, WS 2007/08 Lecture 3, Part III Prof. Dr. Thomas Ottmann Khaireel A. Mohamed Algorithmen & Datenstrukturen,

Similar presentations


Presentation on theme: "The Half-Edge Data Structure Computational Geometry, WS 2007/08 Lecture 3, Part III Prof. Dr. Thomas Ottmann Khaireel A. Mohamed Algorithmen & Datenstrukturen,"— Presentation transcript:

1 The Half-Edge Data Structure Computational Geometry, WS 2007/08 Lecture 3, Part III 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 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann2 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

3 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann3 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.

4 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann4 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? Our deliberations: Constrained to manifold surfaces only.

5 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann5 Planar Subdivision Euler’s Formula: v – e + f = 2

6 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann6 Boundary Representation Structures To represent such queries efficiently, we use the boundary representation (B-rep) structure. B-rep explicitly models 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)

7 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann7 Baumgart’s Winged-Edge DS The Edge DS is augmented with pointers to: –the two vertices it touches (v 1, v 2 ), –the two faces it borders (f 1, f 2 ), and –pointers to four of the edges which emanate from each end point (e_v 1 [4], e_v 2 [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 v1v1 v2v2 f2f2 f1f1 e_v 1 [4] e_v 2 [4]

8 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann8 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.

9 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann9 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 a Java class as follows: H_Edge f eNext ePrev vOrigeTwin class H_Edge { Vertex vOrig; H_Edge eTwin; Face f; H_Edge eNext; H_Edge ePrev; }

10 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann10 DCEL Component - Vertex A vertex in the DCEL stores: –its actual location of the point on the plane, and –a pointer to exactly ONE of the H_Edge, which uses this vertex as its origin. There may be several H_Edge which origins start at the same vertex. We need only one, and it does not matter which one. Vertex hEdge p=(x,y) class Vertex { Point2D p; H_Edge hEdge; }

11 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann11 A face component stores –a reference to any one of the half-edges it borders (the face’s outer- most boundary), and –a set of references to half-edges of unique holes inside the face. For the unbounded face, the eOuterComp reference is NULL. DCEL Component – Face class Face { H_Edge eOuterComp; List eInnerComps; } Face eOuterComp eInnerComps[0]

12 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann12 DCEL Example: Planar Subdivision Vertex v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 p (1,1) (10,0) (9,5) (2,7) (5,8) (8,9) (5,11) (7,13) (1,13) (11,12) (6,15) hEdge e1_3 e2_3 e3_4 e4_9 e5_9 e6_7 e7_8 e8_6 e9_11 01234567891011 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 v7v7 v8v8v9v9 v10 v11 f1f1 f3f3 f2f2 f4f4

13 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann13 DCEL Example: Planar Subdivision Half-Edge e1_3 e3_1 e2_3 e3_2 e10_3 e11_10 e9_11 e4_9 e3_4 e4_3 e9_4 e5_9 e3_5 e5_3 e9_5 e11_9 vOrig v1 eTwin e3_1 f f1 eNext e3_4 ePrev e3_1 01234567891011 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 v7v7 v8v8v9v9 v10 v11 f1f1 f3f3 f2f2 f4f4

14 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann14 DCEL Example: Planar Subdivision Half-Edge e10_11 e3_10 e6_7 e8_6 e7_8 e8_7 e7_6 e6_8 vOrig v10 eTwin e11_10 f f3 eNext e11_9 ePrev e3_10 Face f1 f2 f3 f4 eOuterComp NULL eInnerComps e1_3 01234567891011 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 v7v7 v8v8v9v9 v10 v11 f1f1 f3f3 f2f2 f4f4

15 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann15 Adjacency Queries Given a half-edge e, we can perform queries in constant time. Example: Vertex v1 = e. vOrig; Vertex v2 = e. eTwin. vOrig; Face f1 = e. f; Face f2 = e. eTwin. f; e f1 v2 v1 f2

16 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann16 Iterated Adjacency Queries Iterating over the half-edges adjacent to a given face f. H_Edge hEdge = f. eOuterComp; do { // Do something with edge. hEdge = hEdge. eNext; } while (

17 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann17 Iterated Adjacency Queries Iterating over the half-edges on a given vertex v. H_Edge hEdge = v. hEdge; do { // Do something with edge. hEdge = hEdge. eTwin. eNext; } while (

18 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann18 Splitting an Edge Given a half-edge e and a point p on e, we can split e into two sub- edges e1 and e2 in constant time. e p p e.eTwin e.vOrig e1 e2 e2.eTwin e1.eTwin

19 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann19 Splitting and Re-directing Edges Given a half-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 e1 e2 e.vOrig v v Insertion of new edges into the flow: » Iterate edges at v. » Exercise (in next tutorial).

20 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann20 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 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

21 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann21 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.

22 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann22 Handling Intersections Additional handling of ‘intersection’ event points: –Split and re-direct edges. –Check new nearest-neighbours for intersections. Recall (from Lecture 3b): 2 1 3 7 7 3 1 2 8 U(P) C(P) 3 8 4 5 7 1 3 2 1 P L

23 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann23 Analysis For a total of n vertices in both S1 and S2: Sorting of n vertices: In time Runtime per ‘intersection’-vertex: In time Operation per ‘intersection’-vertex: In time Total ‘intersection’-vertices: k Total runtime:


Download ppt "The Half-Edge Data Structure Computational Geometry, WS 2007/08 Lecture 3, Part III Prof. Dr. Thomas Ottmann Khaireel A. Mohamed Algorithmen & Datenstrukturen,"

Similar presentations


Ads by Google