Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] lower_hull_2() problem

Subject: CGAL users discussion list

List archive

[cgal-discuss] lower_hull_2() problem


Chronological Thread 
  • From: Alessandro Attanasi <>
  • To:
  • Subject: [cgal-discuss] lower_hull_2() problem
  • Date: Tue, 14 Jan 2014 22:54:04 +0100

Hi,

I'm a CGAL newbie and I'm learning convex_hull_2D package. I tried to use lower_hull_points_2() and upper_hull_points_2() functions but I obtained a lot of compilation errors. Maybe I'm not using properly the functions.

I'm using CGAL 4.1 on MacOSX, building the file the cgal script to create the cmake building chain

here there is my code

======================================================

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;

  }

}


=========================================================

and this is the  compilation output

AlecsMac:alecs_CovexHull2D alex$ make
[100%] Building CXX object CMakeFiles/learning_ConvexHull2D.dir/learning_ConvexHull2D.cpp.o
/Users/alex/Downloads/CGAL/CGAL/CGAL-4.1/alecs_CovexHull2D/../include/CGAL/Convex_hull_2/ch_graham_andrew_impl.h: In function ‘OutputIterator CGAL::ch_lower_hull_scan(InputIterator, InputIterator, OutputIterator, const Traits&) [with InputIterator = __gnu_cxx::__normal_iterator<CGAL::Point_2<CGAL::Epick>*, std::vector<CGAL::Point_2<CGAL::Epick>, std::allocator<CGAL::Point_2<CGAL::Epick> > > >, OutputIterator = std::vector<CGAL::Point_2<CGAL::Epick>, std::allocator<CGAL::Point_2<CGAL::Epick> > >, Traits = CGAL::Epick]’:
/Users/alex/Downloads/CGAL/CGAL/CGAL-4.1/alecs_CovexHull2D/../include/CGAL/convex_hull_2.h:144:   instantiated from ‘OutputIterator CGAL::lower_hull_points_2(InputIterator, InputIterator, OutputIterator, const Traits&) [with InputIterator = __gnu_cxx::__normal_iterator<CGAL::Point_2<CGAL::Epick>*, std::vector<CGAL::Point_2<CGAL::Epick>, std::allocator<CGAL::Point_2<CGAL::Epick> > > >, OutputIterator = std::vector<CGAL::Point_2<CGAL::Epick>, std::allocator<CGAL::Point_2<CGAL::Epick> > >, Traits = CGAL::Epick]’
/Users/alex/Downloads/CGAL/CGAL/CGAL-4.1/alecs_CovexHull2D/../include/CGAL/convex_hull_2.h:156:   instantiated from ‘OutputIterator CGAL::lower_hull_points_2(ForwardIterator, ForwardIterator, OutputIterator) [with ForwardIterator = __gnu_cxx::__normal_iterator<CGAL::Point_2<CGAL::Epick>*, std::vector<CGAL::Point_2<CGAL::Epick>, std::allocator<CGAL::Point_2<CGAL::Epick> > > >, OutputIterator = std::vector<CGAL::Point_2<CGAL::Epick>, std::allocator<CGAL::Point_2<CGAL::Epick> > >]’
/Users/alex/Downloads/CGAL/CGAL/CGAL-4.1/alecs_CovexHull2D/learning_ConvexHull2D.cpp:358:   instantiated from here
/Users/alex/Downloads/CGAL/CGAL/CGAL-4.1/alecs_CovexHull2D/../include/CGAL/Convex_hull_2/ch_graham_andrew_impl.h:258: error: no ‘operator++(int)’ declared for postfix ‘++’, trying prefix operator instead
/Users/alex/Downloads/CGAL/CGAL/CGAL-4.1/alecs_CovexHull2D/../include/CGAL/Convex_hull_2/ch_graham_andrew_impl.h:258: error: no match for ‘operator++’ in ‘++result’
/Users/alex/Downloads/CGAL/CGAL/CGAL-4.1/alecs_CovexHull2D/../include/CGAL/Convex_hull_2/ch_graham_andrew_impl.h: In function ‘OutputIterator CGAL::ch_graham_andrew_scan(BidirectionalIterator, BidirectionalIterator, OutputIterator, const Traits&) [with BidirectionalIterator = __gnu_cxx::__normal_iterator<CGAL::Point_2<CGAL::Epick>*, std::vector<CGAL::Point_2<CGAL::Epick>, std::allocator<CGAL::Point_2<CGAL::Epick> > > >, OutputIterator = std::vector<CGAL::Point_2<CGAL::Epick>, std::allocator<CGAL::Point_2<CGAL::Epick> > >, Traits = CGAL::Epick]’:
/Users/alex/Downloads/CGAL/CGAL/CGAL-4.1/alecs_CovexHull2D/../include/CGAL/Convex_hull_2/ch_graham_andrew_impl.h:268:   instantiated from ‘OutputIterator CGAL::ch_lower_hull_scan(InputIterator, InputIterator, OutputIterator, const Traits&) [with InputIterator = __gnu_cxx::__normal_iterator<CGAL::Point_2<CGAL::Epick>*, std::vector<CGAL::Point_2<CGAL::Epick>, std::allocator<CGAL::Point_2<CGAL::Epick> > > >, OutputIterator = std::vector<CGAL::Point_2<CGAL::Epick>, std::allocator<CGAL::Point_2<CGAL::Epick> > >, Traits = CGAL::Epick]’
/Users/alex/Downloads/CGAL/CGAL/CGAL-4.1/alecs_CovexHull2D/../include/CGAL/convex_hull_2.h:144:   instantiated from ‘OutputIterator CGAL::lower_hull_points_2(InputIterator, InputIterator, OutputIterator, const Traits&) [with InputIterator = __gnu_cxx::__normal_iterator<CGAL::Point_2<CGAL::Epick>*, std::vector<CGAL::Point_2<CGAL::Epick>, std::allocator<CGAL::Point_2<CGAL::Epick> > > >, OutputIterator = std::vector<CGAL::Point_2<CGAL::Epick>, std::allocator<CGAL::Point_2<CGAL::Epick> > >, Traits = CGAL::Epick]’
/Users/alex/Downloads/CGAL/CGAL/CGAL-4.1/alecs_CovexHull2D/../include/CGAL/convex_hull_2.h:156:   instantiated from ‘OutputIterator CGAL::lower_hull_points_2(ForwardIterator, ForwardIterator, OutputIterator) [with ForwardIterator = __gnu_cxx::__normal_iterator<CGAL::Point_2<CGAL::Epick>*, std::vector<CGAL::Point_2<CGAL::Epick>, std::allocator<CGAL::Point_2<CGAL::Epick> > > >, OutputIterator = std::vector<CGAL::Point_2<CGAL::Epick>, std::allocator<CGAL::Point_2<CGAL::Epick> > >]’
/Users/alex/Downloads/CGAL/CGAL/CGAL-4.1/alecs_CovexHull2D/learning_ConvexHull2D.cpp:358:   instantiated from here
/Users/alex/Downloads/CGAL/CGAL/CGAL-4.1/alecs_CovexHull2D/../include/CGAL/Convex_hull_2/ch_graham_andrew_impl.h:106: error: no match for ‘operator*’ in ‘*res’
/Users/alex/Downloads/CGAL/CGAL/CGAL-4.1/alecs_CovexHull2D/../include/CGAL/enum.h:93: note: candidates are: CGAL::Sign CGAL::operator*(CGAL::Sign, CGAL::Sign)
/Users/alex/Downloads/CGAL/CGAL/CGAL-4.1/alecs_CovexHull2D/../include/CGAL/MP_Float_impl.h:218: note:                 CGAL::MP_Float CGAL::operator*(const CGAL::MP_Float&, const CGAL::MP_Float&)
/Users/alex/Downloads/CGAL/CGAL/CGAL-4.1/alecs_CovexHull2D/../include/CGAL/Convex_hull_2/ch_graham_andrew_impl.h:106: error: no match for ‘operator++’ in ‘++res’
make[2]: *** [CMakeFiles/learning_ConvexHull2D.dir/learning_ConvexHull2D.cpp.o] Error 1
make[1]: *** [CMakeFiles/learning_ConvexHull2D.dir/all] Error 2
make: *** [all] Error 2

Thanks
Alessandro

--



Archive powered by MHonArc 2.6.18.

Top of Page