Loading [MathJax]/extensions/tex2jax.js

Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Line.h
Go to the documentation of this file.
1
31#pragma once
32
33#ifdef OGDF_INCLUDE_CGAL
34
37
38# include <CGAL/Line_2.h>
39# include <math.h>
40
41namespace ogdf {
42namespace internal {
43namespace gcm {
44namespace geometry {
45using namespace tools;
46template<typename kernel>
47using Line_t = CGAL::Line_2<kernel>;
48
49template<typename kernel>
50inline bool turn(const Line_t<kernel>& l1, const Line_t<kernel>& l2) {
51 return turn(l1.to_vector(), l2.to_vector());
52}
53
54template<typename kernel>
55inline bool left_turn(const Line_t<kernel>& l1, const Line_t<kernel>& l2) {
56 return left_turn(l1.to_vector(), l2.to_vector());
57}
58
59template<typename kernel>
60inline bool right_turn(const Line_t<kernel>& l1, const Line_t<kernel>& l2) {
61 return right_turn(l1.to_vector(), l2.to_vector());
62}
63
64template<typename kernel>
65inline bool turn(const Line_t<kernel>& l, const Point_t<kernel>& p) {
66 return turn(l.to_vector(), p - l.point(0));
67}
68
69template<typename kernel>
70inline bool left_turn(const Line_t<kernel>& l, const Point_t<kernel>& p) {
71 return left_turn(l.to_vector(), p - l.point(0));
72}
73
74template<typename kernel>
75inline bool right_turn(const Line_t<kernel>& l, const Point_t<kernel>& p) {
76 return right_turn(l.to_vector(), p - l.point(0));
77}
78
79template<typename kernel>
80inline Point_t<kernel> intersect(const Line_t<kernel>& l1, const Line_t<kernel>& l2) {
81 OGDF_ASSERT(!l1.is_degenerate());
82 OGDF_ASSERT(!l2.is_degenerate());
83 auto result = CGAL::intersection(l1, l2);
84 if (!result) {
85 return Point_t<kernel>(std::numeric_limits<unsigned int>::max(),
86 std::numeric_limits<unsigned int>::max());
87 }
88
89 Point_t<kernel> intersection;
90 if (boost::get<Line_t<kernel>>(&*result)) {
91 auto s = boost::get<Line_t<kernel>>(&*result);
92 intersection = s->point(0);
93 } else {
94 intersection = *boost::get<Point_t<kernel>>(&*result);
95 }
96 return intersection;
97}
98
99} /* namespace geometry */
100}
101}
102}
103
104#endif
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:41
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.