22 #ifndef _nmrMultiIndexCounter_h
23 #define _nmrMultiIndexCounter_h
29 #ifndef DEFINE_FORMATTED_OUTPUT
30 #define DEFINE_FORMATTED_OUTPUT 0
74 enum CounterStatus {COUNTER_UNDERFLOW = -1, COUNTER_IN_BOUNDS = 0, COUNTER_OVERFLOW = 1, COUNTER_UNDEFINED = 2};
84 Increments.assign( GetSize(), increment );
103 register const int s = GetSize();
104 for (i = 0; i < s; i++) {
105 LowBounds[i] = lowBounds[i];
106 HighBounds[i] = highBounds[i];
108 Status = COUNTER_UNDEFINED;
115 LowBounds[counter] = bound;
122 HighBounds[counter] = bound;
132 register const int s = GetSize();
133 for (i = 0; i < s; i++) {
134 Increments[i] = increments[i];
142 Increments[counter] = increment;
159 return reinterpret_cast<const unsigned int *
>(GetIndexCells());
164 return &(LowBounds[0]);
169 return LowBounds[counter];
174 return &(HighBounds[0]);
179 return HighBounds[counter];
184 return &(Increments[0]);
189 return Increments[counter];
197 if ( (value < LowBounds[cell]) || (HighBounds[cell] < value) )
198 Status = COUNTER_UNDEFINED;
206 register const int s = GetSize();
207 Status = COUNTER_UNDEFINED;
208 for (i = 0; i < s; i++) {
209 if ( (Index[i] < LowBounds[i]) || (HighBounds[i] < Index[i]) )
213 Status = COUNTER_IN_BOUNDS;
225 register const int s = GetSize();
226 for (i = 0; i < s; i++) {
227 Index[i] = LowBounds[i];
229 Status = COUNTER_IN_BOUNDS;
238 register const int s = GetSize();
239 for (i = 0; i < s; i++) {
240 Index[i] = HighBounds[i];
242 Status = COUNTER_IN_BOUNDS;
248 register const int s = GetSize();
249 for (i = 0; i < s; i++) {
252 Status = COUNTER_UNDEFINED;
294 return ( (GetStatus() != COUNTER_UNDEFINED) && (GetStatus() != COUNTER_UNDERFLOW) );
300 return ( (GetStatus() != COUNTER_UNDEFINED) && (GetStatus() != COUNTER_OVERFLOW) );
306 return ( GetStatus() == COUNTER_IN_BOUNDS );
310 unsigned long GetNumberOfCombinations()
const;
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
int IndexType
Definition: nmrMultiIndexCounter.h:70
void SetIndex(unsigned int cell, IndexType value)
Definition: nmrMultiIndexCounter.h:194
CounterType Increments
Definition: nmrMultiIndexCounter.h:317
Portability across compilers and operating systems tools.
std::vector< IndexType > CounterType
Definition: nmrMultiIndexCounter.h:313
void SetHighBound(unsigned int counter, IndexType bound)
Definition: nmrMultiIndexCounter.h:120
void UpdateStatus()
Definition: nmrMultiIndexCounter.h:203
CounterStatus
Definition: nmrMultiIndexCounter.h:74
const IndexType * GetLowBounds() const
Definition: nmrMultiIndexCounter.h:162
IndexType GetHighBound(unsigned int counter) const
Definition: nmrMultiIndexCounter.h:177
void SetIncrement(unsigned int counter, IndexType increment)
Definition: nmrMultiIndexCounter.h:140
static const IndexType DefaultIncrement
Definition: nmrMultiIndexCounter.h:72
CounterStatus Status
Definition: nmrMultiIndexCounter.h:319
IndexType operator[](unsigned int i) const
Definition: nmrMultiIndexCounter.h:146
bool IsBelowHighBounds() const
Definition: nmrMultiIndexCounter.h:298
void GoTo(const IndexType where[])
Definition: nmrMultiIndexCounter.h:245
CounterType Index
Definition: nmrMultiIndexCounter.h:314
CounterType HighBounds
Definition: nmrMultiIndexCounter.h:316
IndexType GetIncrement(unsigned int counter) const
Definition: nmrMultiIndexCounter.h:187
CounterType LowBounds
Definition: nmrMultiIndexCounter.h:315
const IndexType * GetIncrements() const
Definition: nmrMultiIndexCounter.h:182
void SetAllIncrements(IndexType increment)
Definition: nmrMultiIndexCounter.h:82
bool IsAboveLowBounds() const
Definition: nmrMultiIndexCounter.h:292
bool IsBetweenBounds() const
Definition: nmrMultiIndexCounter.h:304
const unsigned int * GetIndexCellsAsUnsigned() const
Definition: nmrMultiIndexCounter.h:157
void SetIncrements(const IndexType increments[])
Definition: nmrMultiIndexCounter.h:129
IndexType GetLowBound(unsigned int counter) const
Definition: nmrMultiIndexCounter.h:167
void SetBounds(const IndexType lowBounds[], const IndexType highBounds[])
Definition: nmrMultiIndexCounter.h:100
const IndexType * GetIndexCells() const
Definition: nmrMultiIndexCounter.h:151
Definition: nmrMultiIndexCounter.h:67
unsigned int GetSize() const
Definition: nmrMultiIndexCounter.h:88
CounterStatus GetStatus() const
Definition: nmrMultiIndexCounter.h:286
void GoToLowBounds()
Definition: nmrMultiIndexCounter.h:222
void SetLowBound(unsigned int counter, IndexType bound)
Definition: nmrMultiIndexCounter.h:113
void GoToHighBounds()
Definition: nmrMultiIndexCounter.h:235
const IndexType * GetHighBounds() const
Definition: nmrMultiIndexCounter.h:172