Subject: CGAL users discussion list
List archive
- From: Efi Fogel <>
- To:
- Subject: Re: [cgal-discuss] Union one (or more) Polygon with holes (or not )
- Date: Tue, 14 Nov 2017 11:31:59 +0200
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
- Ironport-phdr: 9a23:WYInYhVbJY5gQkpnZoPSNVPbwPvV8LGtZVwlr6E/grcLSJyIuqrYZRGCt8tkgFKBZ4jH8fUM07OQ6P+wHzFYqb+681k8M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aSV3DMl9+Ke3xX4LTlM+qzPua+pvJYgwOiiDuT6l1KUCbowSZmM4ZjI8qfqs/yxXOrXZMU+tTzGJsY1mUmkCvtY+L4Jd//nEI6Loa/MlaXPCicg==
Hi Marek,
First, if you don't have holes why define an object of type Polygon_with_holes?
Anyhow, if you insists, you can define a polygon with hole like so:
Polygon_with_holes_2 P;
P.outer_boundary().push_back(Point_2(-3., -3.));
P.outer_boundary().push_back(Point_2(7., -3.));
P.outer_boundary().push_back(Point_2(7., 7.));
P.outer_boundary().push_back(Point_2(-3., 7.));
// the hole for the polygon to apply Q
Polygon_2 hole;
hole.push_back(Point_2(5., 2.));
hole.push_back(Point_2(2., 2.));
hole.push_back(Point_2(2., 5.));
hole.push_back(Point_2(5., 5.));
P.add_hole(hole);
____ _ ____ _
/_____/_) o /__________ __ //
(____ ( ( ( (_/ (_/-(-'_(/
_/
/_____/_) o /__________ __ //
(____ ( ( ( (_/ (_/-(-'_(/
_/
On 13 November 2017 at 18:25, xoru <> wrote:
I'm beginer with cgal. I need add 2 boxes and get one rectangles (created from 4 points).
My objects 2d are polygons with holes or not. I dont know how setting 'empty' holes list.
How I must writing this code correctly?
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Boolean_set_operations_2.h>
#include <list>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2;
typedef std::list<Polygon_with_holes_2> Pwh_list_2;
#include "print_utils.h"
int main ()
{
Polygon_2 outP;
Polygon_2 holesP[1];
outP.push_back (Point_2 (0, 0));
outP.push_back (Point_2 (1, 0));
outP.push_back (Point_2 (1, 1));
outP.push_back (Point_2 (0, 1));
Polygon_with_holes_2 P (outP, holesP, holesP + 1);
Polygon_2 outQ;
Polygon_2 holesQ[1];
outQ.push_back (Point_2 (1, 0));
outQ.push_back (Point_2 (2, 0));
outQ.push_back (Point_2 (2, 1));
outQ.push_back (Point_2 (1, 1));
/* without holes */
Polygon_with_holes_2 Q (outQ, holesQ, holesQ + 1);
std::cout << "Q = "; print_polygon_with_holes (Q);
// How check orientation, simple etc. I dont know the orientation is good
// if(P.is_simple){ std::cout << "P is simple.\n"; }
Polygon_with_holes_2 unionR;
if (CGAL::join (P, Q, unionR))
{
print_polygon_with_holes (unionR);
}
else
{
/* how add P and Q (union P and Q) */
}
return 0;
}
Thanks
Marek
- [cgal-discuss] Union one (or more) Polygon with holes (or not ), xoru, 11/13/2017
- Re: [cgal-discuss] Union one (or more) Polygon with holes (or not ), Efi Fogel, 11/14/2017
Archive powered by MHonArc 2.6.18.