USGS

Isis 3.0 Object Programmers' Reference

Home

ProcessByTile.cpp
Go to the documentation of this file.
1 
23 #include "ProcessByTile.h"
24 #include "TileManager.h"
25 
26 using namespace std;
27 namespace Isis {
28 
36  void ProcessByTile::SetTileSize(const int ns, const int nl) {
37  p_tileSamples = ns;
38  p_tileLines = nl;
39  p_tileSizeSet = true;
40  }
41 
56  void ProcessByTile::StartProcess(void
57  funct(Buffer &in, Buffer &out)) {
58  SetBrickSizesForProcessCube();
59  ProcessByBrick::StartProcess(funct);
60  }
61 
62 
76  void ProcessByTile::StartProcess(void funct(Buffer &in)) {
77  SetBrickSizesForProcessCubeInPlace();
78  ProcessByBrick::StartProcess(funct);
79  }
80 
81 
96  void ProcessByTile::StartProcess(void funct(std::vector<Buffer *> &in,
97  std::vector<Buffer *> &out)) {
98  SetBrickSizesForProcessCubes();
99  ProcessByBrick::StartProcess(funct);
100  }
101 
102 
109  void ProcessByTile::EndProcess() {
110  p_tileSizeSet = false;
111  ProcessByBrick::EndProcess();
112  }
113 
114 
118  void ProcessByTile::Finalize() {
119  p_tileSizeSet = false;
120  ProcessByBrick::Finalize();
121  }
122 
123 
127  void ProcessByTile::SetBrickSizesForProcessCubeInPlace() {
128  // Error checks ... there must be one input and output
129  if(InputCubes.size() != 1) {
130  string m = "You must specify exactly one input cube";
131  throw IException(IException::Programmer, m, _FILEINFO_);
132  }
133 
134  // Make sure the tile size has been set
135  if(!p_tileSizeSet) {
136  string m = "Use the SetTileSize method to set the tile size";
137  throw IException(IException::Programmer, m, _FILEINFO_);
138  }
139 
140  ProcessByBrick::SetBrickSize(p_tileSamples, p_tileLines, 1);
141  }
142 
143 
147  void ProcessByTile::SetBrickSizesForProcessCube() {
148  // The lines in the input and output must match
149  if(InputCubes[0]->lineCount() != OutputCubes[0]->lineCount()) {
150  string m = "The number of lines in the input and output cubes ";
151  m += "must match";
152  throw IException(IException::Programmer, m, _FILEINFO_);
153  }
154 
155  // The samples in the input and output must match
156  if(InputCubes[0]->sampleCount() != OutputCubes[0]->sampleCount()) {
157  string m = "The number of samples in the input and output cubes ";
158  m += "must match";
159  throw IException(IException::Programmer, m, _FILEINFO_);
160  }
161 
162  // The bands in the input and output must match
163  if(InputCubes[0]->bandCount() != OutputCubes[0]->bandCount()) {
164  string m = "The number of bands in the input and output cubes ";
165  m += "must match";
166  throw IException(IException::Programmer, m, _FILEINFO_);
167  }
168 
169  // Make sure the tile size has been set
170  if(!p_tileSizeSet) {
171  string m = "Use the SetTileSize method to set the tile size";
172  throw IException(IException::Programmer, m, _FILEINFO_);
173  }
174 
175  ProcessByBrick::SetBrickSize(p_tileSamples, p_tileLines, 1);
176  }
177 
178 
182  void ProcessByTile::SetBrickSizesForProcessCubes() {
183  // Make sure we had an image
184  if(InputCubes.size() == 0 && OutputCubes.size() == 0) {
185  string m = "You have not specified any input or output cubes";
186  throw IException(IException::Programmer, m, _FILEINFO_);
187  }
188 
189  // Make sure all the output images have the same number of bands as
190  // the first input/output cube
191  for(unsigned int i = 0; i < OutputCubes.size(); i++) {
192  if(OutputCubes[i]->bandCount() != InputCubes[0]->bandCount()) {
193  string m = "All output cubes must have the same number of bands ";
194  m += "as the first input cube or output cube";
195  throw IException(IException::Programmer, m, _FILEINFO_);
196  }
197  }
198 
199  ProcessByBrick::SetBrickSize(p_tileSamples, p_tileLines, 1);
200  }
201 } // end namespace isis
202