File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
BufferManager.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "IsisDebug.h"
8 #include "BufferManager.h"
9 
10 #include <iostream>
11 #include <string>
12 
13 #include "IException.h"
14 
15 using namespace std;
16 
17 namespace Isis {
18  BufferManager::BufferManager() {
19  }
20 
21 
45  BufferManager::BufferManager(int maxsamps, int maxlines,
46  int maxbands, int bufsamps,
47  int buflines, int bufbands,
48  Isis::PixelType type, bool reverse) :
49  Isis::Buffer(bufsamps, buflines, bufbands, type),
50  p_maxSamps(maxsamps), p_maxLines(maxlines),
51  p_maxBands(maxbands) {
52  SetIncrements(bufsamps, buflines, bufbands);
53  p_reverse = reverse;
54  }
55 
56 
63  BufferManager::BufferManager(const BufferManager &other) :
64  Buffer(other),
65  p_maxSamps(other.p_maxSamps), p_maxLines(other.p_maxLines),
66  p_maxBands(other.p_maxBands), p_sinc(other.p_sinc), p_linc(other.p_linc),
67  p_binc(other.p_binc), p_soff(other.p_soff), p_loff(other.p_loff),
68  p_boff(other.p_boff), p_currentSample(other.p_currentSample),
69  p_currentLine(other.p_currentLine), p_currentBand(other.p_currentBand),
70  p_nmaps(other.p_nmaps), p_currentMap(other.p_currentMap),
71  p_reverse(other.p_reverse) {
72  }
73 
74 
82  std::swap(p_maxSamps, other.p_maxSamps);
83  std::swap(p_maxLines, other.p_maxLines);
84  std::swap(p_maxBands, other.p_maxBands);
85  std::swap(p_sinc, other.p_sinc);
86  std::swap(p_linc, other.p_linc);
87  std::swap(p_binc, other.p_binc);
88  std::swap(p_soff, other.p_soff);
89  std::swap(p_loff, other.p_loff);
90  std::swap(p_boff, other.p_boff);
91  std::swap(p_currentSample, other.p_currentSample);
92  std::swap(p_currentLine, other.p_currentLine);
93  std::swap(p_currentBand, other.p_currentBand);
94  std::swap(p_nmaps, other.p_nmaps);
95  std::swap(p_currentMap, other.p_currentMap);
96  std::swap(p_reverse, other.p_reverse);
97  }
98 
99 
108  BufferManager copy(rhs);
109  swap(copy);
110  return *this;
111  }
112 
113 
140  void BufferManager::SetIncrements(const int sinc, const int linc,
141  const int binc) {
142  p_sinc = sinc;
143  p_linc = linc;
144  p_binc = binc;
145 
146  p_soff = 0;
147  p_loff = 0;
148  p_boff = 0;
149 
151  p_currentMap = 0;
152 
153  p_nmaps = ((BigInt)((p_maxSamps - 1) / p_sinc + 1) *
154  (BigInt)((p_maxLines - 1) / p_linc + 1) *
155  (BigInt)((p_maxBands - 1) / p_binc + 1));
156  }
157 
158 
179  void BufferManager::SetOffsets(const int soff, const int loff,
180  const int boff) {
181  p_soff = soff;
182  p_loff = loff;
183  p_boff = boff;
184  }
185 
186 
220  if(map >= 0) {
221  p_currentMap = map;
222 
223  if(!p_reverse) {
224  int sampDimension = (p_maxSamps / p_sinc);
225  if (p_maxSamps % p_sinc)
226  sampDimension++;
227 
228  p_currentSample = (map % sampDimension) * p_sinc + 1;
229  map /= sampDimension;
230 
231  int lineDimension = (p_maxLines / p_linc);
232  if (p_maxLines % p_linc)
233  lineDimension++;
234 
235  p_currentLine = (map % lineDimension) * p_linc + 1;
236  map /= lineDimension;
237 
238  p_currentBand = map * p_binc + 1;
239  }
240  else {
241  int bandDimension = (p_maxBands / p_binc);
242  if (p_maxBands % p_binc)
243  bandDimension++;
244 
245  p_currentBand = (map % bandDimension) * p_binc + 1;
246  map /= bandDimension;
247 
248  int lineDimension = (p_maxLines / p_linc);
249  if (p_maxLines % p_linc)
250  lineDimension++;
251 
252  p_currentLine = (map % lineDimension) * p_linc + 1;
253  map /= lineDimension;
254 
255  p_currentSample = map * p_sinc + 1;
256  }
257 
261  }
262  else {
263  string message = "Invalid value for argument [map]";
264  throw IException(IException::Programmer, message, _FILEINFO_);
265  }
266 
267  return !end();
268  }
269 } // end namespace isis
Isis::BufferManager::operator=
BufferManager & operator=(const BufferManager &rhs)
Creates a new BufferManager with the same values as another.
Definition: BufferManager.cpp:107
Isis::BufferManager::setpos
bool setpos(BigInt map)
Sets the position of the shape in the cube.
Definition: BufferManager.cpp:219
Isis::BufferManager::p_loff
int p_loff
Line offset.
Definition: BufferManager.h:179
Isis::BufferManager::p_currentLine
int p_currentLine
Current line.
Definition: BufferManager.h:183
Isis::BufferManager::SetIncrements
void SetIncrements(const int sinc, const int linc, const int binc)
Sets how the shape is incremented through the cube.
Definition: BufferManager.cpp:140
Isis::BufferManager::p_linc
int p_linc
Line increment.
Definition: BufferManager.h:175
Isis::BufferManager::p_currentSample
int p_currentSample
Current sample.
Definition: BufferManager.h:182
Isis::BufferManager::p_currentMap
BigInt p_currentMap
Current buffer map position.
Definition: BufferManager.h:187
Isis::BufferManager
Manages a Buffer over a cube.
Definition: BufferManager.h:52
Isis::Buffer
Buffer for reading and writing cube data.
Definition: Buffer.h:53
Isis::BufferManager::end
bool end() const
Returns true if the shape buffer has accessed the end of the cube.
Definition: BufferManager.h:115
Isis::BufferManager::swap
void swap(BufferManager &other)
Swaps the values of this BufferManager with that of another.
Definition: BufferManager.cpp:81
Isis::BufferManager::p_currentBand
int p_currentBand
Current band.
Definition: BufferManager.h:184
Isis::Buffer::SetBasePosition
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:106
Isis::BigInt
long long int BigInt
Big int.
Definition: Constants.h:49
Isis::BufferManager::p_binc
int p_binc
Band increment.
Definition: BufferManager.h:176
Isis::BufferManager::p_sinc
int p_sinc
Sample increment.
Definition: BufferManager.h:174
Isis::BufferManager::p_maxLines
int p_maxLines
Maximum lines to map.
Definition: BufferManager.h:171
Isis::BufferManager::SetOffsets
void SetOffsets(const int soff, const int loff, const int boff)
Sets the offset of the buffer.
Definition: BufferManager.cpp:179
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::BufferManager::p_maxBands
int p_maxBands
Maximum bands to map.
Definition: BufferManager.h:172
Isis::BufferManager::p_reverse
bool p_reverse
If true the axies are processed in Band, Line, Sample order (e.g., BIL).
Definition: BufferManager.h:194
Isis::PixelType
PixelType
Enumerations for Isis Pixel Types.
Definition: PixelType.h:27
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
std
Namespace for the standard library.
Isis::BufferManager::p_boff
int p_boff
Band offset.
Definition: BufferManager.h:180
Isis::BufferManager::p_soff
int p_soff
Sample offset.
Definition: BufferManager.h:178
Isis::BufferManager::p_nmaps
BigInt p_nmaps
Total number of objects to map.
Definition: BufferManager.h:186
Isis::BufferManager::p_maxSamps
int p_maxSamps
Maximum samples to map.
Definition: BufferManager.h:170
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16

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 USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:16:10