33#ifdef OGDF_INCLUDE_CGAL
42# include <CGAL/Algebraic_kernel_for_circles_2_2.h>
43# include <CGAL/Boolean_set_operations_2.h>
44# include <CGAL/Circle_2.h>
45# include <CGAL/Circular_kernel_2.h>
46# include <CGAL/General_polygon_set_2.h>
47# include <CGAL/Gps_circle_segment_traits_2.h>
56template<
typename kernel>
57using Circle_t = CGAL::Circle_2<kernel>;
59template<
typename kernel>
60typename CGAL::Circular_kernel_2<kernel, CGAL::Algebraic_kernel_for_circles_2_2<typename kernel::FT>>
::Point_2
61convert(
const typename kernel::Point_2& p) {
62 return {p.x(), p.y()};
65template<
typename kernel>
66typename CGAL::Circular_kernel_2<kernel, CGAL::Algebraic_kernel_for_circles_2_2<typename kernel::FT>>
::Circle_2
71template<
typename kernel>
72typename CGAL::Circular_kernel_2<kernel, CGAL::Algebraic_kernel_for_circles_2_2<typename kernel::FT>>
::Line_2
73convert(
const geometry::Line_t<kernel>& line) {
74 return {line.a(), line.b(), line.c()};
77template<
typename kernel>
78typename CGAL::Circular_kernel_2<kernel, CGAL::Algebraic_kernel_for_circles_2_2<typename kernel::FT>>
::Segment_2
79convert(
const geometry::LineSegment_t<kernel>&
ls) {
83template<
typename kernel>
85 if (
circle.has_on_boundary(
ls.source())) {
87 }
else if (
circle.has_on_unbounded_side(
ls.source()) &&
circle.has_on_bounded_side(
ls.target())) {
89 }
else if (
circle.has_on_unbounded_side(
ls.target()) &&
circle.has_on_bounded_side(
ls.source())) {
96template<
typename kernel>
99 using AKernel = CGAL::Algebraic_kernel_for_circles_2_2<typename kernel::FT>;
100 using CKernel = CGAL::Circular_kernel_2<kernel, AKernel>;
101 using CCircle =
typename CKernel::Circle_2;
102 using CLine =
typename CKernel::Line_2;
107 typename CKernel::Line_arc_2
line_arc(
l);
110 using IS_Result =
typename CGAL::CK2_Intersection_traits<CKernel, CCircle, CLine>::type;
112 std::vector<IS_Result>
is;
113 CGAL::intersection(c,
line_arc, std::back_inserter(
is));
115 using R = std::pair<CGAL::Circular_arc_point_2<CKernel>,
unsigned int>;
118 auto is_1 = boost::get<R>(&
is[0]);
122 auto is_2 = boost::get<R>(&
is[1]);
127template<
typename kernel>
130 using AKernel = CGAL::Algebraic_kernel_for_circles_2_2<typename kernel::FT>;
131 using CKernel = CGAL::Circular_kernel_2<kernel, AKernel>;
132 using CCircle =
typename CKernel::Circle_2;
138 using IS_Result =
typename CGAL::CK2_Intersection_traits<CKernel, CCircle, CCircle>::type;
139 using R = std::pair<CGAL::Circular_arc_point_2<CKernel>,
unsigned int>;
141 std::vector<IS_Result>
is;
142 CGAL::intersection(
cc1,
cc2, std::back_inserter(
is));
145 auto is_1 = boost::get<R>(&
is[0]);
152 auto is_2 = boost::get<R>(&
is[1]);
159template<
typename kernel>
161 return c.has_on_boundary(p) || c.has_on_bounded_side(p);
164template<
typename kernel>
174 if (CGAL::do_intersect(
c_1,
c_2)) {
196 virtual void intersect(
const LineSegment&, std::function<
void(
const Point)>&&)
const = 0;
198 std::function<
void(
const Point)>&&)
const = 0;
201 virtual bool contains(
const Circle&
other,
const Point& p)
const = 0;
204 os << c.circle_1 <<
" " << c.circle_2;
209template<
typename kernel>
221 if (geometry::do_intersect(c,
ls)) {
235 bool contains(
const Circle&
other,
const Point& p)
const {
236 return geometry::contains(
other, p);
244 void intersect(
const CircleOperation&
op, std::function<
void(
const Point)>&&
f)
const {
245 parent::intersect_pair(parent::circle_1,
op.circle_1, [&](
const Point& p) {
246 if (contains(parent::circle_2, p) && op.contains(op.circle_2, p)) {
251 parent::intersect_pair(parent::circle_1,
op.circle_2, [&](
const Point& p) {
252 if (contains(parent::circle_2, p) && op.contains(op.circle_1, p)) {
257 parent::intersect_pair(parent::circle_2,
op.circle_1, [&](
const Point& p) {
258 if (contains(parent::circle_1, p) && op.contains(op.circle_2, p)) {
263 parent::intersect_pair(parent::circle_2,
op.circle_2, [&](
const Point& p) {
264 if (contains(parent::circle_1, p) && op.contains(op.circle_1, p)) {
269 parent::intersect_pair(parent::circle_1, parent::circle_2, [&](
const Point& p) {
270 if (
op.contains(p)) {
275 parent::intersect_pair(
op.circle_1,
op.circle_2, [&](
const Point& p) {
281 if (
op.contains(parent::circle_1.center()) && contains(parent::circle_1.center())) {
282 f(parent::circle_1.center());
284 if (
op.contains(
op.circle_1.center()) && contains(
op.circle_1.center())) {
285 f(
op.circle_1.center());
289 void intersect(
const LineSegment&
ls, std::function<
void(
const Point)>&&
f)
const {
295 return geometry::do_intersect(parent::circle_1,
ls)
296 && geometry::do_intersect(parent::circle_2,
ls);
299 bool contains(
const Point& p)
const {
300 return geometry::contains(parent::circle_1, p) && geometry::contains(parent::circle_2, p);
304template<
typename kernel>
316 if (geometry::do_intersect(c,
ls)) {
331 void intersect(
const LineSegment&
ls, std::function<
void(
const Point)>&&
f)
const {
337 void intersect(
const CircleOperation&
op, std::function<
void(
const Point)>&&
f)
const {
338 parent::intersect_pair(parent::circle_1,
op.circle_1,
f);
339 parent::intersect_pair(parent::circle_1,
op.circle_2,
f);
340 parent::intersect_pair(parent::circle_2,
op.circle_1,
f);
341 parent::intersect_pair(parent::circle_2,
op.circle_2,
f);
343 parent::intersect_pair(parent::circle_1, parent::circle_2, [&](
const Point& p) {
344 if (
op.contains(p)) {
348 parent::intersect_pair(
op.circle_1,
op.circle_2, [&](
const Point& p) {
354 if (
op.contains(parent::circle_1.center())) {
355 f(parent::circle_1.center());
358 if (
op.contains(parent::circle_2.center())) {
359 f(parent::circle_1.center());
362 if (contains(
op.circle_1.center())) {
363 f(
op.circle_1.center());
366 if (contains(
op.circle_2.center())) {
367 f(
op.circle_2.center());
372 return geometry::do_intersect(parent::circle_1,
ls)
373 || geometry::do_intersect(parent::circle_2,
ls);
376 bool contains(
const Circle&,
const Point&)
const {
return true; }
378 bool contains(
const Point& p)
const {
379 return geometry::contains(parent::circle_1, p) || geometry::contains(parent::circle_2, p);
383template<
typename Kernel>
386 using Traits_2 = CGAL::Gps_circle_segment_traits_2<Kernel>;
387 using Polygon_2 =
typename Traits_2::General_polygon_2;
388 using Curve_2 =
typename Traits_2::Curve_2;
394 std::list<CGAL::Object>
objects;
400 std::list<CGAL::Object>::iterator
iter;
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.