Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
Cone.h
Go to the documentation of this file.
1
31#pragma once
32
33#ifdef OGDF_INCLUDE_CGAL
34
37
38namespace ogdf {
39namespace internal {
40namespace gcm {
41namespace geometry {
42
43/*
44 * A cone through the origin defined by two vectors. Everything that is counter clockwise in between the left and right
45 * is within the cone. left and right are not supposed to be parallel
46 * A cone is not necessarly acute / convex
47 */
48template<typename Kernel>
49class Cone_t {
50private:
53 Direction m_left;
54 Direction m_right;
55
56public:
57 Cone_t(const Vector& left, const Vector& right) : Cone_t(left.direction, right.direction()) {
58 // nothing to do
59 }
60
61 Cone_t(const Direction& left, const Direction& right) : m_left(left), m_right(right) {
62 OGDF_ASSERT(left != right);
63 // nothing to do
64 }
65
66 const Direction& left() const { return m_left; }
67
68 const Direction& right() const { return m_right; }
69};
70
71/*
72 * is c_1 subset of c_2
73 */
74template<typename Kernel>
75bool is_subset(const Cone_t<Kernel>& c_1, const Cone_t<Kernel>& c_2) {
76 return c_1.left().counterclockwise_in_between(c_2.left(), c_2.right())
77 && c_1.right().counterclockwise_in_between(c_2.left(), c_2.right());
78}
79
80template<typename Kernel>
81bool is_in(const Direction_t<Kernel>& d, const Cone_t<Kernel>& c) {
82 return d.counterclockwise_in_between(c.left(), c.right());
83}
84
85template<typename Kernel>
87 return is_in(c_1.left(), c_2) || is_in(c_1.right(), c_2) || is_in(c_2.left(), c_1)
88 || is_in(c_2.right(), c_1);
89}
90
91template<typename kernel>
92std::ostream& operator<<(std::ostream& os, const Cone_t<kernel>& c) {
93 os << "cone[(" << c.left().vector() << ", " << c.right().vector() << ")]";
94 return os;
95}
96
97}
98}
99}
100}
101
102#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.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition Array.h:978
Direction
Definition basic.h:134