10 #ifndef LOFAR_PARMDB_BOX_H
11 #define LOFAR_PARMDB_BOX_H
13 #include <casacore/casa/BasicMath/Math.h>
23 typedef std::pair<double, double>
Point;
39 Box() : itsStart(0, 0), itsEnd(0, 0) {}
43 Box(
const Point& start,
const Point& end) : itsStart(start), itsEnd(end) {
44 assert(start.first <= end.first && start.second <= end.second);
49 Box(
const std::vector<double>&);
52 Box(
double x1,
double x2,
double y1,
double y2,
bool asStartEnd =
false);
57 return itsStart == that.itsStart && itsEnd == that.itsEnd;
66 double lowerX()
const {
return itsStart.first; }
67 double lowerY()
const {
return itsStart.second; }
68 double upperX()
const {
return itsEnd.first; }
69 double upperY()
const {
return itsEnd.second; }
74 double widthX()
const {
return itsEnd.first - itsStart.first; }
75 double widthY()
const {
return itsEnd.second - itsStart.second; }
81 return (other.itsStart.first < itsEnd.first &&
82 !casacore::near(other.itsStart.first, itsEnd.first) &&
83 other.itsEnd.first > itsStart.first &&
84 !casacore::near(other.itsEnd.first, itsStart.first) &&
85 other.itsStart.second < itsEnd.second &&
86 !casacore::near(other.itsStart.second, itsEnd.second) &&
87 other.itsEnd.second > itsStart.second &&
88 !casacore::near(other.itsEnd.second, itsStart.second));
94 return ((other.itsStart.first >= itsStart.first ||
95 casacore::near(other.itsStart.first, itsStart.first)) &&
96 (other.itsEnd.first <= itsEnd.first ||
97 casacore::near(other.itsEnd.first, itsEnd.first)) &&
98 (other.itsStart.second >= itsStart.second ||
99 casacore::near(other.itsStart.second, itsStart.second)) &&
100 (other.itsEnd.second <= itsEnd.second ||
101 casacore::near(other.itsEnd.second, itsEnd.second)));
106 return (casacore::near(itsStart.first, itsEnd.first) ||
107 casacore::near(itsStart.second, itsEnd.second));
126 return itsStart.second < that.itsStart.second ||
127 (itsStart.second == that.itsStart.second &&
128 itsStart.first < that.itsStart.first);
131 return itsStart.second > that.itsStart.second ||
132 (itsStart.second == that.itsStart.second &&
133 itsStart.first > that.itsStart.first);
Class representing a 2-dim box.
Definition: Box.h:36
double upperX() const
Definition: Box.h:68
Box(const Point &start, const Point &end)
Definition: Box.h:43
bool contains(const Box &other) const
Definition: Box.h:93
Box(const std::vector< double > &)
Box operator&(const Box &that) const
Definition: Box.h:114
Box(double x1, double x2, double y1, double y2, bool asStartEnd=false)
Create from start/end or center/width.
double widthX() const
Definition: Box.h:74
double upperY() const
Definition: Box.h:69
Box()
Default constructor creates an empty box.
Definition: Box.h:39
bool intersects(const Box &other) const
Definition: Box.h:80
bool operator==(const Box &that) const
Definition: Box.h:56
const Point & lower() const
Definition: Box.h:64
double lowerX() const
Definition: Box.h:66
const Point & upper() const
Definition: Box.h:65
double widthY() const
Definition: Box.h:75
void print() const
Output the start and end point coordinates of the Box.
bool operator<(const Box &that) const
Definition: Box.h:125
bool operator!=(const Box &that) const
Definition: Box.h:59
bool empty() const
Check if the box is empty.
Definition: Box.h:105
Box operator|(const Box &that) const
Definition: Box.h:120
bool operator>(const Box &that) const
Definition: Box.h:130
double lowerY() const
Definition: Box.h:67
Box unite(const Box &lhs, const Box &rhs)
Box intersect(const Box &lhs, const Box &rhs)
std::pair< double, double > Point
Point: A point in a 2-D space.
Definition: Box.h:23
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53