introduction to cgal
play

Introduction to CGAL Constantinos Tsirogiannis TU / Eindhoven - PowerPoint PPT Presentation

Introduction to CGAL Constantinos Tsirogiannis TU / Eindhoven Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011 CGAL ? CGAL = Computational Geometry Algorithms Library: Constantinos Tsirogiannis Introduction to CGAL


  1. Introduction to CGAL Constantinos Tsirogiannis TU / Eindhoven Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  2. CGAL ? CGAL = Computational Geometry Algorithms Library: Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  3. CGAL ? CGAL = Computational Geometry Algorithms Library: A library of Geometric algorithms and data structures. Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  4. CGAL ? CGAL = Computational Geometry Algorithms Library: A library of Geometric algorithms and data structures. Written in C++ Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  5. CGAL ? CGAL = Computational Geometry Algorithms Library: A library of Geometric algorithms and data structures. Written in C++ Uses template programming Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  6. C++ C++ = C + Object Oriented Programming Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  7. C++ C++ = C + Object Oriented Programming Traditional C code: Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  8. C++ C++ = C + Object Oriented Programming Traditional C code: int a = 5; int b = 3; add function(a,b); Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  9. C++ C++ code: int a = 5; int b = 3; Example class foo; foo.add(a,b); Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  10. C++ Basics Here follow few basic concepts of C++ Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  11. Classes/Structures Class: Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  12. Classes/Structures Class: class Example class { public: int add( int a, int b) { return a + b; } ... private: int k; } ; Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  13. Classes/ Structures (cont’d) Structures: same as classes, yet everything is by default visible (“public”) Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  14. Namespaces Namespace: Can be seen as a “big bag” containing declarations of class types and functions. Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  15. Namespaces Namespace: Can be seen as a “big bag” containing declarations of class types and functions. Example: namespace FOO { class something { ... } ; class another class { ... } ; struct whatever { ... } ; int add(int a, int b) { a+b; } } Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  16. Namespace std To access the type something from a namespace FOO try: FOO::something or typename FOO::something Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  17. Namespace std To access the type something from a namespace FOO try: FOO::something or typename FOO::something Namespace std contains many helpfull classes and functions of the Standard Library of C++ . Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  18. Containers Nice and easy classes to insert and manipulate sets of objects. Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  19. Containers Nice and easy classes to insert and manipulate sets of objects. Example: Vectors std::vector < int > integers; integers.push back(4); integers.push back(-2); integers.push back(9); integers.push back(3); for( int i = 0; i < integers.size(); i ++ ) std::cout << integers [ i ] << std::endl; Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  20. Iterators An iterator is a substitute of a pointer. Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  21. Iterators An iterator is a substitute of a pointer. Iterators are used to go through the elements of a container or some other kind of range. Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  22. Iterators An iterator is a substitute of a pointer. Iterators are used to go through the elements of a container or some other kind of range. Example: std::vector < int > integers; integers.push back(4); integers.push back(-2); integers.push back(9); integers.push back(3); for( typename std::vector<int>::iterator it = integers.begin(); it < integers.end(); it ++ ) std::cout << *it << std::endl; Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  23. Input from file In the beginning of your .cpp file put: # include < fstream > Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  24. Input from file In the beginning of your .cpp file put: # include < fstream > To read a set of integers from a file: std::ifstream in(‘‘filename.txt’’); std::istream iterator < int > begin(in); std::istream iterator < int > end; std::vector < int > integers; integers.insert(integers.begin(),begin,end); Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  25. Output to file Example: std::ofstream os("filename.cout"); std::vector < int > integers; integers.push back(4); integers.push back(-2); integers.push back(9); integers.push back(3); for( typename std::vector<int>::iterator it = integers.begin(); it < integers.end(); it ++ ) os << *it << std::endl; Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  26. Template A template is a class or function that one can choose the types that it contains/manipulates. Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  27. Template A template is a class or function that one can choose the types that it contains/manipulates. Example: A function that computes a power of a given integer. int power (int base, int exponent) { int res=1; for( int i=1; i<=exponent; i++ ) res = res * base; return res; } Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  28. Templates Example: A function that computes a power of a given object of type Type . template < class Type > Type power ( Type base, int exponent) { Type res=1; for( int i = 1; i < = exponent; i ++ ) res = res * base; return res; } Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  29. CGAL CGAL provides implementations of: Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  30. CGAL CGAL provides implementations of: Triangulations. Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  31. CGAL CGAL provides implementations of: Triangulations. Voronoi diagrams. Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  32. CGAL CGAL provides implementations of: Triangulations. Voronoi diagrams. Arrangements. Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  33. CGAL CGAL provides implementations of: Triangulations. Voronoi diagrams. Arrangements. Kinetic Data Structures. Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  34. CGAL CGAL provides implementations of: Triangulations. Voronoi diagrams. Arrangements. Kinetic Data Structures. . . . Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  35. CGAL Concepts The concepts provided by CGAL are categorized as: Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  36. CGAL Concepts The concepts provided by CGAL are categorized as: Geometric Objects Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  37. CGAL Concepts The concepts provided by CGAL are categorized as: Geometric Objects Geometric Predicates/Constructions Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  38. CGAL Concepts The concepts provided by CGAL are categorized as: Geometric Objects Geometric Predicates/Constructions Geometric Algorithms/Data-Structures Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  39. Kernel Geometric objects and predicates appear inside a kernel. Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  40. Kernel Geometric objects and predicates appear inside a kernel. A kernel is more or less a large class the encapsulates objects and predicates that fall in the same general category. Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  41. Kernel Geometric objects and predicates appear inside a kernel. A kernel is more or less a large class the encapsulates objects and predicates that fall in the same general category. struct Cartesian kernel { class Point { ... } ; class Segment { ... } ; class Triangle { ... } ; ... class Do intersect predicate { ... } ; } ; Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  42. Kernel A kernel is in fact a template. The template parameter is a number type. Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

  43. Kernel A kernel is in fact a template. The template parameter is a number type. template < typename Num type > struct Cartesian kernel { class Point < Num type > { ... } ; class Segment < Num type > { ... } ; class Triangle < Num type > { ... } ; ... class Do intersect pred < Num type > { ... } ; } ; Constantinos Tsirogiannis Introduction to CGAL Thursday, April 7, 2011

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend