yazd univ. computing the overlay of two...

49
Yazd Univ. Computational Geometry Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions Computing the Overlay of Two Subdivisions 1393-1 1 / 25

Upload: others

Post on 17-Apr-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of TwoSubdivisions

1393-1

1 / 25

Page 2: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

We have solved the easiest case of the map overlayproblem, where the two maps are networksrepresented as collections of line segments.In general, maps have a more complicated structure:they are subdivisions of the plane into labeledregions.

2 / 25

Page 3: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Before we can give an algorithm for computing theoverlay of two subdivisions, we must develop asuitable representation for a subdivision.Storing a subdivision as a collection of line segmentsis not such a good idea.Operations like reporting the boundary of a regionwould be rather complicated.Add topological information: which segments bounda given region, which regions are adjacent, and soon.

3 / 25

Page 4: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

edge

vertex

face

disconnectedsubdivision

Complexity of a subdivision#faces+#edges+#vertices.

4 / 25

Page 5: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

incident

Complexity of a subdivision#faces+#edges+#vertices.

4 / 25

Page 6: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

What kind of queries?What is the face containing a given point? (TOOMUCH!)Walking around the boundary of a given face,Find the face from an adjacent one if we are given acommon edge,Visit all the edges around a given vertex.

The representation that we shall discuss supports theseoperations. It is called the doubly-connected edge list(DCEL).

5 / 25

Page 7: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

DCEL

DCEL contains:a record for each edge,a record for each vertex,a record for each face,plus attribute information.

6 / 25

Page 8: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

−→e

Twin(−→e )

v

w

To be able to traverse the boundary of a face, we need tokeep a pointer to a half-edge of any boundary componentand isolated points.

7 / 25

Page 9: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

To be able to traverse the boundary of a face, we need tokeep a pointer to a half-edge of any boundary componentand isolated points.

7 / 25

Page 10: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

To be able to traverse the boundary of a face, we need tokeep a pointer to a half-edge of any boundary componentand isolated points.

7 / 25

Page 11: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

To be able to traverse the boundary of a face, we need tokeep a pointer to a half-edge of any boundary componentand isolated points.

7 / 25

Page 12: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

DCELDCEL contains:

a record for each vertex,1 Coordinates(v): the coordinates of v,2 IncidentEdge(v): a pointer to an arbitrary half-edge

that has v as its origin.a record for each face,

1 OuterComponent(f): to some half-edge on its outerboundary (nil if unbounded),

2 InnerComponents(f): a pointer to some half-edgeon the boundary of the hole, for each hole.

a record for each half-edge −→e ,1 Origin(−→e ): a pointer to its origin,2 Twin(−→e ) a pointer to its twin half-edge,3 IncidentFace(−→e ): a pointer to the face that it

bounds.4 Next(−→e ) and Prev(−→e ): a pointer to the next and

previous edge on the boundary of IncidentFace(−→e ).

8 / 25

Page 13: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

DCELDCEL contains:

a record for each vertex,1 Coordinates(v): the coordinates of v,2 IncidentEdge(v): a pointer to an arbitrary half-edge

that has v as its origin.a record for each face,

1 OuterComponent(f): to some half-edge on its outerboundary (nil if unbounded),

2 InnerComponents(f): a pointer to some half-edgeon the boundary of the hole, for each hole.

a record for each half-edge −→e ,1 Origin(−→e ): a pointer to its origin,2 Twin(−→e ) a pointer to its twin half-edge,3 IncidentFace(−→e ): a pointer to the face that it

bounds.4 Next(−→e ) and Prev(−→e ): a pointer to the next and

previous edge on the boundary of IncidentFace(−→e ).

8 / 25

Page 14: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

DCELDCEL contains:

a record for each vertex,1 Coordinates(v): the coordinates of v,2 IncidentEdge(v): a pointer to an arbitrary half-edge

that has v as its origin.a record for each face,

1 OuterComponent(f): to some half-edge on its outerboundary (nil if unbounded),

2 InnerComponents(f): a pointer to some half-edgeon the boundary of the hole, for each hole.

a record for each half-edge −→e ,1 Origin(−→e ): a pointer to its origin,2 Twin(−→e ) a pointer to its twin half-edge,3 IncidentFace(−→e ): a pointer to the face that it

bounds.4 Next(−→e ) and Prev(−→e ): a pointer to the next and

previous edge on the boundary of IncidentFace(−→e ).

8 / 25

Page 15: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

DCELDCEL contains:

a record for each vertex,1 Coordinates(v): the coordinates of v,2 IncidentEdge(v): a pointer to an arbitrary half-edge

that has v as its origin.a record for each face,

1 OuterComponent(f): to some half-edge on its outerboundary (nil if unbounded),

2 InnerComponents(f): a pointer to some half-edgeon the boundary of the hole, for each hole.

a record for each half-edge −→e ,1 Origin(−→e ): a pointer to its origin,2 Twin(−→e ) a pointer to its twin half-edge,3 IncidentFace(−→e ): a pointer to the face that it

bounds.4 Next(−→e ) and Prev(−→e ): a pointer to the next and

previous edge on the boundary of IncidentFace(−→e ).

8 / 25

Page 16: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

DCELDCEL contains:

a record for each vertex,1 Coordinates(v): the coordinates of v,2 IncidentEdge(v): a pointer to an arbitrary half-edge

that has v as its origin.a record for each face,

1 OuterComponent(f): to some half-edge on its outerboundary (nil if unbounded),

2 InnerComponents(f): a pointer to some half-edgeon the boundary of the hole, for each hole.

a record for each half-edge −→e ,1 Origin(−→e ): a pointer to its origin,2 Twin(−→e ) a pointer to its twin half-edge,3 IncidentFace(−→e ): a pointer to the face that it

bounds.4 Next(−→e ) and Prev(−→e ): a pointer to the next and

previous edge on the boundary of IncidentFace(−→e ).

8 / 25

Page 17: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

DCELDCEL contains:

a record for each vertex,1 Coordinates(v): the coordinates of v,2 IncidentEdge(v): a pointer to an arbitrary half-edge

that has v as its origin.a record for each face,

1 OuterComponent(f): to some half-edge on its outerboundary (nil if unbounded),

2 InnerComponents(f): a pointer to some half-edgeon the boundary of the hole, for each hole.

a record for each half-edge −→e ,1 Origin(−→e ): a pointer to its origin,2 Twin(−→e ) a pointer to its twin half-edge,3 IncidentFace(−→e ): a pointer to the face that it

bounds.4 Next(−→e ) and Prev(−→e ): a pointer to the next and

previous edge on the boundary of IncidentFace(−→e ).

8 / 25

Page 18: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

DCEL

Origin(−→e )Twin(−→e )Next(−→ e)

Prev

( −→e)

IncidentFace(−→e )

−→e

9 / 25

Page 19: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

DCEL:Examplev1

−→e 1,1v2

v3

v4

f1

f2

−→e 1,2

−→e3,2

−→e4,2−→e

3,1

−→e 2,1−→e 2,

2

−→ e4,1

10 / 25

Page 20: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

DCEL

Time complexity of queries?Walking around the boundary of a given face,Find the face from an adjacent one if we are given acommon edge,Visit all the edges around a given vertex.

11 / 25

Page 21: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

DCEL

Time complexity of queries?Walking around the boundary of a given face,Find the face from an adjacent one if we are given acommon edge,Visit all the edges around a given vertex.

11 / 25

Page 22: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two Subdivisions

=⇒

S1 S2 O(S1,S2)

Main Idea in computing O(S1,S2)Copy DCEL of S1 and S2 into new DCEL (Not a ValidDCEL).Make the new DCEL valid.

12 / 25

Page 23: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two Subdivisions

13 / 25

Page 24: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating half-edges

e

v

the geometric situation andthe two doubly-connectededge lists before handling theintersection

the doubly-connected edgelist after handling the inter-section

14 / 25

Page 25: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating half-edges

e

v

Make two new edge with origin v.Set Twin of new edges.Set Next() of the two new half-edges.Set Prev() of the half-edges to which these pointerspoint.

15 / 25

Page 26: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating half-edges

e

v

e′

e′′

Make two new edge with origin v.Set Twin of new edges.Set Next() of the two new half-edges.Set Prev() of the half-edges to which these pointerspoint.

15 / 25

Page 27: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating half-edges

e

v

e′

e′′ e′′

e′

Make two new edge with origin v.Set Twin of new edges.Set Next() of the two new half-edges.Set Prev() of the half-edges to which these pointerspoint.

15 / 25

Page 28: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating half-edges

e

v

e′

e′′ e′′

e′

Make two new edge with origin v.Set Twin of new edges.Set Next() of the two new half-edges.Set Prev() of the half-edges to which these pointerspoint.

15 / 25

Page 29: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating half-edges

Fix the situation around v

The half-edge for e′ that has vas its destination must belinked to the first half-edge,seen clockwise from e′, with vas its origin.The half-edge for e′ with v asits origin must be linked to thefirst counterclockwisehalf-edge with v as itsdestination.The same for e′′.Time complexity: O(m) (m:degree of v).

e′

e′′

first clockwise half-edge from e′ with v asits origin

16 / 25

Page 30: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating half-edges

Fix the situation around v

The half-edge for e′ that has vas its destination must belinked to the first half-edge,seen clockwise from e′, with vas its origin.The half-edge for e′ with v asits origin must be linked to thefirst counterclockwisehalf-edge with v as itsdestination.The same for e′′.Time complexity: O(m) (m:degree of v).

e′

e′′

first clockwise half-edge from e′ with v asits origin

16 / 25

Page 31: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating half-edges

Fix the situation around v

The half-edge for e′ that has vas its destination must belinked to the first half-edge,seen clockwise from e′, with vas its origin.The half-edge for e′ with v asits origin must be linked to thefirst counterclockwisehalf-edge with v as itsdestination.The same for e′′.Time complexity: O(m) (m:degree of v).

e′

e′′

first clockwise half-edge from e′ with v asits origin

16 / 25

Page 32: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating half-edges

Fix the situation around v

The half-edge for e′ that has vas its destination must belinked to the first half-edge,seen clockwise from e′, with vas its origin.The half-edge for e′ with v asits origin must be linked to thefirst counterclockwisehalf-edge with v as itsdestination.The same for e′′.Time complexity: O(m) (m:degree of v).

e′

e′′

first clockwise half-edge from e′ with v asits origin

16 / 25

Page 33: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating faces

Updating Faces:Create a face record for each f ∈ O(S1,S2).Set OuterComponent(f) and InnerComponent(f).

17 / 25

Page 34: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating faces

# faces= # outer boundaries +1 (unbounded face).From half-edges we can construct the boundaries.To determine weather the boundary is outerboundary or boundary of a hole:

18 / 25

Page 35: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating faces

# faces= # outer boundaries +1 (unbounded face).From half-edges we can construct the boundaries.To determine weather the boundary is outerboundary or boundary of a hole:

18 / 25

Page 36: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating faces

# faces= # outer boundaries +1 (unbounded face).From half-edges we can construct the boundaries.To determine weather the boundary is outerboundary or boundary of a hole:

f

Leftmost vertex of cycle18 / 25

Page 37: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating faces

Which boundary cycles bound the same face?Construct a graph G.Every boundary cycle is a node in G.One node for the imaginary outer boundary of theunbounded face.Add an arc between two cycles if and only if one ofthe cycles is the boundary of a hole and the othercycle has a half-edge immediately to the left of theleftmost vertex of that hole cycle.If there is no half-edge to the left of the leftmostvertex of a cycle, then the node representing thecycle is linked to the node of the unbounded face.

19 / 25

Page 38: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating faces

Which boundary cycles bound the same face?Construct a graph G.Every boundary cycle is a node in G.One node for the imaginary outer boundary of theunbounded face.Add an arc between two cycles if and only if one ofthe cycles is the boundary of a hole and the othercycle has a half-edge immediately to the left of theleftmost vertex of that hole cycle.If there is no half-edge to the left of the leftmostvertex of a cycle, then the node representing thecycle is linked to the node of the unbounded face.

19 / 25

Page 39: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating faces

Which boundary cycles bound the same face?Construct a graph G.Every boundary cycle is a node in G.One node for the imaginary outer boundary of theunbounded face.Add an arc between two cycles if and only if one ofthe cycles is the boundary of a hole and the othercycle has a half-edge immediately to the left of theleftmost vertex of that hole cycle.If there is no half-edge to the left of the leftmostvertex of a cycle, then the node representing thecycle is linked to the node of the unbounded face.

19 / 25

Page 40: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating faces

Which boundary cycles bound the same face?Construct a graph G.Every boundary cycle is a node in G.One node for the imaginary outer boundary of theunbounded face.Add an arc between two cycles if and only if one ofthe cycles is the boundary of a hole and the othercycle has a half-edge immediately to the left of theleftmost vertex of that hole cycle.If there is no half-edge to the left of the leftmostvertex of a cycle, then the node representing thecycle is linked to the node of the unbounded face.

19 / 25

Page 41: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating faces

Which boundary cycles bound the same face?Construct a graph G.Every boundary cycle is a node in G.One node for the imaginary outer boundary of theunbounded face.Add an arc between two cycles if and only if one ofthe cycles is the boundary of a hole and the othercycle has a half-edge immediately to the left of theleftmost vertex of that hole cycle.If there is no half-edge to the left of the leftmostvertex of a cycle, then the node representing thecycle is linked to the node of the unbounded face.

19 / 25

Page 42: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating faces

C1C∞

C2

C3

C4

C6

C5 C7

C1C3

C6C∞

C2

C5

C4

C7

G

20 / 25

Page 43: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsUpdating faces

Lemma 2.5Each connected component of the graph G correspondsexactly to the set of cycles incident to one face.

21 / 25

Page 44: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsHow can we Construct G?

Constructing GSimilar to linesegmentintersectionalgorithm.Find the edgeimmediately to theleft of point.We need a pointerfrom each edge toits boundary in G.

new arcC C′

f

C′

C

G

22 / 25

Page 45: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsHow can we Construct G?

Constructing GSimilar to linesegmentintersectionalgorithm.Find the edgeimmediately to theleft of point.We need a pointerfrom each edge toits boundary in G.

new arcC C′

f

C′

C

G

22 / 25

Page 46: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two SubdivisionsHow can we Construct G?

Constructing GSimilar to linesegmentintersectionalgorithm.Find the edgeimmediately to theleft of point.We need a pointerfrom each edge toits boundary in G.

new arcC C′

f

C′

C

G

22 / 25

Page 47: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Computing the Overlay of Two Subdivisions

Theorem 2.6Let S1 be a planar subdivision of complexity n1, let S2 bea subdivision of complexity n2, and let n := n1 + n2. Theoverlay of S1 and S2 can be constructed inO(n log n+ k log n) time, where k is the complexity of theoverlay.

23 / 25

Page 48: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

Application:Boolean Operations

P1 P2

P1 P2 P1 P2

union

intersection difference

24 / 25

Page 49: Yazd Univ. Computing the Overlay of Two Subdivisionscs.yazd.ac.ir/farshi/Teaching/CG3942/Slides/DCEL.pdf · Doubly Connected Edge List (DCEL) Computing the Overlay of Two Subdivisions

Yazd Univ.

ComputationalGeometry

Doubly ConnectedEdge List (DCEL)

Computing theOverlay of TwoSubdivisions

25 / 25