Isis 3.0 Programmer Reference
Back | Home
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 
73  BufferManager::BufferManager(const BufferManager &other) :
74  Buffer(other),
75  p_maxSamps(other.p_maxSamps), p_maxLines(other.p_maxLines),
76  p_maxBands(other.p_maxBands), p_sinc(other.p_sinc), p_linc(other.p_linc),
77  p_binc(other.p_binc), p_soff(other.p_soff), p_loff(other.p_loff),
78  p_boff(other.p_boff), p_currentSample(other.p_currentSample),
79  p_currentLine(other.p_currentLine), p_currentBand(other.p_currentBand),
80  p_nmaps(other.p_nmaps), p_currentMap(other.p_currentMap),
81  p_reverse(other.p_reverse) {
82  }
83 
84 
85  void BufferManager::swap(BufferManager &other) {
86  std::swap(p_maxSamps, other.p_maxSamps);
87  std::swap(p_maxLines, other.p_maxLines);
88  std::swap(p_maxBands, other.p_maxBands);
89  std::swap(p_sinc, other.p_sinc);
90  std::swap(p_linc, other.p_linc);
91  std::swap(p_binc, other.p_binc);
92  std::swap(p_soff, other.p_soff);
93  std::swap(p_loff, other.p_loff);
94  std::swap(p_boff, other.p_boff);
95  std::swap(p_currentSample, other.p_currentSample);
96  std::swap(p_currentLine, other.p_currentLine);
97  std::swap(p_currentBand, other.p_currentBand);
98  std::swap(p_nmaps, other.p_nmaps);
99  std::swap(p_currentMap, other.p_currentMap);
100  std::swap(p_reverse, other.p_reverse);
101  }
102 
103 
104  BufferManager &BufferManager::operator=(const BufferManager &rhs) {
105  BufferManager copy(rhs);
106  swap(copy);
107  return *this;
108  }
109 
110 
137  void BufferManager::SetIncrements(const int sinc, const int linc,
138  const int binc) {
139  p_sinc = sinc;
140  p_linc = linc;
141  p_binc = binc;
142 
143  p_soff = 0;
144  p_loff = 0;
145  p_boff = 0;
146 
148  p_currentMap = 0;
149 
150  p_nmaps = ((BigInt)((p_maxSamps - 1) / p_sinc + 1) *
151  (BigInt)((p_maxLines - 1) / p_linc + 1) *
152  (BigInt)((p_maxBands - 1) / p_binc + 1));
153  }
154 
155 
176  void BufferManager::SetOffsets(const int soff, const int loff,
177  const int boff) {
178  p_soff = soff;
179  p_loff = loff;
180  p_boff = boff;
181  }
182 
183 
216  bool BufferManager::setpos(BigInt map) {
217  if(map >= 0) {
218  p_currentMap = map;
219 
220  if(!p_reverse) {
221  int sampDimension = (p_maxSamps / p_sinc);
222  if (p_maxSamps % p_sinc)
223  sampDimension++;
224 
225  p_currentSample = (map % sampDimension) * p_sinc + 1;
226  map /= sampDimension;
227 
228  int lineDimension = (p_maxLines / p_linc);
229  if (p_maxLines % p_linc)
230  lineDimension++;
231 
232  p_currentLine = (map % lineDimension) * p_linc + 1;
233  map /= lineDimension;
234 
235  p_currentBand = map * p_binc + 1;
236  }
237  else {
238  int bandDimension = (p_maxBands / p_binc);
239  if (p_maxBands % p_binc)
240  bandDimension++;
241 
242  p_currentBand = (map % bandDimension) * p_binc + 1;
243  map /= bandDimension;
244 
245  int lineDimension = (p_maxLines / p_linc);
246  if (p_maxLines % p_linc)
247  lineDimension++;
248 
249  p_currentLine = (map % lineDimension) * p_linc + 1;
250  map /= lineDimension;
251 
252  p_currentSample = map * p_sinc + 1;
253  }
254 
258  }
259  else {
260  string message = "Invalid value for argument [map]";
262  }
263 
264  return !end();
265  }
266 } // end namespace isis
Buffer for reading and writing cube data.
Definition: Buffer.h:68
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.
bool end() const
Returns true if the shape buffer has accessed the end of the cube.
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
int p_binc
Band increment.
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:154
int p_maxSamps
Maximum samples to map.
int p_soff
Sample offset.
PixelType
Enumerations for Isis Pixel Types.
Definition: PixelType.h:43
int p_currentSample
Current sample.
Manages a Buffer over a cube.
Definition: BufferManager.h:67
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:38
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:99
void SetIncrements(const int sinc, const int linc, const int binc)
Sets how the shape is incremented through the cube.
int p_maxBands
Maximum bands to map.
int p_currentLine
Current line.
BigInt p_nmaps
Total number of objects to map.

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:14:57