Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 
47 namespace ogdf {
48 namespace internal {
49 namespace gcm {
50 namespace geometry {
51 
52 template<typename kernel>
53 using Rectangle_t = CGAL::Iso_rectangle_2<kernel>;
54 
55 class Bbox : public CGAL::Bbox_2 {
56 private:
57  using Bbox_ = CGAL::Bbox_2;
58 
59 public:
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 
82 inline 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 
87 template<typename kernel>
88 inline 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
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
math.h
Point.h
Vector.h
Ray.h
LineSegment.h
Line.h