Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How to use CGAL?

+6 votes
asked Sep 2, 2019 by AbdElRahman Shabayek (180 points)

Dear Sir/Madam,

            I would like to use CGAL, how can I do that?

Example:

#include <iostream>

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

#include <CGAL/convex_hull_2.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;

typedef K::Point_2 Point_2;

int main()

{

Point_2 points[5] = { Point_2(0,0), Point_2(10,0), Point_2(10,10), Point_2(6,5), Point_2(4,1) };

Point_2 result[5];

Point_2 *ptr = CGAL::convex_hull_2( points, points+5, result );

std::cout << ptr - result << " points on the convex hull:" << std::endl;

for(int i = 0; i < ptr - result; i++){

std::cout << result[i] << std::endl;

}

return 0;

}

Best regards,

1 Answer

+1 vote
answered Jan 21 by ruuta (200 points)

Below is a simple example program I am trying to compile and run. The goal is to compute the convex hull of a set of 2D points using CGAL:

#include <iostream> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/convex_hull_2.h> typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef K::Point_2 Point_2; int main() { Point_2 points[5] = { Point_2(0,0), Point_2(10,0), Point_2(10,10), Point_2(6,5), Point_2(4,1) }; Point_2 result[5]; Point_2* ptr = CGAL::convex_hull_2(points, points + 5, result); std::cout << ptr - result << " points on the convex hull:" << std::endl; for (int i = 0; i < ptr - result; i++) { std::cout << result[i] << std::endl; } return 0; }

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...