Skip to Content.
Sympa Menu

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

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] lower_hull_2() problem


Chronological Thread 
  • From: Alessandro Attanasi <>
  • To: Philipp Moeller <>
  • Cc:
  • Subject: Re: [cgal-discuss] lower_hull_2() problem
  • Date: Wed, 15 Jan 2014 22:17:18 +0100

Thanks!

my error was due to the missing back_inserter()

I have gcc version 4.2.1, so I tried to remove typedef from enum but it was complaining :) ... I don't think my compiler supports C++11

anyhow I found another strange behaviour, I computed lower and upper hull, but I obtained the same results. Points are the same I described in the previous email, and the code I used to compute the lower and upper hull are

  std::vector<K::Point_2>lower_hull;  

  CGAL::lower_hull_points_2( points_vect.begin(), points_vect.end(), std::back_inserter(lower_hull) );

  ch_points = lower_hull.size();

  std::cout << "6) Points on the lower hull = " << ch_points << std::endl;

  for(int i = 0; i < ch_points; i++)

  {

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

  }


  std::vector<K::Point_2>upper_hull;  

  CGAL::lower_hull_points_2( points_vect.begin(), points_vect.end(), std::back_inserter(upper_hull) );

  ch_points = upper_hull.size();

  std::cout << "7) Points on the upper hull = " << ch_points << std::endl;

  for(int i = 0; i < ch_points; i++)

  {

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

  }  


obtaining in both cases the same result:

6) Points on the lower hull = 2
0 0
4 0

7) Points on the upper hull = 2
0 0
4 0

I was expecting for the lower hull that ones but for the upper hull (4,4) (2,5) (0,4) that within the lower hull give to me the full convex hull. What is my mistake now?





On 14 January 2014 23:59, Philipp Moeller <> wrote:
Alessandro Attanasi <> writes:

> 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

The first error comes from this call:
`CGAL::lower_hull_points_2( points_vect.begin(), points_vect.end(), result_vect);`

The third argument should be an OutputIterator, but you pass in a
`std::vector`. Use std::back_inserter(result_vect), if this is what you
want. `CGAL::lower_hull_points_2( points_vect.begin(), points_vect.end(), std::back_inserter(result_vect));`

You might also want to clear the vector in between calls.

The variable `ch_points` isn't declared anywhere. I suppose you want
this to be `std::size_t ch_points = result_vect.size();`

A few random things:
- `typedef enum blabla { FOO } blabla_t;` is not necessary in C++.
  `enum blabla_t { FOO };` is enough
- I suppose your compiler comes with C++11. Don't initialize vectors with
  `push_back` if you know the elements in advance. Use an
  initializer_list, for example `std::vector<Point_2> v = {p1, p2, p3}`;


[...snipped huge code block and error message...]



--






Archive powered by MHonArc 2.6.18.

Top of Page