Isis 3 Programmer Reference
BufferManager.cpp
Go to the documentation of this file.
1 
23 #include "IsisDebug.h"
24 #include "BufferManager.h"
25 
26 #include <iostream>
27 #include <string>
28 
29 #include "IException.h"
30 
31 using namespace std;
32 
33 namespace Isis {
34  BufferManager::BufferManager() {
35  }
36 
37 
61  BufferManager::BufferManager(int maxsamps, int maxlines,
62  int maxbands, int bufsamps,
63  int buflines, int bufbands,
64  Isis::PixelType type, bool reverse) :
65  Isis::Buffer(bufsamps, buflines, bufbands, type),
66  p_maxSamps(maxsamps), p_maxLines(maxlines),
67  p_maxBands(maxbands) {
68  SetIncrements(bufsamps, buflines, bufbands);
69  p_reverse = reverse;
70  }
71 
72 
79  BufferManager::BufferManager(const BufferManager &other) :
80  Buffer(other),
81  p_maxSamps(other.p_maxSamps), p_maxLines(other.p_maxLines),
82  p_maxBands(other.p_maxBands), p_sinc(other.p_sinc), p_linc(other.p_linc),
83  p_binc(other.p_binc), p_soff(other.p_soff), p_loff(other.p_loff),
84  p_boff(other.p_boff), p_currentSample(other.p_currentSample),
85  p_currentLine(other.p_currentLine), p_currentBand(other.p_currentBand),
86  p_nmaps(other.p_nmaps), p_currentMap(other.p_currentMap),
87  p_reverse(other.p_reverse) {
88  }
89 
90 
98  std::swap(p_maxSamps, other.p_maxSamps);
99  std::swap(p_maxLines, other.p_maxLines);
100  std::swap(p_maxBands, other.p_maxBands);
101  std::swap(p_sinc, other.p_sinc);
102  std::swap(p_linc, other.p_linc);
103  std::swap(p_binc, other.p_binc);
104  std::swap(p_soff, other.p_soff);
105  std::swap(p_loff, other.p_loff);
106  std::swap(p_boff, other.p_boff);
107  std::swap(p_currentSample, other.p_currentSample);
108  std::swap(p_currentLine, other.p_currentLine);
109  std::swap(p_currentBand, other.p_currentBand);
110  std::swap(p_nmaps, other.p_nmaps);
111  std::swap(p_currentMap, other.p_currentMap);
112  std::swap(p_reverse, other.p_reverse);
113  }
114 
115 
124  BufferManager copy(rhs);
125  swap(copy);
126  return *this;
127  }
128 
129 
156  void BufferManager::SetIncrements(const int sinc, const int linc,
157  const int binc) {
158  p_sinc = sinc;
159  p_linc = linc;
160  p_binc = binc;
161 
162  p_soff = 0;
163  p_loff = 0;
164  p_boff = 0;
165 
167  p_currentMap = 0;
168 
169  p_nmaps = ((BigInt)((p_maxSamps - 1) / p_sinc + 1) *
170  (BigInt)((p_maxLines - 1) / p_linc + 1) *
171  (BigInt)((p_maxBands - 1) / p_binc + 1));
172  }
173 
174 
195  void BufferManager::SetOffsets(const int soff, const int loff,
196  const int boff) {
197  p_soff = soff;
198  p_loff = loff;
199  p_boff = boff;
200  }
201 
202 
236  if(map >= 0) {
237  p_currentMap = map;
238 
239  if(!p_reverse) {
240  int sampDimension = (p_maxSamps / p_sinc);
241  if (p_maxSamps % p_sinc)
242  sampDimension++;
243 
244  p_currentSample = (map % sampDimension) * p_sinc + 1;
245  map /= sampDimension;
246 
247  int lineDimension = (p_maxLines / p_linc);
248  if (p_maxLines % p_linc)
249  lineDimension++;
250 
251  p_currentLine = (map % lineDimension) * p_linc + 1;
252  map /= lineDimension;
253 
254  p_currentBand = map * p_binc + 1;
255  }
256  else {
257  int bandDimension = (p_maxBands / p_binc);
258  if (p_maxBands % p_binc)
259  bandDimension++;
260 
261  p_currentBand = (map % bandDimension) * p_binc + 1;
262  map /= bandDimension;
263 
264  int lineDimension = (p_maxLines / p_linc);
265  if (p_maxLines % p_linc)
266  lineDimension++;
267 
268  p_currentLine = (map % lineDimension) * p_linc + 1;
269  map /= lineDimension;
270 
271  p_currentSample = map * p_sinc + 1;
272  }
273 
277  }
278  else {
279  string message = "Invalid value for argument [map]";
281  }
282 
283  return !end();
284  }
285 } // end namespace isis
Buffer for reading and writing cube data.
Definition: Buffer.h:69
long long int BigInt
Big int.
Definition: Constants.h:65
void SetOffsets(const int soff, const int loff, const int boff)
Sets the offset of the buffer.
bool p_reverse
If true the axies are processed in Band, Line, Sample order (e.g., BIL).
int p_loff
Line offset.
int p_sinc
Sample increment.
int p_maxLines
Maximum lines to map.
int p_boff
Band offset.
void SetBasePosition(const int start_sample, const int start_line, const int start_band)
This method is used to set the base position of the shape buffer.
Definition: Buffer.cpp:122
Namespace for the standard library.
int p_binc
Band increment.
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
int p_maxSamps
Maximum samples to map.
int p_soff
Sample offset.
PixelType
Enumerations for Isis Pixel Types.
Definition: PixelType.h:43
void swap(BufferManager &other)
Swaps the values of this BufferManager with that of another.
int p_currentSample
Current sample.
Manages a Buffer over a cube.
Definition: BufferManager.h:68
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
bool end() const
Returns true if the shape buffer has accessed the end of the cube.
BufferManager & operator=(const BufferManager &rhs)
Creates a new BufferManager with the same values as another.
bool setpos(BigInt map)
Sets the position of the shape in the cube.
int p_linc
Line increment.
BigInt p_currentMap
Current buffer map position.
int p_currentBand
Current band.
Isis exception class.
Definition: IException.h:107
void SetIncrements(const int sinc, const int linc, const int binc)
Sets how the shape is incremented through the cube.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
int p_maxBands
Maximum bands to map.
int p_currentLine
Current line.
BigInt p_nmaps
Total number of objects to map.