CGAL 6.1 - 2D Polygon Partitioning

Loading...
Searching...
No Matches
Partition_2/approx_convex_partition_2.cpp
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Partition_traits_2.h>
#include <CGAL/partition_2.h>
#include <cassert>
#include <list>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Partition_traits_2<K> Traits;
typedef Traits::Point_2 Point_2;
typedef Traits::Polygon_2 Polygon_2;
typedef std::list<Polygon_2> Polygon_list;
void make_polygon(Polygon_2& polygon)
{
polygon.push_back(Point_2(391, 374));
polygon.push_back(Point_2(240, 431));
polygon.push_back(Point_2(252, 340));
polygon.push_back(Point_2(374, 320));
polygon.push_back(Point_2(289, 214));
polygon.push_back(Point_2(134, 390));
polygon.push_back(Point_2( 68, 186));
polygon.push_back(Point_2(154, 259));
polygon.push_back(Point_2(161, 107));
polygon.push_back(Point_2(435, 108));
polygon.push_back(Point_2(208, 148));
polygon.push_back(Point_2(295, 160));
polygon.push_back(Point_2(421, 212));
polygon.push_back(Point_2(441, 303));
}
int main()
{
Polygon_2 polygon;
Polygon_list partition_polys;
make_polygon(polygon);
CGAL::approx_convex_partition_2(polygon.vertices_begin(),
polygon.vertices_end(),
std::back_inserter(partition_polys));
assert(CGAL::convex_partition_is_valid_2(polygon.vertices_begin(),
polygon.vertices_end(),
partition_polys.begin(),
partition_polys.end()));
return 0;
}
CGAL::Exact_predicates_inexact_constructions_kernel
CGAL::Partition_traits_2
Traits class that can be used with all the 2-dimensional polygon partitioning algorithms.
Definition: Partition_traits_2.h:26
CGAL::convex_partition_is_valid_2
bool convex_partition_is_valid_2(InputIterator point_first, InputIterator point_beyond, ForwardIterator poly_first, ForwardIterator poly_beyond, const Traits &traits=Default_traits)
determines if the polygons in the range [poly_first, poly_beyond) define a valid convex partition of ...
CGAL::approx_convex_partition_2
OutputIterator approx_convex_partition_2(InputIterator first, InputIterator beyond, OutputIterator result, const Traits &traits=Default_traits)
computes a partition of the polygon defined by the points in the range [first, beyond) into convex po...