Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
Rectangle.h
Go to the documentation of this file.
1
31#pragma once
32
33#ifdef OGDF_INCLUDE_CGAL
34
41
42# include <vector>
43
44# include <CGAL/Bbox_2.h>
45# include <CGAL/Iso_rectangle_2.h>
46
47namespace ogdf {
48namespace internal {
49namespace gcm {
50namespace geometry {
51
52template<typename kernel>
53using Rectangle_t = CGAL::Iso_rectangle_2<kernel>;
54
55class Bbox : public CGAL::Bbox_2 {
56private:
57 using Bbox_ = CGAL::Bbox_2;
58
59public:
60 using Bbox_::Bbox_;
61
62 Bbox() {
63 // nothing to do
64 }
65
66 Bbox(const Bbox_& b) : Bbox_(b) {
67 //nothing to do;
68 }
69
70 inline double width() const { return Bbox::xmax() - Bbox::xmin(); }
71
72 inline double height() const { return Bbox::ymax() - Bbox::ymin(); }
73
74 inline double area() const { return width() * height(); }
75
76 template<typename Kernel>
77 inline Point_t<Kernel> center() const {
78 return {xmin() + width() / 2, ymin() + height() / 2};
79 }
80};
81
82inline Bbox equalize(const Bbox& bb) {
83 double max = std::max(bb.width(), bb.height());
84 return {bb.xmin(), bb.ymin(), bb.xmin() + max, bb.ymin() + max};
85}
86
87template<typename kernel>
88inline Rectangle_t<kernel> scale_up(const Rectangle_t<kernel>& rect, const typename kernel::FT v) {
89 const typename kernel::FT s = std::min(rect.xmax() - rect.xmin(), rect.ymax() - rect.ymin()) * v;
90 const Vector_t<kernel> t(s, s);
91 return {rect.min() - t, rect.max() + t};
92}
93} // namespace
94}
95}
96}
97
98#endif
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.