#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/partition_2.h>
#include <CGAL/Partition_traits_2.h>
#include <CGAL/property_map.h>
#include <vector>
#include <cassert>
#include <list>
typedef Partition_traits_2::Point_2 Point_2;
typedef Partition_traits_2::Polygon_2 Polygon_2;
typedef std::list<Polygon_2> Polygon_list;
int main( )
{
std::vector<K::Point_2> points = { K::Point_2(0,0), K::Point_2(2,0), K::Point_2(2,2), K::Point_2(1,1), K::Point_2(0,2) };
Partition_traits_2 traits(CGAL::make_property_map(points));
Polygon_2 polygon;
polygon.push_back(0);
polygon.push_back(1);
polygon.push_back(2);
polygon.push_back(3);
polygon.push_back(4);
Polygon_list partition_polys;
polygon.vertices_end(),
std::back_inserter(partition_polys),
traits);
for (const Polygon_2& poly : partition_polys){
for(Point_2 p : poly.container()){
std::cout << "points[" << p << "] = " << points[p] << ", ";
}
std::cout << std::endl;
}
polygon.vertices_end(),
partition_polys.begin(),
partition_polys.end(),
traits));
return 0;
}
Traits class that can be used with all the 2-dimensional polygon partitioning algorithms.
Definition: Partition_traits_2.h:26
OutputIterator y_monotone_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 -monotone...
bool partition_is_valid_2(InputIterator point_first, InputIterator point_beyond, ForwardIterator poly_first, ForwardIterator poly_beyond, const Traits &traits=Default_traits)
returns true iff the polygons in the range [poly_first, poly_beyond) define a valid partition of the ...