Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] store polygon from convex hull directly

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] store polygon from convex hull directly


Chronological Thread 
  • From: Atul Thakur <>
  • To:
  • Subject: Re: [cgal-discuss] store polygon from convex hull directly
  • Date: Tue, 3 Mar 2009 15:17:33 -0500
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=bc6SMD7KfPfe/y8l7ETfGSycj9oabd1aki0qmpAVYKDDwuP/ZuJfYF68NL+rG1qZLG 4aZxCZJU2cxoxHttXeYu6rXrXCWmbZsaY9P3o/u5VzHINbbm8FWPFgwCK+pZ0zTwZIio 8k239vzsaPe0hveUAgdOqVwfRy5ir1K5lVJHU=

Hi:
You can store the vertices in a list iterator as follows

#include <CGAL/Cartesian.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/ch_graham_andrew.h>
#include <CGAL/convex_hull_2.h>
#include <vector>
typedef CGAL::Cartesian<double> K;
typedef K::Point_2 Point_2;
typedef CGAL::Polygon_2<K> Polygon;


using namespace std;
int main()
{
  CGAL::set_ascii_mode(std::cin);
  CGAL::set_ascii_mode(std::cout);
  vector <Point_2> pset;
    pset.push_back(Point_2(0,0));
    pset.push_back(Point_2(0,1));
    pset.push_back(Point_2(1,1));
    pset.push_back(Point_2(1,0));
    std::list< Point_2 > L;
    std::insert_iterator<std::list< Point_2 >>  out(L, L.begin());
    CGAL::Object ch_obj;
    Polygon pp;
    list<Point_2> ll;
    CGAL::convex_hull_2( pset.begin(), pset.end(), out );
    for(std::list<Point_2>::iterator it = L.begin(); it!=L.end(); it++)
    {
        Point_2 pp = (Point_2)*it;
    }
  return 0;
}

Hope this helps,

-Atul Thakur



On Tue, Mar 3, 2009 at 11:34 AM, <> wrote:
Hello,
how do i store the result of a convex hull polygon like in the  example using
Graham-Andrew's Algorithm as a polygon? I don't want to write the polygon to a
file or print it on the screen like in the example. I would like to work
directly with the created polygon/convex hull to perform a point inside check.
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss





Archive powered by MHonArc 2.6.16.

Top of Page