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:53:32 +0100

Sorry, really stupid error :P. It works as expected!

Just last question about this problem: if I want to use C pointers instead of stl iterators, why this code is wrong? It gives to me zero points on the lower hull (I tried to use the same logic of the example for convex hull computation)

K::Point_2 *ptr2;

  K::Point_2 *result2 = NULL;

  result2 = (K::Point_2*)malloc(totPoints * sizeof(K::Point_2));

  ptr2 = CGAL::lower_hull_points_2( points, points+totPoints, result2 );

  ch_points = (ptr2 - result2);

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

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

  {

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

  }


thanks again



On 15 January 2014 22:39, Philipp Moeller <> wrote:
Alessandro Attanasi <> writes:

> 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

You call lower_hull_points_2 twice.

>
>   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) );
          ^^^^^^^^^^^^^^^^^^^^

This should be upper_hull_points_2.

>
>   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



--






Archive powered by MHonArc 2.6.18.

Top of Page