10 #ifndef LOFAR_PARMDB_GRID_H
11 #define LOFAR_PARMDB_GRID_H
30 typedef std::shared_ptr<GridRep>
ShPtr;
44 GridRep(
const std::vector<Grid>& domains,
bool sort);
52 GridRep(
const std::vector<Box>& domains,
bool sort);
65 void setup(
const std::vector<Box>& domains);
68 void setup(
const std::vector<Grid>& domains);
73 Axis::ShPtr combineAxes(
const std::vector<Grid>& grids,
unsigned int axis,
74 unsigned int n,
unsigned int step)
const;
93 : itsRep(new
GridRep(first, second)) {}
101 Grid(
const std::vector<Grid>& grids,
bool sort =
false);
108 Grid(
const std::vector<Box>& domains,
bool sort =
false)
109 : itsRep(new
GridRep(domains, sort)) {}
130 std::pair<size_t, size_t>
shape()
const {
return std::make_pair(
nx(),
ny()); }
137 return location.second *
nx() + location.first;
147 assert(location.first <
nx() && location.second <
ny());
149 getAxis(1)->center(location.second));
155 assert(location.first <
nx() && location.second <
ny());
157 getAxis(1)->lower(location.second)),
159 getAxis(1)->upper(location.second)));
173 assert(start.first <= end.first && start.second <= end.second);
181 return std::make_pair(
getAxis(0)->
locate(point.first, biasRight),
221 : itsStart(start), itsEnd(end), itsLocation(start) {}
224 bool atEnd()
const {
return itsLocation.second > itsEnd.second; }
229 if (++itsLocation.first > itsEnd.first) {
230 itsLocation.first = itsStart.first;
231 ++itsLocation.second;
Classes representing a regular or irregular axis.
Class representing a 2-dim box.
std::shared_ptr< Axis > ShPtr
Define a shared_ptr for this class.
Definition: Axis.h:32
Class representing a 2-dim box.
Definition: Box.h:36
double lowerX() const
Definition: Box.h:66
double lowerY() const
Definition: Box.h:67
Utility class that simplifies iterating over a 2-D range of cells.
Definition: Grid.h:218
void operator++()
Definition: Grid.h:228
const Grid::Location & operator*() const
STL-like iterator dereference.
Definition: Grid.h:238
const Grid::Location * operator->() const
STL-like iterator pointer.
Definition: Grid.h:241
bool atEnd() const
Test if the iterator is at the end.
Definition: Grid.h:224
CellIterator(const Grid::Location &start, const Grid::Location &end)
Definition: Grid.h:220
void operator++(int)
Definition: Grid.h:234
The letter class for a 2-D grid with regular or irregular axes.
Definition: Grid.h:28
GridRep()
Default constructor uses two default RegularAxis objects.
GridRep(const std::vector< Grid > &domains, bool sort)
Axis::ShPtr & getAxis(size_t n)
Definition: Grid.h:59
std::shared_ptr< GridRep > ShPtr
Definition: Grid.h:30
const Axis::ShPtr & getAxis(size_t n) const
Definition: Grid.h:60
GridRep(Axis::ShPtr first, Axis::ShPtr second)
Create from given axes.
bool isDefault() const
Is it the default grid?
Definition: Grid.h:55
GridRep(const std::vector< Box > &domains, bool sort)
The envelope class for a 2-D grid with regular or irregular axes. -.
Definition: Grid.h:83
Grid()
Default constructor creates empty axes.
Definition: Grid.h:89
std::pair< size_t, size_t > Location
Define Location: A location on a 2-D grid.
Definition: Grid.h:86
size_t size() const
Get the total number of cells.
Definition: Grid.h:133
unsigned int getCellId(const Location &location) const
Get the cell id from an (x,y) location.
Definition: Grid.h:136
const Axis::ShPtr & operator[](size_t n) const
Definition: Grid.h:120
Location locate(const Point &point, bool biasRight=true) const
Definition: Grid.h:180
void toDomains(std::vector< Box > &domains) const
Convert the grid to domain boxes and append them to the vector.
bool checkIntervals(const Grid &that) const
Check if the corresponding intervals in this and that grid are the same.
Box getCell(const Location &location) const
Definition: Grid.h:154
Grid(const std::vector< Grid > &grids, bool sort=false)
Grid subset(const Box &) const
Box getBoundingBox(const Location &start, const Location &end) const
Get the bounding box of part of the grid.
Definition: Grid.h:172
Grid(Axis::ShPtr first, Axis::ShPtr second)
Create a grid using the given axes.
Definition: Grid.h:92
Grid subset(const Box &, Location &index) const
Grid(const std::vector< Box > &domains, bool sort=false)
Definition: Grid.h:108
bool operator<(const Grid &that) const
Definition: Grid.h:201
std::pair< size_t, size_t > shape() const
Get the grid shape (nx,ny).
Definition: Grid.h:130
Point getCellCenter(const Location &location) const
Get the coordinates of the center of the given cell.
Definition: Grid.h:146
size_t ny() const
Definition: Grid.h:126
bool isDefault() const
Is it the default grid?
Definition: Grid.h:115
Box getBoundingBox() const
Get the bounding box of the grid.
Definition: Grid.h:166
Grid subset(const Location &start, const Location &end) const
bool operator>(const Grid &that) const
Definition: Grid.h:206
size_t nx() const
Definition: Grid.h:125
const Axis::ShPtr & getAxis(size_t n) const
Definition: Grid.h:119
Box getCell(unsigned int id) const
Definition: Grid.h:162
Location getCellLocation(unsigned int id) const
Get the (x,y) location from a cell id.
Definition: Grid.h:141
Box unite(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