Subject: CGAL users discussion list
List archive
Re: [cgal-discuss] Re: How to get one boundary and one hole from a self-intersected polygon
Chronological Thread
- From: Jo <>
- To:
- Subject: Re: [cgal-discuss] Re: How to get one boundary and one hole from a self-intersected polygon
- Date: Fri, 14 May 2010 17:45:51 +0200 (CEST)
Ben Supnik's first hint using the "Arr_bfs_scanner" class.
I'm not sure the result. 1 polygon to have 3 holes.
#include <CGAL/Gmpq.h>
#include <CGAL/Lazy_exact_nt.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Boolean_set_operations_2/Gps_default_dcel.h>
#include <CGAL/Gps_segment_traits_2.h>
#include <CGAL/General_polygon_set_2.h>
#include <CGAL/General_polygon_with_holes_2.h>
#include <list>
typedef CGAL::Gmpq
Number_type;
typedef CGAL::Lazy_exact_nt<Number_type>
Lazy_exact_nt;
typedef CGAL::Cartesian<Lazy_exact_nt>
Kernel;
typedef Kernel::Point_2
Point_2;
typedef Kernel::Segment_2
Segment_2;
typedef CGAL::Gps_segment_traits_2<Kernel>
Traits_2;
typedef CGAL::Gps_default_dcel<Traits_2> Dcel;
typedef CGAL::Arrangement_2<Traits_2, Dcel>
Arrangement2;
typedef CGAL::General_polygon_set_2<Traits_2>
Polygon_set_2;
typedef Traits_2::General_polygon_with_holes_2
Polygon_with_holes_2;
typedef std::back_insert_iterator<std::list<Polygon_with_holes_2> >
OutputIterator;
typedef CGAL::Arr_bfs_scanner<Arrangement2, OutputIterator>
Arr_bfs_scanner;
int main()
{
Arrangement2 arr;
std::list<Segment_2> segments;
segments.push_back(Segment_2(Point_2(0,0), Point_2(50,0)));
segments.push_back(Segment_2(Point_2(50,0), Point_2(50,30)));
segments.push_back(Segment_2(Point_2(50,30), Point_2(30,30)));
segments.push_back(Segment_2(Point_2(30,30), Point_2(30,10)));
segments.push_back(Segment_2(Point_2(30,10), Point_2(10,10)));
segments.push_back(Segment_2(Point_2(10,10), Point_2(10,40)));
segments.push_back(Segment_2(Point_2(10,40), Point_2(20,40)));
segments.push_back(Segment_2(Point_2(20,40), Point_2(20,20)));
segments.push_back(Segment_2(Point_2(20,20), Point_2(40,20)));
segments.push_back(Segment_2(Point_2(40,20), Point_2(40,50)));
segments.push_back(Segment_2(Point_2(40,50), Point_2(0,50)));
segments.push_back(Segment_2(Point_2(0,50), Point_2(0,0)));
insert(arr, segments.begin(), segments.end());
Polygon_set_2 s;
std::list<Polygon_with_holes_2> res;
OutputIterator out = std::back_inserter(res);
Traits_2 trait;
Arr_bfs_scanner scanner(&trait, out);
scanner.scan(arr);
std::cout<<std::endl;
std::cout<<"Number of polygon : "<<res.size()<<std::endl;
std::list<Polygon_with_holes_2>::const_iterator it;
int i=1;
for (it=res.begin(); it!=res.end(); ++it, ++i)
std::cout<<"#"<<i<<" Number of holes :
"<<it->number_of_holes()<<std::endl;
return 0;
}
I hope that somebody draw the shapes on a screen to confirm the result.
Thans.
- [cgal-discuss] How to get one boundary and one hole from a self-intersected polygon, Hyungon Kim, 05/06/2010
- Re: [cgal-discuss] How to get one boundary and one hole from a self-intersected polygon, efif, 05/08/2010
- Re: [cgal-discuss] How to get one boundary and one hole from a self-intersected polygon, Ben Supnik, 05/08/2010
- [cgal-discuss] Re: How to get one boundary and one hole from a self-intersected polygon, Hyungon Kim, 05/10/2010
- Re: [cgal-discuss] Re: How to get one boundary and one hole from a self-intersected polygon, Jo, 05/14/2010
- Re: [cgal-discuss] Re: How to get one boundary and one hole from a self-intersected polygon, Ben Supnik, 05/14/2010
- Re: [cgal-discuss] Re: How to get one boundary and one hole from a self-intersected polygon, Jo, 05/14/2010
- [cgal-discuss] Re: How to get one boundary and one hole from a self-intersected polygon, Hyungon Kim, 05/10/2010
- Re: [cgal-discuss] How to get one boundary and one hole from a self-intersected polygon, Ben Supnik, 05/08/2010
- Re: [cgal-discuss] How to get one boundary and one hole from a self-intersected polygon, efif, 05/08/2010
Archive powered by MHonArc 2.6.16.