10 #ifndef LOFAR_PARMDB_AXISMAPPING_H
11 #define LOFAR_PARMDB_AXISMAPPING_H
40 size_t size()
const {
return itsMapping.size(); }
53 const std::vector<int>&
getBorders()
const {
return itsBorders; }
56 std::vector<int> itsMapping;
57 std::vector<double> itsCenters;
58 std::vector<int> itsBorders;
94 std::map<int64_t, std::vector<std::pair<int, int>>> itsGridCache;
95 std::map<int, Axis::ShPtr> itsAxisCache;
106 AxisKey(
unsigned int fromId,
unsigned int toId)
107 : itsFrom(fromId), itsTo(toId) {}
108 unsigned int itsFrom;
111 bool operator==(
const AxisKey that)
const {
112 return itsFrom == that.itsFrom && itsTo == that.itsTo;
114 bool operator!=(
const AxisKey that)
const {
115 return itsFrom != that.itsFrom || itsTo != that.itsTo;
117 bool operator<(
const AxisKey that)
const {
118 return itsFrom < that.itsFrom ||
119 (itsFrom == that.itsFrom && itsTo < that.itsTo);
125 size_t size()
const {
return itsCache.size(); }
133 std::map<AxisKey, AxisMapping>::const_iterator iter =
134 itsCache.find(AxisKey(from.
getId(), to.
getId()));
135 return (iter == itsCache.end() ? makeMapping(from, to) : iter->second);
142 std::map<AxisKey, AxisMapping> itsCache;
154 unsigned int cellId,
const Grid& src,
Class representing a regular or irregular 2-D grid.
This class caches Grid objects.
Definition: AxisMapping.h:77
void clear()
Clear the cache.
Definition: AxisMapping.h:88
Grid getGrid(const std::vector< Box > &domains)
Axis::ShPtr getAxis(const Axis &axis)
This class caches axis mappings. It uses the unique id of the from-axis and to-axis as the key in the...
Definition: AxisMapping.h:102
size_t size() const
Get the number of elements.
Definition: AxisMapping.h:125
void clear()
Clear the cache.
Definition: AxisMapping.h:128
const AxisMapping & get(const Axis &from, const Axis &to)
Definition: AxisMapping.h:132
Map the cells of one axis to another.
Definition: AxisMapping.h:27
size_t size() const
Get the number of elements.
Definition: AxisMapping.h:40
AxisMapping(const Axis &from, const Axis &to)
Create the mapping.
const double * getScaledCenters() const
Definition: AxisMapping.h:48
const std::vector< int > & getBorders() const
Definition: AxisMapping.h:53
std::vector< int >::const_iterator const_iterator
Definition: AxisMapping.h:34
const_iterator begin() const
Definition: AxisMapping.h:35
const_iterator end() const
Definition: AxisMapping.h:36
int operator[](int i) const
Get the to interval for the i-th from interval.
Definition: AxisMapping.h:43
Classes representing a regular or irregular axis.
Definition: Axis.h:29
std::shared_ptr< Axis > ShPtr
Define a shared_ptr for this class.
Definition: Axis.h:32
unsigned int getId() const
Get the unique axis id.
Definition: Axis.h:49
Definition: AxisMapping.h:145
static unsigned int findCellId(AxisMappingCache &cache, const Grid::Location &location, const Grid &src, const Grid &dest)
Find the cellId in grid 'dest', given the location in grid 'src'.
static unsigned int findcellId(AxisMappingCache &cache, unsigned int cellId, const Grid &src, const Grid &dest)
Find the cellId in grid 'dest', given the cellId in grid 'src'.
static Grid::Location findLocation(AxisMappingCache &cache, unsigned int cellId, const Grid &src, const Grid &dest)
Find the location in grid 'dest', given the cellId in grid 'src'.
static Grid::Location findLocation(AxisMappingCache &cache, const Grid::Location &location, const Grid &src, const Grid &dest)
Find the location in grid 'dest', given the location in grid 'src'.
The envelope class for a 2-D grid with regular or irregular axes. -.
Definition: Grid.h:83
std::pair< size_t, size_t > Location
Define Location: A location on a 2-D grid.
Definition: Grid.h:86
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53