CARMA C++
CoordAxes.h
Go to the documentation of this file.
1 #ifndef SZA_UTIL_COORDAXES_H
2 #define SZA_UTIL_COORDAXES_H
3 
11 #include <vector>
12 
13 #include "carma/szautil/Coord.h"
15 #include "carma/szautil/Range.h"
16 
17 namespace sza {
18  namespace util {
19 
25  class CoordAxes {
26  public:
27 
31  CoordAxes();
32  CoordAxes(unsigned nel0);
33  CoordAxes(unsigned nel0, unsigned nel1);
34  CoordAxes(unsigned nel0, unsigned nel1, unsigned nel2);
35 
39  CoordAxes(CoordAxes* regAxes);
40 
44  void reset();
45 
50  void setAxis(unsigned nAxis, unsigned nEl);
51 
55  virtual ~CoordAxes();
56 
60  unsigned int nAxis();
61 
69  unsigned int nEl(int axis=-1);
70 
79  unsigned int elementOffsetOf(Coord& coord);
80  unsigned int elementOffsetOf(Coord* coord);
81 
90  Coord coordOf(unsigned element);
91 
106  std::vector<Range<unsigned> > getRanges(CoordRange range);
107  std::vector<Range<unsigned> > getRanges(CoordRange* range=0);
108 
113  bool rangeIsValid(CoordRange& range);
114  bool rangeIsValid(CoordRange* range);
115 
119  unsigned nEl(CoordRange& range);
120  unsigned nEl(CoordRange* range);
121 
125  bool operator==(CoordAxes& axes);
126 
130  friend std::ostream& operator<<(std::ostream& os, CoordAxes axes);
131 
136  void fillRange(CoordRange& range);
137 
138 
139  private:
140 
141  // The vector in which we store the number of elements per axis
142 
143  std::vector<unsigned int> nEl_;
144 
148  void privateConstructor();
149 
153  void checkValidityOf(Coord& coord);
154 
155  /*
156  * Find a vector element matching the stop index
157  */
158  std::vector<Range<unsigned> >::iterator
159  findStopIndex(std::vector<Range<unsigned> >& ranges, unsigned index);
160 
164  void computeRanges(std::vector<Range<unsigned> >& ranges, unsigned iAxis,
165  Coord& start, Coord& stop, unsigned offset);
166 
170  void addNewRange(std::vector<Range<unsigned> >& ranges,
171  unsigned startIndex, unsigned stopIndex);
172 
173  }; // End class CoordAxes
174 
175  } // End namespace util
176 } // End namespace sza
177 
178 
179 
180 #endif // End #ifndef SZA_UTIL_COORDAXES_H
unsigned int nAxis()
Return the number of axes in this axis description.
bool operator==(CoordAxes &axes)
An operator for testing equality of two Axes.
Class for managing coordinate axes.
Definition: CoordAxes.h:25
void setAxis(unsigned nAxis, unsigned nEl)
Method for setting the number of elements on an arbitrary axis.
Tagged: Thu Jun 24 17:38:28 UTC 2004.
friend std::ostream & operator<<(std::ostream &os, CoordAxes axes)
An operator for printing this object.
void fillRange(CoordRange &range)
This method fills out any missing dimensions in the range object with the full range for that axis...
void reset()
Reset this object.
virtual ~CoordAxes()
Destructor.
unsigned int nEl(int axis=-1)
Return the number of elements in an axis.
Tagged: Fri Sep 17 15:48:20 PDT 2004.
std::vector< Range< unsigned > > getRanges(CoordRange range)
CoordRange objects can specify a different range of indices in each axis.
bool rangeIsValid(CoordRange &range)
Check if a coordinate range is consistent with this axis specifier.
A class for specifying a coordinate in a multi-dimensional space.
Definition: Coord.h:21
CoordAxes()
Constructors.
Coord coordOf(unsigned element)
An N-dimensional axis description can be thought of as indexing a contiguous one-dimensional array...
unsigned int elementOffsetOf(Coord &coord)
An N-dimensional axis description can be thought of as indexing a contiguous one-dimensional array...
Tagged: Fri Sep 17 15:51:07 PDT 2004.