traversing an arrangement - tau
TRANSCRIPT
2D Arrangements
Efi Fogel
Tel Aviv University
Computational GeometryApr. 7th, 2014
Outline
1 Definitions
2 Representation
3 Queries & Free FunctionsPoint Location QueriesThe Zone Computation AlgorithmThe Plane Sweep AlgorithmVertical DecompositionMap Overlay
4 Arrangement-Traits Classes
5 Extending the ArrangementExtending Cell Records
6 Literature
2D Arrangements 2
Two Dimensional Arrangements
Definition (Arrangement)Given a collection C of curves on a surface, the arrangement A(C) is thepartition of the surface into vertices, edges and faces induced by thecurves of C.
An arrangementof circles in theplane.
An arrangement of lines inthe plane.
An arrangementof great-circlearcs on a sphere.
2D Arrangements 3
The Cgal Arrangement_on_surface_2 Package
Constructs, maintains, modifies, traverses, queries, and presentsarrangements on two-dimensional parametric surfaces.Complete and Robust
All inputs are handled correctly (including degenerate input).Exact number types are used to achieve robustness.
Generic – easy to interface, extend, and adaptModular – geometric and topological aspects are separatedSupports among the others:
various point location strategieszone-construction paradigmsweep-line paradigmvertical decompositionoverlay computation
Part of the Cgal basic library
2D Arrangements 4
Outline
1 Definitions
2 Representation
3 Queries & Free FunctionsPoint Location QueriesThe Zone Computation AlgorithmThe Plane Sweep AlgorithmVertical DecompositionMap Overlay
4 Arrangement-Traits Classes
5 Extending the ArrangementExtending Cell Records
6 Literature
2D Arrangements 5
The Doubly-Connected Edge List
One of a family ofcombinatorial data-structurescalled the halfedgedata-structures.Represents each edge using apair of directed halfedges.Maintains incidence relationsamong cells of 0 (vertex), 1(edge), and 2 (face)dimensions.
v1
v2
eprev
enext
ee′
f0
f1
f2
f3f4
u1
u2
The target vertex of a halfedge and the halefedge are incident to each other.The source and target vertices of a halfedge are adjacent.
2D Arrangements 6
The Doubly-Connected Edge List Components
VertexAn incident halfedge pointing at the vertex.
HalfedgeThe opposite halfedge.The previous halfedge in the component boundary.The next halfedge in the component boundary.The target vertex of the halfedge.The incident face.
FaceAn incident halfedge on the outer Ccb.An incident halfedge on each inner Ccb.
Connected component of the boundary (Ccb)The circular chains of halfedges around faces.
2D Arrangements 7
Arrangement Representation
The halfedges incident to a vertex form a circular list.The halfedges are sorted in clockwise order around thevertex.
The halfedges around faces form circular chains.All halfedges of a chain are incident to the same face.The halfedges are sorted in counterclockwise order alongthe boundary.Geometric interpretation is added by classes built on top of thehalfedge data-structure.
2D Arrangements 8
Arrangement_2<Tra i t s , Dcel>
Is the main component in the 2D Arrangements package.An instance of this class template represents 2D arrangements.The representation of the arrangements and the various geometricalgorithms that operate on them are separated.The topological and geometric aspects are separated.
The T r a i t s template-parameter must be substituted by a model of ageometry-traits concept, e.g., ArrangementBasicTraits_2.
⋆ Defines the type X_monotone_curve_2 that represents x -monotonecurves.
⋆ Defines the type Point_2 that represents two-dimensional points.⋆ Supports basic geometric predicates on these types.
The Dce l template-parameter must be substituted by a model of theArrangementDcel concept, e.g., A r r_de f au l t_dce l <Tra i t s >.
2D Arrangements 9
Traversing the Halfedges Incident to an ArrangementVertex
Print all the halfedges incident to a vertex.✞ ☎t emp la t e <typename Arrangement>vo i d p r i n t _ i n c i d e n t_ h a l f e d g e s ( typename Arrangement : : Ve r tex_cons t_hand le v ){
i f ( v−>i s _ i s o l a t e d ( ) ) {s td : : cout << "The␣ v e r t e x ␣ ( " << v−>po i n t ( ) << " ) ␣ i s ␣ i s o l a t e d " << s td : : e nd l ;r e t u r n ;
}s td : : cout << "The␣ n e i g hbo r s ␣ o f ␣ the ␣ v e r t e x ␣ ( " << v−>po i n t ( ) << " ) ␣ a r e : " ;typename Arrangement : : Ha l f e dg e_a r ound_ve r t e x_con s t_c i r c u l a t o r f i r s t , c u r r ;f i r s t = cu r r = v−>i n c i d e n t_ h a l f e d g e s ( ) ;do s td : : cout << "␣ ( " << cur r−>sou r c e ()−>po i n t ( ) << " ) " ;wh i l e (++cu r r != f i r s t ) ;s t d : : cout << s td : : e nd l ;
}✝ ✆
2D Arrangements 10
Traversing the Halfedges of an Arrangement Ccb
Print all x -monotone curves along a given Ccb✞ ☎t emp la t e <typename Arrangement>vo i d p r i n t_ccb ( typename Arrangement : : C cb_ha l f e dg e_con s t_c i r c u l a t o r c i r c ){
s td : : cout << " ( " << c i r c−>sou r c e ()−>po i n t ( ) << " ) " ;typename Arrangement : : C cb_ha l f e dg e_con s t_c i r c u l a t o r c u r r = c i r c ;do {
typename Arrangement : : Ha l f edge_cons t_hand le he = cu r r ;s t d : : cout << "␣␣␣ [ " << he−>curve ( ) << " ] ␣␣␣"
<< " ( " << he−>t a r g e t ()−>po i n t ( ) << " ) " ;} wh i l e (++cu r r != c i r c ) ;s t d : : cout << s td : : e nd l ;
}✝ ✆he−>curve ( ) is equivalent to he−>twin ()−> curve ( ) ,he−>sou r c e ( ) is equivalent to he−>twin ()−> t a r g e t ( ) , andhe−>t a r g e t ( ) is equivalent to he−>twin ()−> sou r c e ( ) .
2D Arrangements 11
Traversing the Ccbs of an Arrangement FacePrint the outer and inner boundaries of a face.✞ ☎t emp la t e <typename Arrangement>vo i d p r i n t_ f a c e ( typename Arrangement : : Face_const_handle f ){
// P r i n t the ou t e r boundary .i f ( f−>is_unbounded ( ) ) s t d : : cout << "Unbounded␣ f a c e . ␣ " << s td : : e nd l ;e l s e {
s td : : cout << "Outer ␣ boundary : ␣ " ;p r in t_ccb<Arrangement >(f−>outer_ccb ( ) ) ;
}
// P r i n t the boundary o f each o f the h o l e s .i n t i nd e x = 1 ;typename Arrangement : : Ho l e_con s t_ i t e r a t o r ho l e ;f o r ( ho l e = f−>ho l e s_beg i n ( ) ; h o l e != f−>holes_end ( ) ; ++hole , ++index ) {
s td : : cout << "␣␣␣␣Hole ␣#" << index << " : ␣" ;p r in t_ccb<Arrangement >(∗ho l e ) ;
}
// P r i n t the i s o l a t e d v e r t i c e s .typename Arrangement : : I s o l a t e d_ v e r t e x_ c o n s t _ i t e r a t o r i v ;f o r ( i v = f−>i s o l a t e d_ v e r t i c e s _ b e g i n ( ) , i nd e x = 1 ;
i v != f−>i s o l a t e d_ v e r t i c e s_ e n d ( ) ; ++iv , ++index )s td : : cout << "␣␣␣␣ I s o l a t e d ␣ v e r t e x ␣#" << index << " : ␣"
<< " ( " << iv−>po i n t ( ) << " ) " << s td : : e nd l ;}✝ ✆2D Arrangements 12
Traversing an ArrangementPrint all the cells of an arrangement.✞ ☎t emp la t e <typename Arrangement>vo i d p r i n t_a r r angement ( con s t Arrangement& a r r ){
CGAL_precondit ion ( a r r . i s _ v a l i d ( ) ) ;
// P r i n t the ar rangement v e r t i c e s .typename Arrangement : : V e r t e x_con s t_ i t e r a t o r v i t ;s t d : : cout << a r r . numbe r_o f_ve r t i c e s ( ) << "␣ v e r t i c e s : " << s td : : e nd l ;f o r ( v i t = a r r . v e r t i c e s _ b e g i n ( ) ; v i t != a r r . v e r t i c e s_ end ( ) ; ++v i t ) {
s td : : cout << " ( " << v i t−>po i n t ( ) << " ) " ;i f ( v i t−>i s _ i s o l a t e d ( ) ) s t d : : cout << "␣−␣ I s o l a t e d . " << s td : : e nd l ;e l s e s t d : : cout << "␣−␣ deg r ee ␣" << v i t−>deg ree ( ) << s td : : e nd l ;
}
// P r i n t the ar rangement edges .typename Arrangement : : Edge_con s t_ i t e r a t o r e i t ;s t d : : cout << a r r . number_of_edges ( ) << "␣ edges : " << s td : : e nd l ;f o r ( e i t = a r r . edges_beg in ( ) ; e i t != a r r . edges_end ( ) ; ++e i t )
s t d : : cout << " [ " << e i t−>curve ( ) << " ] " << s td : : e nd l ;
// P r i n t the ar rangement f a c e s .typename Arrangement : : F a c e_con s t_ i t e r a t o r f i t ;s t d : : cout << a r r . number_of_faces ( ) << "␣ f a c e s : " << s td : : e nd l ;f o r ( f i t = a r r . f a c e s_beg i n ( ) ; f i t != a r r . f aces_end ( ) ; ++f i t )
p r i n t_ f a c e <Arrangement >( f i t ) ;}✝ ✆2D Arrangements 13
Modifying the Arrangement
v1 v2f
vu
Inserting a curve that inducesa new hole inside the face f ,a r r . i n s e r t _ i n _ f a c e _ i n t e r i o r ( c , f ) .
Inserting a curve from an existing vertex uthat corresponds to one of its endpoints,i n s e r t_ f r om_ l e f t_ v e r t e x ( c , v ) ,i n s e r t_ f r om_ r i g h t_v e r t e x ( c , v ) .
v1
v2
h1
f f ′h2
Inserting an x -monotone curve, the endpointsof which correspond to existing vertices v1and v2, i n s e r t _ a t _ v e r t i c e s ( c , v1 , v2 ) .
The new pair of halfedges close a new face f ′.The hole h1, which belonged to f before theinsertion, becomes a hole in this new face.
2D Arrangements 14
Outline
1 Definitions
2 Representation
3 Queries & Free FunctionsPoint Location QueriesThe Zone Computation AlgorithmThe Plane Sweep AlgorithmVertical DecompositionMap Overlay
4 Arrangement-Traits Classes
5 Extending the ArrangementExtending Cell Records
6 Literature
2D Arrangements 15
Arrangement Point Location
Given a subdivision A of the space into cells and a query point q, find thecell of A containing q.
q
2D Arrangements 16
Arrangement Point Location
Given a subdivision A of the space into cells and a query point q, find thecell of A containing q.
q
2D Arrangements 17
Arrangement Point Location
Given a subdivision A of the space into cells and a query point q, find thecell of A containing q.
In degenerate situations the query point can
2D Arrangements 18
Arrangement Point Location
Given a subdivision A of the space into cells and a query point q, find thecell of A containing q.
q
In degenerate situations the query point canlie on an edge, or
2D Arrangements 19
Arrangement Point Location
Given a subdivision A of the space into cells and a query point q, find thecell of A containing q.
q
In degenerate situations the query point canlie on an edge, or
2D Arrangements 20
Arrangement Point Location
Given a subdivision A of the space into cells and a query point q, find thecell of A containing q.
q
In degenerate situations the query point canlie on an edge, orcoincide with a vertex.
2D Arrangements 21
Arrangement Point Location
Given a subdivision A of the space into cells and a query point q, find thecell of A containing q.
q
In degenerate situations the query point canlie on an edge, orcoincide with a vertex.
2D Arrangements 22
Cgal Point Location Strategies
NaiveTraverse all edges of the arrangement to find the closes.
Walk along lineWalk along a vertical line from infinity.
Trapezoidal map Randomized Incremental-Construction (RIC)Landmark
2D Arrangements 23
Point Location: PrintPrint a polymorphic object.✞ ☎t emp la t e <typename Arrangement_>vo i d p r i n t_p o i n t_ l o c a t i o n ( cons t typename Arrangement_ : : Point_2& q ,
CGAL : : A r r_po i n t_ l o c a t i o n_ r e s u l t <Arrangement_ >: : Type& ob j ){
t y p ed e f Arrangement_ Arrangementt y p ed e f typename Arrangement : : Ve r tex_cons t_hand le Ver tex_cons t_hand le ;t y p ed e f typename Arrangement : : Ha l f edge_cons t_hand le Ha l f edge_cons t_hand le ;t y p ed e f typename Arrangement : : Face_const_handle Face_const_handle ;
con s t Ver tex_cons t_hand le∗ v ;con s t Ha l f edge_cons t_hand le∗ e ;con s t Face_const_handle∗ f ;
s t d : : cout << "The␣ po i n t ␣ ( " << q << " ) ␣ i s ␣ l o c a t e d ␣" ;i f ( ( f = boos t : : get<Face_const_handle>(&ob j ) ) ) // l o c a t e d i n s i d e a f a c e
s td : : cout << " i n s i d e ␣"<< (((∗ f)−>is_unbounded ( ) ) ? " the ␣unbounded " : " a␣bounded " )<< "␣ f a c e . " << s td : : e nd l ;
e l s e i f ( ( e = boos t : : get<Hal fedge_const_hand le >(&ob j ) ) ) // l o c a t e d on an edges td : : cout << "on␣an␣ edge : ␣" << (∗ e)−>curve ( ) << s td : : e nd l ;
e l s e i f ( ( v = boos t : : get<Vertex_const_hand le >(&ob j ) ) ) // l o c a t e d on a v e r t e xs td : : cout << "on␣" << (((∗ v)−>i s _ i s o l a t e d ( ) ) ? " an␣ i s o l a t e d " : " a " )
<< "␣ v e r t e x : ␣ " << (∗ v)−>po i n t ( ) << s td : : e nd l ;e l s e CGAL_error_msg ( " I n v a l i d ␣ o b j e c t . " ) ; // t h i s s hou l d neve r happen
}✝ ✆2D Arrangements 24
Point Location: Locate✞ ☎t emp la t e <typename Po in tLoca t i on>vo i d l o c a t e_po i n t ( con s t Po i n tLo ca t i o n& pl ,
con s t typename Po i n t_ l o c a t i o n : : Arrangement_2 : : Point_2& q ){
t y p ed e f Po i n tLo ca t i o n Po i n t_ l o c a t i o n ;t y p ed e f typename Po i n t_ l o c a t i o n : : Arrangement_2 Arrangement_2 ;typename CGAL : : A r r_po i n t_ l o c a t i o n_ r e s u l t <Arrangement_2 >: : Type ob j = p l . l o c a t e ( q ) ;
// P r i n t the r e s u l t .p r i n t_po i n t_ l o c a t i o n <Arrangement_2>(q , ob j ) ;
}✝ ✆q1
q2 q3q4 q5
q6
2D Arrangements 25
Point Location: Example✞ ☎// F i l e : e x_po i n t_ l o c a t i o n . cpp
#i n c l u d e <CGAL/ b a s i c . h>#i n c l u d e <CGAL/ Ar r_na i v e_po i n t_ l o c a t i o n . h>#i n c l u d e <CGAL/Ar r_ landmark s_po in t_ loca t i on . h>
#i n c l u d e " a r r_ i n e xa c t_con s t r u c t i o n_s egmen t s . h"#i n c l u d e " p o i n t _ l o c a t i o n_ u t i l s . h"
t y p ed e f CGAL : : A r r_na i v e_po i n t_ l o ca t i on<Arrangement_2> Naive_pl ;t y p ed e f CGAL : : Ar r_ landmarks_po in t_ loca t i on<Arrangement_2> Landmarks_pl ;
i n t main ( ){
// Cons t ruc t the ar rangement .Arrangement_2 a r r ;con s t ruc t_segment s_a r r ( a r r ) ;
// Perform some po in t−l o c a t i o n q u e r i e s u s i n g the na i v e s t r a t e g y .Na ive_p l na i v e_p l ( a r r ) ;l o c a t e_po i n t ( na i ve_p l , Point_2 (1 , 4 ) ) ; // q1
// Attach the landmarks o b j e c t to the ar rangement and per fo rm q u e r i e s .Landmarks_pl landmarks_p l ;l andmarks_p l . a t t a ch ( a r r ) ;l o c a t e_po i n t ( landmarks_pl , Point_2 (3 , 2 ) ) ; // q4
r e t u r n 0 ;}✝ ✆2D Arrangements 26
The Zone of Curves in Arrangements
Definition (Zone)Given an arrangement of curves A = A(C) in the plane, the zone of anadditional curve γ /∈ C in A is the union of the features of A, whoseclosure is intersected by γ.
γ The zone of a line γ in an arrangement oflines.
2D Arrangements 27
Incremental Insertion✞ ☎// F i l e : e x_ i n c r emen t a l_ i n s e r t i o n . cpp
#i n c l u d e <CGAL/ b a s i c . h>#i n c l u d e <CGAL/ Ar r_na i v e_po i n t_ l o c a t i o n . h>
#i n c l u d e " a r r_exac t_con s t r u c t i on_segmen t s . h"#i n c l u d e " a r r _ p r i n t . h"
i n t main ( ){
// Cons t ruc t the ar rangement o f f i v e l i n e segments .Arrangement_2 a r r ;Na ive_p l p l ( a r r ) ;CGAL : : i n s e r t_non_ i n t e r s e c t i n g_ c u r v e ( a r r , Segment_2 ( Point_2 (1 , 0 ) , Point_2 (2 , 4 ) ) , p l ) ;CGAL : : i n s e r t_non_ i n t e r s e c t i n g_ c u r v e ( a r r , Segment_2 ( Point_2 (5 , 0 ) , Point_2 (5 , 5 ) ) ) ;CGAL : : i n s e r t ( a r r , Segment_2 ( Point_2 (1 , 0 ) , Point_2 (5 , 3 ) ) , p l ) ;CGAL : : i n s e r t ( a r r , Segment_2 ( Point_2 (0 , 2 ) , Point_2 (6 , 0 ) ) ) ;CGAL : : i n s e r t ( a r r , Segment_2 ( Point_2 (3 , 0 ) , Point_2 (5 , 5 ) ) , p l ) ;p r i n t_a r r angemen t_s i z e ( a r r ) ;r e t u r n 0 ;
}✝ ✆
s4s1
s3
s5s2
2D Arrangements 28
The Plane Sweep Algorithmic Framework[BO79]
Initialize an event queue with all endpoints sorted lexicographicallyWhile the queue is not empty, extract and process an event
Remove all x -monotone curves to the left of the current event pointfrom a sorted container of curvesInsert all x -monotone curves to the right of the current event pointinto the curve containerCompute intersections between existing curves and newly insertedcurves, and insert them into the event queue
2D Arrangements 29
The Plane Sweep Algorithmic Framework[BO79]
Initialize an event queue with all endpoints sorted lexicographicallyWhile the queue is not empty, extract and process an event
Remove all x -monotone curves to the left of the current event pointfrom a sorted container of curvesInsert all x -monotone curves to the right of the current event pointinto the curve containerCompute intersections between existing curves and newly insertedcurves, and insert them into the event queue
2D Arrangements 30
The Plane Sweep Algorithmic Framework[BO79]
Initialize an event queue with all endpoints sorted lexicographicallyWhile the queue is not empty, extract and process an event
Remove all x -monotone curves to the left of the current event pointfrom a sorted container of curvesInsert all x -monotone curves to the right of the current event pointinto the curve containerCompute intersections between existing curves and newly insertedcurves, and insert them into the event queue
2D Arrangements 31
The Plane Sweep Algorithmic Framework[BO79]
Initialize an event queue with all endpoints sorted lexicographicallyWhile the queue is not empty, extract and process an event
Remove all x -monotone curves to the left of the current event pointfrom a sorted container of curvesInsert all x -monotone curves to the right of the current event pointinto the curve containerCompute intersections between existing curves and newly insertedcurves, and insert them into the event queue
2D Arrangements 32
The Plane Sweep Algorithmic Framework[BO79]
Initialize an event queue with all endpoints sorted lexicographicallyWhile the queue is not empty, extract and process an event
Remove all x -monotone curves to the left of the current event pointfrom a sorted container of curvesInsert all x -monotone curves to the right of the current event pointinto the curve containerCompute intersections between existing curves and newly insertedcurves, and insert them into the event queue
2D Arrangements 33
The Plane Sweep Algorithmic Framework[BO79]
Initialize an event queue with all endpoints sorted lexicographicallyWhile the queue is not empty, extract and process an event
Remove all x -monotone curves to the left of the current event pointfrom a sorted container of curvesInsert all x -monotone curves to the right of the current event pointinto the curve containerCompute intersections between existing curves and newly insertedcurves, and insert them into the event queue
2D Arrangements 34
The Plane Sweep Algorithmic Framework[BO79]
Initialize an event queue with all endpoints sorted lexicographicallyWhile the queue is not empty, extract and process an event
Remove all x -monotone curves to the left of the current event pointfrom a sorted container of curvesInsert all x -monotone curves to the right of the current event pointinto the curve containerCompute intersections between existing curves and newly insertedcurves, and insert them into the event queue
2D Arrangements 35
The Plane Sweep Algorithmic Framework[BO79]
Initialize an event queue with all endpoints sorted lexicographicallyWhile the queue is not empty, extract and process an event
Remove all x -monotone curves to the left of the current event pointfrom a sorted container of curvesInsert all x -monotone curves to the right of the current event pointinto the curve containerCompute intersections between existing curves and newly insertedcurves, and insert them into the event queue
2D Arrangements 36
The Plane Sweep Algorithmic Framework[BO79]
Initialize an event queue with all endpoints sorted lexicographicallyWhile the queue is not empty, extract and process an event
Remove all x -monotone curves to the left of the current event pointfrom a sorted container of curvesInsert all x -monotone curves to the right of the current event pointinto the curve containerCompute intersections between existing curves and newly insertedcurves, and insert them into the event queue
2D Arrangements 37
The Plane Sweep Algorithmic Framework[BO79]
Initialize an event queue with all endpoints sorted lexicographicallyWhile the queue is not empty, extract and process an event
Remove all x -monotone curves to the left of the current event pointfrom a sorted container of curvesInsert all x -monotone curves to the right of the current event pointinto the curve containerCompute intersections between existing curves and newly insertedcurves, and insert them into the event queue
2D Arrangements 38
The Plane Sweep Algorithmic Framework[BO79]
Initialize an event queue with all endpoints sorted lexicographicallyWhile the queue is not empty, extract and process an event
Remove all x -monotone curves to the left of the current event pointfrom a sorted container of curvesInsert all x -monotone curves to the right of the current event pointinto the curve containerCompute intersections between existing curves and newly insertedcurves, and insert them into the event queue
2D Arrangements 39
Aggregate Insertion✞ ☎// F i l e : e x_agg r e g a t e d_ i n s e r t i o n . cpp
#i n c l u d e " a r r_exac t_con s t r u c t i on_segmen t s . h"#i n c l u d e " a r r _ p r i n t . h"
i n t main ( ){
// Agg r ega t e l y c o n s t r u c t the ar rangement o f f i v e l i n e segments .Segment_2 segments [ ] = {Segment_2 ( Point_2 (1 , 0 ) , Point_2 (2 , 4 ) ) ,
Segment_2 ( Point_2 (5 , 0 ) , Point_2 (5 , 5 ) ) ,Segment_2 ( Point_2 (1 , 0 ) , Point_2 (5 , 3 ) ) ,Segment_2 ( Point_2 (0 , 2 ) , Point_2 (6 , 0 ) ) ,Segment_2 ( Point_2 (3 , 0 ) , Point_2 (5 , 5 ) ) } ;
Arrangement_2 a r r ;CGAL : : i n s e r t ( a r r , segments , segments + s i z e o f ( segments )/ s i z e o f ( Segment_2 ) ) ;p r i n t_a r r angemen t_s i z e ( a r r ) ;r e t u r n 0 ;
}✝ ✆
s4s1
s3
s5s2
2D Arrangements 40
Map Overlay
Definition (map overlay)The map overlay of two planar subdivisions S1 and S2, denoted asoverlay(S1, S2), is a planar subdivision S, such that there is a face f in Sif and only if there are faces f1 and f2 in S1 and S2 respectively, such thatf is a maximal connected subset of f1 ∩ f2.
The overlay of two subdivisions embedded on a surface in R3 is definedsimilarly.n1, n2, n — number of vertices in S1, S2, overlay(S1, S2).
Time complexities of the computation of the overlay of 2 subdivisionsembedded on surfaces in R3:
Using sweep-line: O((n) log(n1 + n2)). [BO79]Using trapezoidal decomposition: O(n). [FH95]
⋆ Precondition: S1 and S2 are simply connected.
2D Arrangements 41
Map Overlay of Cgal✞ ☎t emp la t e <typename Tra i t sRed , typename Tra i t sB l u e , typename Tra i t sRe s ,
typename DcelRed , typename Dce lBlue , typename DcelRes ,typename Ove r l a yT r a i t s >
vo i d o v e r l a y ( con s t Arrangement__2<Tra i t sRed , DcelRed> & ar r1 ,con s t Arrangement__2<Tra i t sB l u e , Dce lBlue> & ar r2 ,Arrangement__2<Tra i t sRe s , DcelRes> & ar r_ r e s , O v e r l a yT r a i t s & ov l_ t r )✝ ✆
The concept OverlayTraits requires the provision of ten functions thathandle all possible cases as follows:
1 A new vertex v is induced by coinciding vertices vr and vb .2 A new vertex v is induced by a vertex vr that lies on an edge eb .3 An analogous case of a vertex vb that lies on an edge er .4 A new vertex v is induced by a vertex vr that is contained in a face fb .5 An analogous case of a vertex vb contained in a face fr .6 A new vertex v is induced by the intersection of two edges er and eb .7 A new edge e is induced by the overlap of two edges er and eb .8 A new edge e is induced by the an edge er that is contained in a face fb .9 An analogous case of an edge eb contained in a face fr .10 A new face f is induced by the overlap of two faces fr and fb .
2D Arrangements 42
Outline
1 Definitions
2 Representation
3 Queries & Free FunctionsPoint Location QueriesThe Zone Computation AlgorithmThe Plane Sweep AlgorithmVertical DecompositionMap Overlay
4 Arrangement-Traits Classes
5 Extending the ArrangementExtending Cell Records
6 Literature
2D Arrangements 43
Arrangement Geometry Traits
Separates geometric asspects from topological asspectsArrangement_2<Tra i t s , Dcel> — main component.
Is a parameter of the data structures and algorithms.Defines the family of curves that induce the arrangement.A parameterized data structure or algorithm can be used with anyfamily of curves for which a traits class is supplied.
AggregatesGeometric types (point, curve).Operations over types (accessors, predicates, constructons).
2D Arrangements 44
Arrangement Geometry Traits
Separates geometric asspects from topological asspectsArrangement_2<Tra i t s , Dcel> — main component.
Is a parameter of the data structures and algorithms.Defines the family of curves that induce the arrangement.A parameterized data structure or algorithm can be used with anyfamily of curves for which a traits class is supplied.
AggregatesGeometric types (point, curve).Operations over types (accessors, predicates, constructons).
Each input curve is subdivided into x-monotone subcurves.Most operations involve points and x-monotone curves.
2D Arrangements 45
Arrangement Traits Models
Line segments:1 Uses the kernel point and segment types.2 Caches the underlying line.
Linear curves, i.e., line segments, rays, and lines.Circular arcs and line segments.Conic curvesArcs of rational functions.Bézier curves.Algebraic curves of arbitrary degrees.
2D Arrangements 46
Arrangement Geometry Traits Models
① — ArrangementLandmarkTraits_2 ② — ArrangementTraits_2③ — ArrangementDirectionalXMonotoneTraits_2 ④ — ArrangementOpenTraits_2.
Model Name Curve Family Degree ConceptsArr_non_cach ing_segment_bas ic_tra i t s_2 line segments 1 ①
Arr_non_cach ing_segment_tra i t s_2 line segments 1 ①,②,③Arr_segment_t ra i t s_2 line segments 1 ①,②,③A r r_ l i n e a r_ t r a i t s _ 2 line segments, rays,
and lines1 ①,②,③,④
Ar r_c i r c l e_ s egmen t_ t r a i t s_2 line segments and cir-cular arcs
≤ 2 ②,③
A r r_ c i r c u l a r _ l i n e_ a r c_ t r a i t s _ 2 line segments and cir-cular arcs
≤ 2 ②
Ar r_con i c_ t r a i t s_2 circles, ellipses, andconic arcs,
≤ 2 ①,②,③
A r r_ r a t i o n a l_ f u n c t i o n_ t r a i t s_2 curves of rational func-tions
≤ 2 ①,②,③,④
Ar r_Bez i e r_cu r v e_t r a i t s_2 Bézier curves ≤ n ②,③Ar r_a l g eb r a i c_s egmen t_t r a i t s_2 algebraic curves ≤ n ②,③,④A r r_p o l y l i n e_ t r a i t s _ 2 polylines ∞ ①,②,③
2D Arrangements 47
Outline
1 Definitions
2 Representation
3 Queries & Free FunctionsPoint Location QueriesThe Zone Computation AlgorithmThe Plane Sweep AlgorithmVertical DecompositionMap Overlay
4 Arrangement-Traits Classes
5 Extending the ArrangementExtending Cell Records
6 Literature
2D Arrangements 48
The Notification Mechanism
Definition (Observer)An observer defines a one-to-many dependency between objects, so thatwhen one object changes state, all its dependents are notified and updatedautomatically.
The 2D Arrangements package offers a mechanism that usesobservers.The observed type is derived from an instance ofAr r_obse rve r <Arrangement>.The observed object does not know anything about the observers.Each arrangement object stores a list of pointers to A r r_obs e r v e robjects.The trapezoidal-RIC and the landmark point-location strategies useobservers to keep their auxiliary data-structures up-to-date.
2D Arrangements 49
Observer Notification FunctionsThe set of functions can be divided into 3 categories:
1 Notifiers on changes that affect the topological structure of thearrangement. There are 2 pairs (before and after) that notify when
the arrangement is cleared orthe arrangement is assigned with the contents of another one.
2 Pairs of notifiers before and after of a local change that occurs in thetopological structure.
A new vertex is constructed or deleted.An new edge is constructed or deleted.1 edge is split into 2 edges, or 2 are merged into 1.1 face is split into 2 faces, or 2 are merged into 1.1 hole is created in the interior of a face or removed from it.2 holes are merged into 1, or 1 is split into 2.A hole is moved from one face to another.
3 Notifiers on a structural change caused by a free function. A singlepair be fo r e_g loba l_change ( ) anda f t e r_g l oba l_change ( ) .
2D Arrangements 50
Extending the Dcel FacesAn instance ofAr r_face_extended_dce l <Tra i t s , FaceData> is a Dcelthat extends the face record with the FaceData type.Data-fields must be maintained by the user application.
You can construct an arrangement, go over the faces, and store data inthe appropriate face data-fields.You can use an observer that receives updates whenever a face ismodified and sets its data fields accordingly.
s5
s3
s4
s2s1s6
[0][1]
[2][3]
[4]
[5]
[6]
[7]
ex_ fac e_ex t en s i on . cppAssigns indeces to all faces in the order ofcreation.
2D Arrangements 51
Extending the Dcel Faces (Cont.)✞ ☎#i n c l u d e <CGAL/ b a s i c . h>#i n c l u d e <CGAL/Arr_extended_dce l . h>#i n c l u d e <CGAL/ Ar r_obs e r v e r . h>
#i n c l u d e " a r r_exac t_con s t r u c t i on_segmen t s . h"
t y p ed e f CGAL : : Ar r_face_extended_dce l<Tra i t s_2 , uns i gned i n t > Dce l ;t y p ed e f CGAL : : Arrangement_2<Tra i t s_2 , Dcel> Ex_arrangement_2 ;
// An arrangement o b s e r v e r used to r e c e i v e n o t i f i c a t i o n s o f f a c e s p l i t s and// to update the i n d i c e s o f the newly c r e a t e d f a c e s .c l a s s Face_ index_obse rve r : p u b l i c CGAL : : Ar r_obse rve r<Ex_arrangement_2> {p r i v a t e :
un s i gned i n t n_faces ; // the c u r r e n t number o f f a c e s
p u b l i c :Face_ index_obse rve r ( Ex_arrangement_2& a r r ) :
CGAL : : Ar r_obse rve r<Ex_arrangement_2>( a r r ) , n_faces (0 ){
CGAL_precondit ion ( a r r . i s_empty ( ) ) ;a r r . unbounded_face()−>set_data ( 0 ) ;
}
v i r t u a l v o i d a f t e r _ s p l i t _ f a c e ( Face_handle o ld_face , Face_handle new_face , boo l ){
new_face−>set_data(++n_faces ) ; // a s s i g n i ndex to the new f a c e}
} ;✝ ✆2D Arrangements 52
Extending all the Dcel RecordsAn instance ofArr_extended_dce l<Tra i t s , VertexData , Hal fedgeData , FaceData>is a Dcel that extends the vertex, halfedge, and face records withthe corresponding types.✞ ☎
enum Co lo r {BLUE, RED, WHITE} ;
t y p ed e f CGAL : : Arr_extended_dce l<Tra i t s_2 , Co lor , boo l , un s i gned i n t > Dce l ;t y p ed e f CGAL : : Arrangement_2<Tra i t s_2 , Dcel> Ex_arrangement_2 ;✝ ✆✞ ☎
Ex_arrangement_2 : : V e r t e x_ i t e r a t o r v i t ;f o r ( v i t = a r r . v e r t i c e s _ b e g i n ( ) ; v i t != a r r . v e r t i c e s_ end ( ) ; ++v i t ) {
uns i gned i n t deg r e e = v i t−>deg ree ( ) ;v i t−>set_data ( ( deg r e e == 0) ? BLUE : ( ( deg r e e <= 2) ? RED : WHITE ) ) ;
}✝ ✆✞ ☎s t d : : cout << "The␣ ar rangement ␣ v e r t i c e s : " << s td : : e nd l ;f o r ( v i t = a r r . v e r t i c e s _ b e g i n ( ) ; v i t != a r r . v e r t i c e s_ end ( ) ; ++v i t ) {
s td : : cout << ’ ( ’ << v i t−>po i n t ( ) << " ) ␣−␣" ;sw i t c h ( v i t−>data ( ) ) {
ca se BLUE : s td : : cout << "BLUE . " << s td : : e nd l ; b reak ;ca s e RED : s td : : cout << "RED. " << s td : : e nd l ; b reak ;ca s e WHITE : s td : : cout << "WHITE. " << s td : : e nd l ; b reak ;
}}✝ ✆
2D Arrangements 53
Extending all the Dcel Records (Cont.)✞ ☎#i n c l u d e <s t r i n g >
#i n c l u d e <CGAL/ b a s i c . h>#i n c l u d e <CGAL/Arr_dce l_base . h>
/∗ ! The map extended d c e l v e r t e x ∗/temp la t e <typename Point_2>c l a s s Arr_map_vertex : p u b l i c CGAL : : Ar r_ver tex_base<Point_2> {p u b l i c :
s t d : : s t r i n g name , type ;} ;
/∗ ! The map extended d c e l h a l f e d g e ∗/temp la t e <typename X_monotone_curve_2>c l a s s Arr_map_halfedge : p u b l i c CGAL : : Ar r_ha l f edge_base<X_monotone_curve_2> {p u b l i c :
s t d : : s t r i n g name , type ;} ;
/∗ ! The map extended d c e l f a c e ∗/c l a s s Arr_map_face : p u b l i c CGAL : : Ar r_face_base {p u b l i c :
s t d : : s t r i n g name , type ;} ;
/∗ ! The map extended d c e l ∗/temp la t e <typename Tra i t s >c l a s s Arr_map_dcel : p u b l i cCGAL : : Arr_dce l_base<Arr_map_vertex<typename T r a i t s : : Point_2 >,
Arr_map_halfedge<typename T r a i t s : : X_monotone_curve_2>,Arr_map_face>
{} ;✝ ✆2D Arrangements 54
Outline
1 Definitions
2 Representation
3 Queries & Free FunctionsPoint Location QueriesThe Zone Computation AlgorithmThe Plane Sweep AlgorithmVertical DecompositionMap Overlay
4 Arrangement-Traits Classes
5 Extending the ArrangementExtending Cell Records
6 Literature
2D Arrangements 55
Arrangement Bibliography I
Jon Louis Bentley and Thomas Ottmann.Algorithms for Reporting and Counting Geometric Intersections.IEEE Transactions on Computers, 28(9): 643–647, 1979.
Eric Berberich, Efi Fogel, Dan Halperin, Michael Kerber, and Ophir Setter.Arrangements on parametric surfaces ii: Concretizations and applications, 2009.Mathematics in Computer Science, 4(1):67–91,2010.
Ulrich Finke and Klaus H. Hinrichs.Overlaying simply connected planar subdivisions in linear time.In Proceedings of 11th Annual ACM Symposium on Computational Geometry (SoCG), pages 119–126. Association forComputing Machinery (ACM) Press, 1995.
Ron Wein, Efi Fogel, Baruch Zukerman, Dan Halperin, and Eric Berberich.2D Arrangements.In Cgal Editorial Board, editor, Cgal User and Reference Manual. 4.4 edition, 2014. http://www.cgal.org/Manual/latest/doc_html/cgal_manual/packages.html#Pkg:Arrangement2.
David G. Kirkpatrick.Optimal search in planar subdivisions.SIAM Journal on Computing. 12(1):28–35,1983.
N. Sarnak and Robert E. Tarjan.Planar point location using persistent search trees.Communications of the ACM. 29(7):669–679, 1986.
Kentan Mulmuley.A fast planar partition algorithm, I.Journal of Symbolic Computation. 10(3-4):253–280,1990.
2D Arrangements 56
Arrangement Bibliography IIRaimund SeidelA Simple and Fast Incremental Randomized Algorithm for Computing Trapezoidal Decompositions and for TriangulatingPolygons.Computational Geometry: Theory and Applications. 1(1):51–64, 1991.
Olivier Devillers, Sylvain Pion, and Monique Teillaud.Walking in a triangulation.International Journal of Foundations of Computer Science. 13:181–199,2002.
Luc Devroye Christophe, Christophe Lemaire, and Jean-Michel Moreau.Fast Delaunay Point-Location with Search Structures.In Proceedings of 11th Canadian Conference on Computational Geometry. Pages 136–141, 1999.
Luc Devroye, Ernst Peter Mücke, and Binhai Zhu.A Note on Point Location in Delaunay Triangulations of Random Points.Algorithmica. 22:477–482, 1998.
Olivier Devillers.The Delaunay hierarchy.International Journal of Foundations of Computer Science. 13:163-180, 2002.
Sunil AryaA Simple Entropy-Based Algorithm for Planar Point Location.ACM Transactions on Graphics. 3(2), 2007
Masato Edahiro, Iwao Kokubo, And Takao AsanoA new Point-Location Algorithm and its Practical Efficiency: comparison with existing algorithmsACM Transactions on Graphics. 3(2):86–109, 1984.
Micha Sharir and Pankaj Kumar AgarwalDavenport-Schinzel Sequences and Their Geometric Applications.Cambridge University Press, New York, NY, 1995.
2D Arrangements 57
Arrangement Bibliography IIIBernard Chazelle, Leonidas J. Guibas, and Der-Tsai Le.The Power of Geometric Duality.BIT, 25:76–90, 1985.
Herbert Edelsbrunner,Algorithms in Combinatorial Geometry,Springer, Heidelberg, 1987.
Mark de Berg, Mark van Kreveld, Mark H. Overmars, and Otfried Cheong.Computational Geometry: Algorithms and Applications.Springer, 3rd edition, 2008.
Herbert Edelsbrunner, Raimund Seidel, and Micha Sharir.On the Zone Theorem for Hyperplane Arrangements.SIAM Journal on Computing. 22(2):418–429,1993.
Silvio Micali and Vijay V. Vazirani.
An O(√
|V ||E |) Algorithm for Finding Maximum Matching in General Graphs.Proceedings of 21st Annual IEEE Symposium on the Foundations of Computer Science, pages 17–27, 1980.
Jack Edmonds.Paths, Trees, and Flowers.Canadian Journal of Mathematics, 17:449–467,1965.
Robert Endre Tarjan.Data structures and network algorithms, Society for Industrial and Applied Mathematics (SIAM), 1983.
Marcin Mucha and Piotr Sankowski.Maximum Matchings via Gaussian EliminationProceedings of 45th Annual IEEE Symposium on the Foundations of Computer Science, pages 248–255, 2004.
2D Arrangements 58
Arrangement Bibliography IV
Jeremy G. Siek, Lie-Quan Lee, and Andrew Lumsdaine.The Boost Graph Library.Addison-Wesley, 2002
Efi Fogel, Ron Wein, and Dan Halperin.Cgal Arrangements and Their Applications, A Step-by-Step Guide.Springer, 2012.
2D Arrangements 59
Movies
Eyal Flato, Efi Fogel, Dan Halperin, and Eyal Leiserowitz.Movie: Exact Minkowski Sums and Applications.In Proceedings of 18th Annual ACM Symposium on Computational Geometry (SoCG), pages 273–274. Association forComputing Machinery (ACM) Press, 2005.
Efi Fogel and Dan Halperin.Movie: Exact Minkowski sums of convex polyhedra.In Proceedings of 21st Annual ACM Symposium on Computational Geometry (SoCG), pages 382–383. Association forComputing Machinery (ACM) Press, 2005.
Efi Fogel, Ophir Setter, and Dan Halperin.Movie: Arrangements of Geodesic Arcs on the Sphere.In Proceedings of 24th Annual ACM Symposium on Computational Geometry (SoCG), pages 218–219. Association forComputing Machinery (ACM) Press, 2008.
2D Arrangements 60