My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
CoordAxes.h
Go to the documentation of this file.
1 #ifndef GCP_UTIL_COORDAXES_H
2 #define GCP_UTIL_COORDAXES_H
3 
11 #include <vector>
12 
13 #include "gcp/util/common/Coord.h"
14 #include "gcp/util/common/CoordRange.h"
15 #include "gcp/util/common/Range.h"
16 
17 namespace gcp {
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  void operator=(CoordAxes& axes);
131 
135  friend std::ostream& operator<<(std::ostream& os, CoordAxes axes);
136 
141  void fillRange(CoordRange& range);
142 
143  private:
144 
145  // The vector in which we store the number of elements per axis
146 
147  public:
148  std::vector<unsigned int> nEl_;
149 
150  private:
154  void privateConstructor();
155 
159  void checkValidityOf(Coord& coord);
160 
161  /*
162  * Find a vector element matching the stop index
163  */
164  std::vector<Range<unsigned> >::iterator
165  findStopIndex(std::vector<Range<unsigned> >& ranges, unsigned index);
166 
170  void computeRanges(std::vector<Range<unsigned> >& ranges, unsigned iAxis,
171  Coord& start, Coord& stop, unsigned offset);
172 
176  void addNewRange(std::vector<Range<unsigned> >& ranges,
177  unsigned startIndex, unsigned stopIndex);
178 
179  }; // End class CoordAxes
180 
181  } // End namespace util
182 } // End namespace gcp
183 
184 
185 
186 
187 #endif // End #ifndef GCP_UTIL_COORDAXES_H
Definition: CoordAxes.h:25
virtual ~CoordAxes()
Definition: CoordAxes.cc:121
void operator=(CoordAxes &axes)
Definition: CoordAxes.cc:74
void fillRange(CoordRange &range)
Definition: CoordAxes.cc:466
friend std::ostream & operator<<(std::ostream &os, CoordAxes axes)
bool rangeIsValid(CoordRange &range)
Definition: CoordAxes.cc:351
Definition: Coord.h:21
Definition: CoordRange.h:20
CoordAxes()
Definition: CoordAxes.cc:23
bool operator==(CoordAxes &axes)
Definition: CoordAxes.cc:501
std::vector< Range< unsigned > > getRanges(CoordRange range)
Definition: CoordAxes.cc:219
void reset()
Definition: CoordAxes.cc:84
unsigned int elementOffsetOf(Coord &coord)
Definition: CoordAxes.cc:160
void setAxis(unsigned nAxis, unsigned nEl)
Definition: CoordAxes.cc:92
unsigned int nEl(int axis=-1)
Definition: CoordAxes.cc:136
Coord coordOf(unsigned element)
Definition: CoordAxes.cc:428
Definition: Range.h:18
unsigned int nAxis()
Definition: CoordAxes.cc:128