2D Arrangements in CGAL: Recent Developments
description
Transcript of 2D Arrangements in CGAL: Recent Developments
![Page 1: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/1.jpg)
2D Arrangements in CGAL:2D Arrangements in CGAL:Recent DevelopmentsRecent Developments
CGAL Team
School of Computer Science
Tel Aviv University
Eti Ezra, Eyal Flato, Efi Fogel, Dan Halperin, Shai Hirsch,Eran Leiserowitz, Eli Packer, Tali Zvi, Ron Wein
![Page 2: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/2.jpg)
OutlineOutline
• Introduction
• The Packages in Brief
• Exploiting the Kernel
• Categorizing the Traits
• Benchmarking
• More Work
![Page 3: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/3.jpg)
OutlineOutline
• Introduction• The Package in Brief
• Exploiting the Kernel
• Categorizing the Traits
• Benchmarking
• More Work
![Page 4: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/4.jpg)
IntroductionIntroduction
“Bypasses are devices that allow some people to dash from point A to point B very fast while other people dash from point B to point A very fast. People living at point C, being a point directly in between, are often given to wonder what's so great about point A that so many people from point B are so keen to get there and what's so great about point B that so many people from point A are so keen to get there. They often wish that people would just once and for all work out where the hell they wanted to be.”
Douglas Adams
![Page 5: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/5.jpg)
DefinitionsDefinitions
Planar Maps
Planar graphs that are embedded
in the plane
![Page 6: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/6.jpg)
Definitions (cont.)Definitions (cont.)
Planar Arrangements
Given a collection Γ of planar curves,
the arrangement A(Γ) is the partition
of the plane to vertices, edges and
faces induced by the curves of Γ
![Page 7: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/7.jpg)
Application: GISApplication: GIS
[Nguyen Dong Ha, et al.]
![Page 8: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/8.jpg)
Application: Robot Motion PlanningApplication: Robot Motion Planning
[Flato, Halperin]
![Page 9: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/9.jpg)
OutlineOutline
• Introduction
• The Package in Brief• Exploiting the Kernel
• Categorizing the Traits
• Benchmarking
• More Work
![Page 10: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/10.jpg)
The Package in BriefThe Package in Brief
“A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.”
Douglas Adams
![Page 11: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/11.jpg)
The Package in BriefThe Package in Brief
• Goal: Construct, maintain, modify, traverse, query and present subdivisions of the plane
• Exact
• Generic
• Handles all degeneracies
• Efficient
![Page 12: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/12.jpg)
• Topological_map – Maintains topological maps of finite edges
• Planar_map_2– Maintains planar maps of interior-disjoint x-
monotone curves• Planar_map_with_intersections_2
– Maintains planar maps of general curves (may intersect, may be non-x-monotone)
• Arrangement_2– Maintains planar maps of intersecting curves
along with curve history
![Page 13: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/13.jpg)
The Package in BriefThe Package in Brief
![Page 14: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/14.jpg)
FunctionalityFunctionality
• Creation & Destruction• I/O
– Save, Load, Print (ASCII streams)– Draw (graphic streams)– Flexibility (Adaptable and Extensible, Verbose mode,
I/O of specific elements)• Modification
– Insertion, Removal, Split, Merge• Traversal • Queries
– Number of Vertices, Halfedges, & Faces– Is Point in Face– Point Location, Vertical ray shoot
![Page 15: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/15.jpg)
TraversalTraversal
• Element Traversal– Vertex Iterator– Face Iterator– Edge Iterator– Halfedge Iterator
• Map Traversal– Connected Component of the Boundary
(CCB) Halfedge Circulator– Around Vertex Halfedge Circulator– Hole Iterator
![Page 16: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/16.jpg)
Point Location StrategiesPoint Location Strategies
• Naive– No preprocessing, no internal data– Linear query time
• Walk along a line– No preprocessing, no internal data– Linear query time with heuristics
• Trapezoidal decomposition based– Preprocessing, internal data– Expected logarithmic query time
![Page 17: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/17.jpg)
Traits ClassesTraits Classes
• Geometric Interface• Parameter of package
– Defines the family of curves in interest– Package can be used with any family of
curves for which a traits class is supplied
• Aggregate– geometric types (points, curves)– Operations over types (accessors,
predicates, constructors)
![Page 18: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/18.jpg)
Traits ClassesTraits Classes
• Supplied Traits Classes – Segments, Polylines, Circular arcs and Line
segments, Conics (and line segments).
• Other Known Traits Classes– Circular arcs, Canonical Parabola, Bezier
Curves
![Page 19: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/19.jpg)
InsertionsInsertions
• Non intersecting insert
• Intersecting insertHalfedge_handle
insert(const X_curve_2 & cv,
Change_notification * en = NULL);
Halfedge_handle
non_intersecting_insert(const X_curve_2 & cv,
Change_notification *
en = NULL);
![Page 20: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/20.jpg)
InsertionsInsertions
• Incremental Insert• Aggregate Insert• Often information is known in advance
– Containing faceInsert in face interior
– Incident verticesInsert from vertex, between vertices
– Order around vertexInsert from halfedge target, between halfedge
targets
![Page 21: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/21.jpg)
Aggregate InsertAggregate Insert
• Inserts a container into the map
• Two versions– Simplified - planar map no intersections– General - planar map with intersections
• Sweep based– If planar map is not empty, use overlay
template <class curve_iterator>
Halfedge_iterator
insert(const curve_iterator & begin,
const curve_iterator & end,
Change_notification * en = NULL);
![Page 22: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/22.jpg)
OutlineOutline
• Introduction
• The Package in Brief
• Exploiting the Kernel
• Categorizing the Traits
• Benchmarking
• More Work
![Page 23: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/23.jpg)
Exploiting the KernelExploiting the Kernel
“Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.”
Douglas Adams
![Page 24: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/24.jpg)
CGAL Kernel ContextCGAL Kernel Context
• CGAL consists of three major parts– Kernel– Basic geometric data structures and
algorithms• Convex Hull, Planar_map, Arrangement,
etc.
– Non-geometric support facilities
![Page 25: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/25.jpg)
CGAL KernelCGAL Kernel
• Encapsulates– Constant-size non-modifiable geometric
primitive object representations• Point, Segments, hopefully Conics, etc
– operations (and predicates) on these objects
• Adaptable and Extensible• Efficient• Used as a traits class for algorithms
![Page 26: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/26.jpg)
Adapting the kernelAdapting the kernel
• Exchange of representation classes– Representation classes are
parameterized by a number type– Geometric objects are extracted from
a representation class
template <class Kernel>class Pm_segment_traits_2 : public Kernel{public typedef typename Kernel::Point_2 Point_2; typedef typename Kernel::Segment_2 X_curve_2; …};
![Page 27: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/27.jpg)
Adapting the kernelAdapting the kernel
• Functors provide the functionality– Functor – a class that define an
appropriate operator()
• Object for functors are obtained through access member functionstemplate <class Kernel>class Pm_segment_traits_2 : public Kernel{ Comparison_result compare_x(const Point_2 & p1, const Point_2 & p2) const { return compare_x_2_object()(p1, p2); }};
![Page 28: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/28.jpg)
Adapting the kernelAdapting the kernel
• Code reduction– Implementation is simple and concise
• Traits reduction– Matthias Baesken LEDA Kernel makes
the dedicated LEDA Traits obsolete
#if defined(USE_LEDA_KERNEL)typedef CGAL::leda_rat_kernel_traits Kernel;#elsetypedef leda_rational NT;typedef CGAL::Cartesian<NT> Kernel;#endiftypedef CGAL::Pm_segment_traits_2<Kernel> Traits;
![Page 29: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/29.jpg)
OutlineOutline
• Introduction
• The Package in Brief
• Exploiting the Kernel
• Categorizing the Traits
• Benchmarking
• More Work
![Page 30: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/30.jpg)
Categorizing the TraitsCategorizing the Traits
“It is a mistake to think you can solve any major problems just with potatoes.”
Douglas Adams
![Page 31: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/31.jpg)
Categorizing the TraitsCategorizing the Traits
• In the past – 2 levels of refinements – Planar map Traits– Planar map of intersecting curves Traits
• In the future – multiple categories– Each category identifies a behavior
• Multiple Tags
– All categories identify the Traits
![Page 32: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/32.jpg)
Dispatching AlgorithmsDispatching Algorithms
• Tailored Algorithms– Curve category
• Segments, Circular Arcs, Conics
template <class Kernel>class Arr_segment_traits_2{ typedef Segment_tag Curve_category;};
template <class Kernel>class Arr_conic_traits_2{ typedef Conic_tag Curve_category;};
![Page 33: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/33.jpg)
Dispatching AlgorithmsDispatching Algorithms
• Trading between efficiency and complexity – Intersection Category
• Lazy, Efficient
typedef Lazy_intersection_tag Intersection_category;Point_2 reflect_point(const Point_2 & pt) const;X_curve_2 reflect_curve(const X_curve_2 & cv) const;Bool nearest_intersection_to_right(…) const;
typedef Efficient_intersection_tag Intersection_category;
Bool nearest_intersection_to_right(…) const;Bool nearest_intersection_to_left(…) const;
![Page 34: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/34.jpg)
Tightening the TraitsTightening the Traits
• Different operations may have– Different requirements– Different preconditions
• Minimal set of requirements– Sweep has less requirement
bool do_intersect_to_left(c1, c2, pt)bool do_intersect_to_right(c1, c2, pt)
bool nearest_intersection_to_left(c1, c2, pt, …)bool nearest_intersection_to_right(c1, c2, pt, …)
result curve_compare_at_x_left(cv1, cv2, pt)result curve_compare_at_x_right(cv1, cv2, pt)
![Page 35: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/35.jpg)
SpecializationSpecialization
• Caching– Avoid computations (intersection points)– Avoid construction (extreme end-points)– Code Reuse
• Caching of intersection points is currently implemented as part of the conic traits
– Requires redefinition of some classes (e.g., halfedge)
Work in progress
![Page 36: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/36.jpg)
OutlineOutline
• Introduction
• The Package in Brief
• Exploiting the Kernel
• Categorizing the Traits
• Benchmarking• More Work
![Page 37: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/37.jpg)
Insert MultiplicationsInsert Multiplications
Non intersecting vs. intersecting 2
Incremental vs. aggregate 2
Point location strategies 3
CGAL cartesian parameterized with LEDA rational number type vs. Matthias LEDA Kernel
2
Segments, Conics 2
Traits categories 2
Total 96
![Page 38: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/38.jpg)
BenchmarksBenchmarks
onebig 100
0
1
2
3
4
5
6
7
8
31-Oct 10-Nov 20-Nov 30-Nov 10-Dec
date
oper
atio
n tim
e (s
ec)
Inc,Leda traits Inc, Leda Kernel
Agg, Leda traits Agg, Leda Kernel
onebig 100
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
5-Nov 10-Nov
15-Nov
20-Nov
25-Nov
30-Nov
5-Dec
date
oper
atio
n tim
e (s
ec)
Agg, Leda traits Agg, Leda Kernel
![Page 39: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/39.jpg)
BenchmarksBenchmarks
random 100
0
0.5
1
1.5
2
2.5
3
3.5
5-Nov 10-Nov
15-Nov
20-Nov
25-Nov
30-Nov
5-Dec
date
oper
atio
n tim
e (s
ec)
Inc,Leda traits Inc, Leda Kernel
Agg, Leda traits Agg, Leda Kernel
random 100
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
5-Nov 10-Nov
15-Nov
20-Nov
25-Nov
30-Nov
5-Dec
date
oper
atio
n tim
e (s
ec)
Agg, Leda traits Agg, Leda Kernel
![Page 40: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/40.jpg)
OutlineOutline
• Introduction
• The Package in Brief
• Exploiting the Kernel
• Categorizing the Traits
• Benchmarking
• More Work
![Page 41: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/41.jpg)
More WorkMore Work
“Capital letters were always the best way of dealing with things you didn't have a good answer to.”
Douglas Adams
![Page 42: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/42.jpg)
More WorkMore Work
• Consolidate Pm and Pmwx into a unified class Planar_map_2
• Introduce more Specialization categories and options
• Introduce more Point Location Strategies
• Introduce Traits classes for complex curves
• Move up to higher dimensions
![Page 43: 2D Arrangements in CGAL: Recent Developments](https://reader036.fdocuments.in/reader036/viewer/2022081418/5681441b550346895db0b7b0/html5/thumbnails/43.jpg)
EndEnd