Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Computational Geometry Algorithm Library Andreas Fabri INRIA Sophia-Antipolis CGAL.

Similar presentations


Presentation on theme: "The Computational Geometry Algorithm Library Andreas Fabri INRIA Sophia-Antipolis CGAL."— Presentation transcript:

1 The Computational Geometry Algorithm Library Andreas Fabri INRIA Sophia-Antipolis CGAL

2 Andreas Fabri, Meshing Roundtable 2001 2 European Project CGAL “Make the large body of geometric algorithms developed in the field of computational geometry available for industrial applications” Started in 1996 as joined project of: ETH Zurich, INRIA, MPI für Informatik, Tel-Aviv U, Utrecht U, Trier U, FU Berlin

3 CGALAndreas Fabri, Meshing Roundtable 2001 3 The CGAL Class Library 1200 C++ classes, 300 KLOC, 1100 p manual 40 developer years Supported Platforms –Irix 6.5 / SGI Mips CC 7.3, g++ –Solaris 2.6 / KCC, g++ –Wintel/ VC++6.0, Borland C++5.0, g++ 1500 downloads of each release CGAL is enabling technology

4 CGALAndreas Fabri, Meshing Roundtable 2001 4 Basic Library Structure of CGAL Support Library: Configuration, Assertions Visualization File I/O Number Types Generators STL extensions Point, Segment,... Predicates Kernel TriangulationsArrangements Halfedge Datastructure Convex HullOptimisation...

5 The Basic Library A collection of pearls

6 CGALAndreas Fabri, Meshing Roundtable 2001 6 Triangulations Basic, Delaunay, regular, constrained 2D Fully dynamic data structures Operations –point location, –traversal along a line –traversal of the triangulation

7 CGALAndreas Fabri, Meshing Roundtable 2001 7 Triangulations Hierarchy Alpha shapes Voronoi diagram, power diagram k-order Voronoi diagram 2D* Natural neighbors* Conforming Delaunay 3D**

8 CGALAndreas Fabri, Meshing Roundtable 2001 8 Polyhedral Surface Orientable 2-manifolds with boundary Based on half edge data structure Operations –Euler operations –rich low level API HEDS is highly configurable

9 CGALAndreas Fabri, Meshing Roundtable 2001 9 Convex Hull 2D Convex Hull –5 algorithms for points –CH of a simple polyline Convexity Test Extremal Points 3D Convex Hull –static, incremental, dynamic

10 CGALAndreas Fabri, Meshing Roundtable 2001 10 Boolean Operations on Polygons

11 CGALAndreas Fabri, Meshing Roundtable 2001 11 Planar Subdivisions Framework for arrangements of 2D curves –based on planar maps –based on topological maps –Models exist for polylines, circles, conic arcs Operations –point location, overlay, ray shooting,..

12 CGALAndreas Fabri, Meshing Roundtable 2001 12 Optimization Smallest enclosing sphere in dD Polytope distance in dD Smallest enclosing circle/ellipse in 2D Rectangular p center Smallest enclosing annulus in dD

13 CGALAndreas Fabri, Meshing Roundtable 2001 13 and... Polygon decomposition Boolean operations on polyhedra ** Range trees, segment trees, kd-trees Visibility complex 2* Plane sweep framework* Largest empty rectangle* Smallest enclosing sphere of spheres*

14 The Kernel Robustness by Exactness Exact but Efficient

15 CGALAndreas Fabri, Meshing Roundtable 2001 15 Kernel Point, vector, direction, segment, ray, line, triangle, circle, sphere, tetrahedron Predicates –orientation, do_intersect, closer_than Constructions –intersection, distance, affine transformation

16 CGALAndreas Fabri, Meshing Roundtable 2001 16 Robustness of Predicates Correctness through –exact arithmetic, or –exact geometric predicates and constructions Challenge: Being exact and efficient Collinear iff det(M) == 0 Collinear iff det(M) in [ - ,  ] Collinear iff det(M) == 0

17 CGALAndreas Fabri, Meshing Roundtable 2001 17 Exact Arithmetic exact number types –integers: GMP_Z, leda_integer –rationals: Quotient, MP_Float –reals: Core, leda_real Leads to unacceptable slowdown

18 CGALAndreas Fabri, Meshing Roundtable 2001 18 Fast Exact Predicates Filtered arithmetic predicate Filtered geometric predicate Principle –interval arithmetic –fast inexact but certified computation –if filter fails: slow exact computation

19 CGALAndreas Fabri, Meshing Roundtable 2001 19 Fast Exact Constructions Store history of computation in a DAG of geometric constructions* S2 S1 S4 S3 S1 P2 P1 P2 P1 Q S2S3S4 intersect construct S S

20 Library Design Let’s play Lego

21 CGALAndreas Fabri, Meshing Roundtable 2001 21 Design Goals Offer trade-off between –robustness and efficiency –flexibility and ease of use Technical decision –C++ class library –Generic programming paradigm [Musser89]

22 CGALAndreas Fabri, Meshing Roundtable 2001 22 int min(int a, int b) float min(float a, float b) template CompType min(CompType a, CompType b) { return (a<b) ? a : b; } BigInt n(9), m(8), r; r = min( n, m ); BigInt is a model for the concept CompType Generic Programming

23 CGALAndreas Fabri, Meshing Roundtable 2001 23 Parameterization in the Kernel Point CartesianHomogeneous double Quotient MP_Float int gmpz typedef Cartesian C; typedef Filtered_kernel K; typedef K::Point_3 Point;

24 CGALAndreas Fabri, Meshing Roundtable 2001 24 How to use ucb_Delaunay(ucb_list ) cmu::AlphaHull(cmu::PointList) in your application class point A Third Party Code Problem

25 CGALAndreas Fabri, Meshing Roundtable 2001 25 template class Delaunay_triangulation_2 { void insert(Geometry::Point t) { if(Geometry::orientation(p,q,t)==..) if(Geometry::incircle(p,q,r,t)) } }; Geometry as Parameter Works with CGAL kernels Works with projections kernels Write thin glue layer for your kernel

26 CGALAndreas Fabri, Meshing Roundtable 2001 26 Combinatorics as Parameter template class Delaunay_triangulation_2{ void insert(Point p) {.. Facet v = Combinatorics::create_facet();.. } }; Combinatorics allocates vertices, facets –Default data structure is facet based –It could be half edge based

27 CGALAndreas Fabri, Meshing Roundtable 2001 27 Iterators and Circulators A concept: generalisation of pointers Decouple algorithms and datastructures template class Delaunay_triangulation_2 { template void insert(Iterator begin, Iterator end) { Point p = *begin; ++begin;..} Vertex_iterator vertices_begin(){..} };

28 CGALAndreas Fabri, Meshing Roundtable 2001 28 Hello Triangle #include typedef Cartesian Geometry; typedef Triangulation_2 Triangulation ; typedef Triangulation::Vertex_circulator Vertex_circulator; typedef Geometry::Point_2 Point; int main() { Triangulation t; Point p; while (cin >> p) { t.insert(p); } Vertex_circulator vc = t.incident_vertices(t.infinite_vertex()), done(vc); do{ cout point(); } while(++vc != done); } 

29 CGALAndreas Fabri, Meshing Roundtable 2001 29 Robust and Fast Hello Triangle #include typedef Cartesian K; typedef Filtered_kernel Geometry; typedef Triangulation_2 T; typedef Triangulation_hierarchy_2 Triangulation; typedef Triangulation::Vertex_circulator Vertex_circulator; typedef Geometry::Point_2 Point; int main() { Triangulation t; Point p; while (cin >> p) { t.insert(p); } Vertex_circulator vc = t.incident_vertices(t.infinite_vertex()), done(vc); do{ cout point(); } while(++vc != done); }

30 CGALAndreas Fabri, Meshing Roundtable 2001 30 Points in a Coordinate Array #include typedef CGAL::Cartesian Geometry; typedef CGAL::Triangulation_cell_base_3 Cell; typedef CGAL::Triangulation_vertex_base_pointer_3 Vertex; typedef CGAL::Triangulation_data_structure_3 Combinatorics; typedef CGAL::Delaunay_triangulation_3 Triangulation; typedef Geometry::Point_3 Point; double xyz[4][4] = { {0,0,0, 6}, {3,0,0, 5}, {0,4,0, 9.3}, {2,2,2, 0.1}}; int main( ) { Triangulation t; for(int i=0; i < 4; i++) { t.insert((Point&) (*xyz[i])); } return 0; }

31 CGALAndreas Fabri, Meshing Roundtable 2001 31 The C++ is Slow Myth std::sort is faster than clib sort Delaunay 3D –51,095 points, 340,275 cells in 11.176 sec. –2 mio points, in 156 sec, P3 1Ghz HPC projects Blitz++

32 CGALAndreas Fabri, Meshing Roundtable 2001 32 GeometryFactory Library has reached a critical mass Acceptance of exact computing paradigm Maturity of compilers Acceptance of generic programming (STL) The right moment to found a company


Download ppt "The Computational Geometry Algorithm Library Andreas Fabri INRIA Sophia-Antipolis CGAL."

Similar presentations


Ads by Google