Subject: CGAL users discussion list
List archive
- From: Alessandro Attanasi <>
- To:
- Subject: [cgal-discuss] lower_hull_2() problem
- Date: Tue, 14 Jan 2014 22:54:04 +0100
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
void CGALearning__ConvexHull2D();
void ConvexHull__2D();
typedef enum convexHull_algo
{
INVALID = 0,
akl_toussaint = 1,
bykat = 2,
eddy = 3,
graham_andrew = 4,
jarvis = 5,
melkman = 6
} convexHullAlgo_t;
int main()
{
ConvexHull__2D();
return 0;
}
void ConvexHull__2D()
{
// the test points for convex hull are as in the picture below:
//
// * p1
//
// * p2 * p5
//
// * p6 * p9
//
// * p10
//
// * p7 * p8
//
// * p3 * p4
// definition of the input points
K::Point_2 p1(2,5);
K::Point_2 p2(0,4);
K::Point_2 p3(0,0);
K::Point_2 p4(4,0);
K::Point_2 p5(4,4);
K::Point_2 p6(1,3);
K::Point_2 p7(1,1);
K::Point_2 p8(3,1);
K::Point_2 p9(3,3);
K::Point_2 p10(2,2);
//--------------------------------------------------------------------------//
// vector storing input points
std::vector<K::Point_2> points_vect;
points_vect.push_back(p1);
points_vect.push_back(p2);
points_vect.push_back(p3);
points_vect.push_back(p4);
points_vect.push_back(p5);
points_vect.push_back(p6);
points_vect.push_back(p7);
points_vect.push_back(p8);
points_vect.push_back(p9);
points_vect.push_back(p10);
// vector storing results
std::vector<K::Point_2> result_vect;
// select here the convex hull algorithm that you want to use
convexHullAlgo_t chAlgo = akl_toussaint;
std::cout << " -------------------------------------------------------------------------------- " << std::endl;
std::cout << " STL VECTOR " << std::endl;
std::cout << " -------------------------------------------------------------------------------- " << std::endl;
switch(chAlgo)
{
case akl_toussaint:
std::cout << " AKL-TOUSSAINT with STL vector[] " << std::endl;
CGAL::ch_akl_toussaint( points_vect.begin(), points_vect.end(), std::back_inserter(result_vect) );
break;
case bykat:
std::cout << " BYKAT with STL vector[] " << std::endl;
CGAL::ch_bykat( points_vect.begin(), points_vect.end(), std::back_inserter(result_vect) );
break;
case eddy:
std::cout << " EDDY with STL vector[] " << std::endl;
CGAL::ch_eddy( points_vect.begin(), points_vect.end(), std::back_inserter(result_vect) );
break;
case graham_andrew:
std::cout << " GRAHAM-ANDREW with STL vector[] " << std::endl;
CGAL::ch_graham_andrew( points_vect.begin(), points_vect.end(), std::back_inserter(result_vect) );
break;
case jarvis:
std::cout << " JARVIS with STL vector[] " << std::endl;
CGAL::ch_jarvis( points_vect.begin(), points_vect.end(), std::back_inserter(result_vect) );
break;
case melkman:
std::cout << " MELKMAN with STL vector[] " << std::endl;
CGAL::ch_melkman( points_vect.begin(), points_vect.end(), std::back_inserter(result_vect) );
break;
default:
std::cout << "INVALID convex hull algorithm" << std::endl;
break;
}
// see how many points are into the convex hull
ch_points = result_vect.size();
// print out the number of points of the convex hull and the points themselves
std::cout << "1) Points on the convex hull = " << ch_points << std::endl;
for(int i =0;i<ch_points;i++)
{
std::cout << result_vect[i] << std::endl;
}
CGAL::lower_hull_points_2( points_vect.begin(), points_vect.end(), result_vect);
ch_points = result_vect.size();
std::cout << "6) Points on the lower hull = " << ch_points << std::endl;
for(int i =0;i<ch_points;i++)
{
std::cout << result_vect[i] << std::endl;
}
}
- [cgal-discuss] lower_hull_2() problem, Alessandro Attanasi, 01/14/2014
- Re: [cgal-discuss] lower_hull_2() problem, Philipp Moeller, 01/15/2014
- Re: [cgal-discuss] lower_hull_2() problem, Alessandro Attanasi, 01/15/2014
- Re: [cgal-discuss] lower_hull_2() problem, Philipp Moeller, 01/15/2014
- Re: [cgal-discuss] lower_hull_2() problem, Alessandro Attanasi, 01/15/2014
- Re: [cgal-discuss] lower_hull_2() problem, Philipp Moeller, 01/15/2014
- Re: [cgal-discuss] lower_hull_2() problem, Alessandro Attanasi, 01/15/2014
- Re: [cgal-discuss] lower_hull_2() problem, Philipp Moeller, 01/16/2014
- Re: [cgal-discuss] lower_hull_2() problem, Alessandro Attanasi, 01/16/2014
- Re: [cgal-discuss] lower_hull_2() problem, Philipp Moeller, 01/16/2014
- Re: [cgal-discuss] lower_hull_2() problem, Alessandro Attanasi, 01/17/2014
- Re: [cgal-discuss] lower_hull_2() problem, Alessandro Attanasi, 01/15/2014
- Re: [cgal-discuss] lower_hull_2() problem, Philipp Moeller, 01/15/2014
- Re: [cgal-discuss] lower_hull_2() problem, Alessandro Attanasi, 01/15/2014
- Re: [cgal-discuss] lower_hull_2() problem, Philipp Moeller, 01/15/2014
- Re: [cgal-discuss] lower_hull_2() problem, Alessandro Attanasi, 01/15/2014
- Re: [cgal-discuss] lower_hull_2() problem, Philipp Moeller, 01/15/2014
Archive powered by MHonArc 2.6.18.