generate-shapes/src/util/geo/Box.h

59 lines
1.5 KiB
C
Raw Normal View History

2018-07-10 17:04:59 +02:00
// Copyright 2016, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: Patrick Brosi <brosi@informatik.uni-freiburg.de>
#ifndef UTIL_GEO_BOX_H_
#define UTIL_GEO_BOX_H_
#include "./Point.h"
namespace util {
2018-07-12 14:23:29 +02:00
namespace geo {
2018-07-10 17:04:59 +02:00
template <typename T>
class Box {
public:
// maximum inverse box as default value of box
2018-07-12 14:23:29 +02:00
Box()
: _ll(std::numeric_limits<T>::max(), std::numeric_limits<T>::max()),
_ur(std::numeric_limits<T>::min(), std::numeric_limits<T>::min()) {}
2018-07-10 17:04:59 +02:00
Box(const Point<T>& ll, const Point<T>& ur) : _ll(ll), _ur(ur) {}
const Point<T>& getLowerLeft() const { return _ll; }
const Point<T>& getUpperRight() const { return _ur; }
2018-07-12 14:23:29 +02:00
Point<T>& getLowerLeft() { return _ll; }
Point<T>& getUpperRight() { return _ur; }
2018-07-10 17:04:59 +02:00
void setLowerLeft(const Point<T>& ll) { _ll = ll; }
void setUpperRight(const Point<T>& ur) { _ur = ur; }
bool operator==(const Box<T>& b) const {
return getLowerLeft() == b.getLowerLeft() &&
getUpperRight == b.getUpperRight();
}
bool operator!=(const Box<T>& p) const { return !(*this == p); }
private:
Point<T> _ll, _ur;
};
2018-07-17 19:33:05 +02:00
template <typename T>
class RotatedBox {
public:
RotatedBox() : _box() {}
RotatedBox(const Box<T>& box) : _box(box), _deg(0), _center() {}
2018-07-18 19:26:34 +02:00
RotatedBox(const Point<T>& ll, const Point<T>& ur)
: _box(ll, ur), _deg(0), _center() {}
2018-07-17 19:33:05 +02:00
private:
Box<T> _box;
double _deg;
Point<T> _center;
};
2018-07-12 14:23:29 +02:00
} // namespace geo
2018-07-10 17:04:59 +02:00
} // namespace util
#endif // UTIL_GEO_BOX_H_