42
Motivation Doubly-connected edge list Map overlay Subdivision representation and map overlay Computational Geometry Lecture 2b: Subdivision representation and map overlay Computational Geometry Lecture 2b: Subdivision representation and map overlay

Lecture 2b: Subdivision representation and map overlay · 2017. 12. 28. · Motivation Doubly-connected edge list Map overlay Map overlay Map overlay To solve map overlay questions,

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

  • MotivationDoubly-connected edge list

    Map overlay

    Subdivision representation and map overlay

    Computational Geometry

    Lecture 2b: Subdivision representation

    and map overlay

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlayMap overlay

    Map overlay

    Map overlay is the combination oftwo (or more) map layers

    It is needed to answer questions like:

    What is the total length ofroads through forests?

    What is the total area of cornfields within 1km from a river?

    What area of all lakes occurs atthe geological soil type “rock”?

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlayMap overlay

    Map overlay

    To solve map overlay questions, weneed (at the least) intersectionpoints from two sets of line segments(possibly, boundaries of regions)

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlayMap overlay

    Map overlay

    To solve map overlayquestions, we also need to beable to represent subdivisions

    clayclay sand

    sandloess

    rockrock

    sand

    sand

    loess

    clay

    rock rock

    clay

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    Subdivisions

    A planar subdivision is a structure induced by a set of linesegments in the plane that can only intersect at commonendpoints. It consists of vertices, edges, and faces

    face

    vertex

    edge

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    Subdivisions

    Vertices are the endpoints of the linesegments

    Edges are the interiors of the line segments

    Faces are the interiors of connectedtwo-dimensional regions that do notcontain any point of any line segment

    Objects of the same dimensionality areadjacent or not; objects of differentdimensionality are incident or not

    adjacent

    incident

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    Subdivisions

    Exactly one face is unbounded, theouter face

    Every other face is bounded and hasan outer boundary consisting ofvertices and edges

    Any face has zero or more innerboundaries

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    Subdivisions

    Vertices, edges, and faces form apartition of the plane

    If a planar subdivision is induced byn line segments, it has exactly nedges, and at most 2n vertices

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    Subdivisions

    And how many faces?

    Observe: Every face is bounded by atleast 3 edges, and every edge boundsat most 2 faces ⇒F ≤ 3 · (E/2) = 3n/2 = O(n)

    Exception: there are less than 3edges, and the only face is the outerface

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    Euler’s formula

    Euler’s formula for planar graphs: If S is a planarsubdivision with V vertices, E edges, and F faces, thenV−E +F ≥ 2, with equality iff the vertices and edges of Sform a connected set

    V = 9, E = 10, F = 4 V = 11, E = 12, F = 4

    V − E + F = 3 V − E + F = 2

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    Representing subdivisions

    A subdivision representation has avertex-object class, an edge-objectclass, and a face-object class

    It is a pointer structure whereobjects can reach incident (oradjacent) objects easily

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    Representing subdivisions

    Use the edge as the central object

    For any edge, exactly two verticesare incident, exactly two faces areincident, and zero or more otheredges are adjacent

    f1f2

    v1

    v2

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    Representing subdivisions

    Use the edge as the central object,and give it a direction

    Now we can speak of Origin,Destination, Left Face, and RightFace

    fleft

    vorigin

    fright

    vdestination

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    Representing subdivisions

    Four edges are of specialinterest

    fleftfright

    for fright

    for frightfor fleft

    for fleft

    next edgenext edge

    previous edgeprevious edge

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    Representing subdivisions

    It would be nice if we could traversea boundary cycle by continuouslyfollowing the next edge for fleft orfright

    . . . but, no consistent edgeorientation needs to exist

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    Representing subdivisions

    We apply a trick/hack/impossibility:split every edge length-wise(!) intotwo half-edges

    Every half-edge:

    has exactly one half-edge as itsTwin

    is directed opposite to its Twin

    is incident to only one face (left)

    ~e Twin(~e)

    Next(~e)

    Prev(~e)

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    The doubly-connected edge list

    The doubly-connected edge listis a subdivision representationstructure with an object forevery vertex, every half-edge,and every face

    A vertex object stores:

    Coordinates

    IncidentEdge (somehalf-edge leaving it)

    A half-edge object stores:

    Origin (vertex)

    Twin (half-edge)

    IncidentFace (face)

    Next (half-edge in cycleof the incident face)

    Prev (half-edge in cycleof the incident face)

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    The doubly-connected edge list

    A face object stores:

    OuterComponent(half-edge of outer cycle)

    InnerComponents (listof half-edges for the innercycles bounding the face)

    f

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    The doubly-connected edge list

    Question: A half-edge~e can directlyaccess its Origin, and get thecoordinates of one endpoint. Howcan it get the coordinates of its otherendpoint?

    Question: For a vertex v, how do wefind all adjacent vertices?

    v

    ~e Twin(~e)

    Next(~e)

    Prev(~e) Origin(~e)

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    The doubly-connected edge list

    A vertex object stores:

    Coordinates

    IncidentEdge

    Any attributes, mark bits

    A face object stores:

    OuterComponent(half-edge of outer cycle)

    InnerComponents(half-edges for the innercycles)

    Any attributes, mark bits

    A half-edge object stores:

    Origin (vertex)

    Twin (half-edge)

    IncidentFace (face)

    Next (half-edge in cycleof the incident face)

    Prev (half-edge in cycleof the incident face)

    Any attributes, mark bits

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    SubdivisionsRepresenting subdivisionsDCEL structure

    The doubly-connected edge list

    Question: For a face f , how do we find all adjacent facenames, assuming they are stored in an attribute? Write thecode using the proper names like Next, OuterComponent,etc.

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Map overlay problem

    The map overlay problem for twosubdivisions S1 and S2 is to computea subdivision S that is the overlay ofS1 and S2

    All edges of S are (parts of) edgesfrom S1 and S2. All vertices of S arealso in S1 or S2, or intersections ofedges from S1 and S2

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Map overlay

    We start by making a copy of S1 andof S2 whose vertex and half-edgeobjects we will re-use

    At first we do not compute faceobject information in the overlay

    The output should be adoubly-connected edge list (DCEL)of the overlay

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Map overlay

    We start by making a copy of S1 andof S2 whose vertex and half-edgeobjects we will re-use

    At first we do not compute faceobject information in the overlay

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Map overlay

    Approach: plane sweep

    Need to define status, events, eventhandling

    Need status structure, event list, andDCEL for the output

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Map overlay

    Status: the edges of S1 and S2intersecting the sweep line in theleft-to-right order

    Events happen:

    At the vertices of S1 and S2At intersection points from S1and S2

    The event list is basically the sameas for line segment intersection

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Overlay events

    Six types of events:

    A vertex of S1A vertex of S2An intersection point of one edge fromS1 and one edge from S2An edge of S1 goes through a vertexof S2An edge of S2 goes through a vertexof S1A vertex of S1 and a vertex of S2coincide

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Overlay events

    Consider the event:an intersection point of one edge from S1 and one edgefrom S2

    geometry DCELs before DCEL after

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Overlay events

    Consider the event:an edge from S1 goes through a vertex of S2

    geometry DCELs before DCEL after

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Overlay events

    Consider the event:a vertex of S1 and a vertex of S2 coincide

    geometry DCELs before DCEL after

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Overlay events

    When we take an event from the event queue Q, we needquick access to the DCEL to make the necessary changes

    We keep a pointer from each leaf in the status structure toone of the representing half-edges in the DCEL

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Overlay events

    When we take an event from the event queue Q, we needquick access to the DCEL to make the necessary changes

    We keep a pointer from each leaf in the status structure toone of the representing half-edges in the DCEL

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Overlay so far

    The sweep algorithm gives us all vertices and half-edges of theoverlay, and pointers between these objects

    Next we need face objects and their connection into thedoubly-connected edge list structure

    Question: Which variables of vertex, edge, and face objectswill we set in this process?

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    C1

    C2

    C3C4C5

    C6

    C7

    C8

    C9

    C10C11

    C12

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Face information

    Determine all cycles of half-edges, and whether they areinner or outer boundaries of the incident face

    Make a face object for each outer boundary, plus one forthe unbounded face, and set the OuterComponentvariable of each face. Set the IncidentFace variable forevery half-edge in an outer boundary cycle

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    C1

    C2

    C3C4C5

    C6

    C7

    C8

    C9

    C10C11

    C12

    C6 → C2

    C2 → C5

    C1 →C3 →

    C10 → C1

    C7 → C9

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Face information

    Determine the leftmost vertex of each inner boundarycycle

    For all of these leftmost vertices, determine the edgehorizontally left of it, take the downward half-edge of it,and its cycle (by plane sweep) to set InnerComponentsfor all faces and IncidentFace for half-edges in innerboundary cycles

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    C1

    C2

    C3C4C5

    C6

    C7

    C8

    C9

    C10C11

    C12

    C6 → C2

    C2 → C5

    C1 →C3 →

    C10 → C1

    C7 → C9

    f5

    f5: outer e5; inner e2, e6

    e5

    e2

    e6

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Efficiency

    Every event takes O(logn) or O(m+ logn) time to handle,where m is the sum of the degrees of any vertex from S1and/or S2 involved

    The sum of the degrees of all vertices is exactly twice thenumber of edges

    Theorem: Given two planar subdivisions S1 and S2, theiroverlay can be computed in O(n logn+ k logn) time, where kis the number of vertices of the overlay

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

  • MotivationDoubly-connected edge list

    Map overlay

    InitializationOverlay algorithmBoolean operations

    Boolean operations on polygons

    Boolean operations on twopolygons with n vertices takeO(n logn+ k logn) time, wherek is the number of intersectionpoints

    intersection

    symmetric difference

    union

    difference or

    Computational Geometry Lecture 2b: Subdivision representation and map overlay

    MotivationMap overlay

    Doubly-connected edge listSubdivisionsRepresenting subdivisionsDCEL structure

    Map overlayInitializationOverlay algorithmBoolean operations