Subject: CGAL users discussion list
List archive
- From: Yang Qu <>
- To:
- Subject: [cgal-discuss] compute difference of a polygon and a polygon with holes
- Date: Mon, 20 Apr 2009 14:21:16 +1000
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; b=uFGwhU9Rahuyo/A7w5GY9yNeE4dSgH81c0UfdkUfNCsWZnN42um28EVYhdAXhgGLyr ib7DqHF0PwzqRR6il8BgVvfvvZkTE/jEGa1e0imN0XhPqBRWpUWQkVJBxvYTTBeaW4m0 OVPLnKeIBgHkRqNSUkwDV9p2wy0T+3mVDLIrM=
Hi,
I use the attached code to compute difference of a polygon and a polygon with holes,
I got the code compiled, but when I run it, it gives me the error: the polygon has a wrong orientation
Anyone know why this happened?
Regards,
Yang
#include "CGALTypedefs.hpp"
#include <vector>
#include <CGAL/Boolean_set_operations_2.h>
using namespace std;
int main(int argc, char *argv[]) {
vector<Point_2> outer_boundary;
outer_boundary.push_back(Point_2(0, 0));
outer_boundary.push_back(Point_2(4, 0));
outer_boundary.push_back(Point_2(4, 4));
outer_boundary.push_back(Point_2(0, 4));
vector<Point_2> holePoints;
holePoints.push_back(Point_2(1, 1));
holePoints.push_back(Point_2(2, 1));
holePoints.push_back(Point_2(2, 2));
holePoints.push_back(Point_2(1, 2));
vector<Point_2> smallPoints;
smallPoints.push_back(Point_2(3, 3));
smallPoints.push_back(Point_2(3.5, 3));
smallPoints.push_back(Point_2(3.5, 3.5));
smallPoints.push_back(Point_2(3, 3.5));
Polygon_2 small(smallPoints.begin(), smallPoints.end());
vector<Polygon_2> holes;
Polygon_2 aHole(holePoints.begin(), holePoints.end());
holes.push_back(aHole);
Polygon_2 big(outer_boundary.begin(), outer_boundary.end());
Polygon_with_holes_2 bigWithHole(big, holes.begin(), holes.end());
Pwh_list_2 result;//typedef std::list<Polygon_with_holes_2> Pwh_list_2;
CGAL::difference(small, bigWithHole, back_inserter(result));
return 0;
}
#ifndef CGALINIT_H
#define CGALINIT_H
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Triangulation_vertex_base_with_id_2.h>
#include <CGAL/Point_set_2.h>
#include <CGAL/basic.h>
#include <vector>
#include <list>
//struct Kernel : CGAL::Exact_predicates_inexact_constructions_kernel {};
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
//typedef CGAL::Delaunay_triangulation_2<Kernel> Delaunay;
typedef CGAL::Point_set_2<Kernel> Point_set_2;
typedef CGAL::Vector_2<Kernel> Vector_2;
typedef Point_set_2::Vertex_handle Vertex_handle;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Segment_2 Segment_2;
typedef CGAL::Polygon_2<Kernel, std::vector<Point_2> > Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel, std::vector<Point_2> >
Polygon_with_holes_2;
typedef std::list<Polygon_with_holes_2> Pwh_list_2;
#endif
- [cgal-discuss] compute difference of a polygon and a polygon with holes, Yang Qu, 04/20/2009
- Re: [cgal-discuss] compute difference of a polygon and a polygon, guyzucke, 04/20/2009
Archive powered by MHonArc 2.6.16.