29#ifndef CPPSRC_CORE_INCLUDE_COVERAGECONTROL_CGAL_UTILITIES_H_
30#define CPPSRC_CORE_INCLUDE_COVERAGECONTROL_CGAL_UTILITIES_H_
32#include <CGAL/Boolean_set_operations_2.h>
33#include <CGAL/Polygon_2_algorithms.h>
44inline Point2 CGALtoCC(CGAL_Point2
const pt) {
45 return Point2(CGAL::to_double(pt.x()), CGAL::to_double(pt.y()));
48 std::vector<Ray_2> rays_;
49 std::vector<Line_2> lines_;
50 std::vector<Segment_2> segments_;
52 void operator<<(
const Ray_2 &ray) { rays_.push_back(ray); }
53 void operator<<(
const Line_2 &line) { lines_.push_back(line); }
54 void operator<<(
const Segment_2 &seg) { segments_.push_back(seg); }
57template <
class Arrangement>
58inline void CGAL_CCBTraversal(
59 typename Arrangement::Ccb_halfedge_const_circulator circ,
62 typename Arrangement::Ccb_halfedge_const_circulator curr = circ;
63 typename Arrangement::Halfedge_const_handle he;
64 auto pt = curr->source()->point();
67 pt = he->target()->point();
68 polygon.push_back(pt);
70 }
while (curr != circ);
73template <
class Arrangement>
74inline void CGAL_GeneratePolygons(
const Arrangement &arr,
75 std::list<Polygon_2> &polygon_list) {
77 typename Arrangement::Face_const_iterator fit;
78 for (fit = arr.faces_begin(); fit != arr.faces_end(); ++fit) {
79 if (fit->is_unbounded()) {
83 CGAL_CCBTraversal<Arrangement>(fit->outer_ccb(), polygon);
84 if (not polygon.is_counterclockwise_oriented()) {
85 polygon.reverse_orientation();
87 polygon_list.push_back(polygon);
92inline bool IsPointInPoly(CGAL_Point2
const &pt, Polygon_2
const &poly) {
93 if (CGAL::bounded_side_2(poly.begin(), poly.end(), pt, K()) ==
94 CGAL::ON_UNBOUNDED_SIDE) {
100inline void PrunePolygons(std::list<Polygon_2> &polygon_list,
101 int const &map_size) {
103 bbox_poly.push_back(CGAL_Point2(0, 0));
104 bbox_poly.push_back(CGAL_Point2(map_size, 0));
105 bbox_poly.push_back(CGAL_Point2(map_size, map_size));
106 bbox_poly.push_back(CGAL_Point2(0, map_size));
107 for (
auto it = polygon_list.begin(); it != polygon_list.end();) {
108 if (not CGAL::do_intersect(bbox_poly, *it)) {
109 it = polygon_list.erase(it);
Contains the configuration for the CGAL library.
Namespace for the CoverageControl library.
Contains typedefs for the library.