Isis 3 Programmer Reference
ProcessBySpectra.cpp
Go to the documentation of this file.
1 
24 #include "ProcessBySpectra.h"
25 
26 #include "Buffer.h"
27 #include "Cube.h"
28 #include "IException.h"
29 #include "Process.h"
30 #include "ProcessByBrick.h"
31 
32 using namespace std;
33 namespace Isis {
34 
57  Isis::Cube *ProcessBySpectra::SetInputCube(const QString &parameter,
58  const int requirements) {
59  return ProcessByBrick::SetInputCube(parameter,
60  Isis::SpatialMatch | requirements);
61  }
62 
63 
76  Isis::Cube *ProcessBySpectra::SetInputCube(const QString &file,
78  const int requirements) {
79  return ProcessByBrick::SetInputCube(file, att,
80  Isis::SpatialMatch | requirements);
81  }
82 
83 
97  void ProcessBySpectra::StartProcess(void funct(Isis::Buffer &in)) {
98 
99 
100  VerifyCubes(InPlace);
101  SetBricks(InPlace);
102  //SetBrickSizesForProcessCubeInPlace();
103  ProcessByBrick::StartProcess(funct);
104  }
105 
106 
119  void ProcessBySpectra::StartProcess(void
120  funct(Isis::Buffer &in,
121  Isis::Buffer &out)) {
122 
123  VerifyCubes(InputOutput);
124  SetBricks(InputOutput);
125  //SetBrickSizesForProcessCube();
126  ProcessByBrick::StartProcess(funct);
127  }
128 
129 
141  void ProcessBySpectra::StartProcess(void funct(std::vector<Isis::Buffer *> &in,
142  std::vector<Isis::Buffer *> &out)) {
143  //SetBrickSizesForProcessCubes();
144  VerifyCubes(InputOutputList);
145  SetBricks(InputOutputList);
146  ProcessByBrick::StartProcess(funct);
147  }
148 
149 
159  void ProcessBySpectra::SetType(const int type) {
160  if (type != PerPixel && type != ByLine && type != BySample) {
161  string m = "The specified spectra type is invalid";
162  throw IException(IException::Programmer, m, _FILEINFO_);
163  }
164  else p_spectraType = type;
165  }
166 
167 
168  void ProcessBySpectra::SetBricks(IOCubes cn){
169 
170 
171 
172 
173  switch(cn){
174 
175  case InPlace:
176  int ns, nl, nb;
177  if(InputCubes.size() == 1) {
178 
179  ns = InputCubes[0]->sampleCount();
180  nl = InputCubes[0]->lineCount();
181  nb = InputCubes[0]->bandCount();
182  }
183  else {
184  ns = OutputCubes[0]->sampleCount();
185  nl = OutputCubes[0]->lineCount();
186  nb = OutputCubes[0]->bandCount();
187  }
188 
189  if(Type() == PerPixel) SetBrickSize(1, 1, nb);
190 
191  else if(Type() == ByLine) SetBrickSize(ns, 1, nb);
192 
193  else SetBrickSize(1, nl, nb);
194 
195  break;
196 
197  case InputOutput:
198 
199  if(Type() == PerPixel) {
200  SetInputBrickSize(1, 1, InputCubes[0]->bandCount());
201  SetOutputBrickSize(1, 1, OutputCubes[0]->bandCount());
202  }
203  else if(Type() == ByLine) {
204  SetInputBrickSize(InputCubes[0]->sampleCount(), 1,
205  InputCubes[0]->bandCount());
206  SetOutputBrickSize(OutputCubes[0]->sampleCount(), 1,
207  OutputCubes[0]->bandCount());
208  }
209  else {
210  SetInputBrickSize(1, InputCubes[0]->lineCount(),
211  InputCubes[0]->bandCount());
212  SetOutputBrickSize(1, OutputCubes[0]->lineCount(),
213  OutputCubes[0]->bandCount());
214  }
215 
216  break;
217 
218 
219  case InputOutputList:
220 
221  if(Type() == PerPixel) {
222  for(unsigned int i = 0; i < InputCubes.size(); i++) {
223  SetInputBrickSize(1, 1, InputCubes[i]->bandCount(), i + 1);
224  }
225  for(unsigned int i = 0; i < OutputCubes.size(); i++) {
226  SetOutputBrickSize(1, 1, OutputCubes[i]->bandCount(), i + 1);
227  }
228  }
229  else if(Type() == ByLine) {
230  for(unsigned int i = 0; i < InputCubes.size(); i++) {
231  SetInputBrickSize(InputCubes[i]->sampleCount(), 1,
232  InputCubes[i]->bandCount(), i + 1);
233  }
234  for(unsigned int i = 0; i < OutputCubes.size(); i++) {
235  SetOutputBrickSize(OutputCubes[i]->sampleCount(), 1,
236  OutputCubes[i]->bandCount(), i + 1);
237  }
238  }
239  else {
240  for(unsigned int i = 0; i < InputCubes.size(); i++) {
241  SetInputBrickSize(1, InputCubes[i]->lineCount(),
242  InputCubes[i]->bandCount(), i + 1);
243  }
244  for(unsigned int i = 0; i < OutputCubes.size(); i++) {
245  SetOutputBrickSize(1, OutputCubes[i]->lineCount(),
246  OutputCubes[i]->bandCount(), i + 1);
247  }
248  }
249 
250  break;
251 
252  }
253 
254 
255  }
256 
257 
262  /*
263  void ProcessBySpectra::SetBrickSizesForProcessCubeInPlace() {
264  // Error checks
265  if ((InputCubes.size() + OutputCubes.size()) > 1) {
266  string m = "You can only specify exactly one input or output cube";
267  throw IException(IException::Programmer, m, _FILEINFO_);
268  }
269  else if ((InputCubes.size() + OutputCubes.size()) == 0) {
270  string m = "You haven't specified an input or output cube";
271  throw IException(IException::Programmer, m, _FILEINFO_);
272  }
273 
274  int ns, nl, nb;
275  if (InputCubes.size() == 1) {
276  ns = InputCubes[0]->sampleCount();
277  nl = InputCubes[0]->lineCount();
278  nb = InputCubes[0]->bandCount();
279  }
280  else {
281  ns = OutputCubes[0]->sampleCount();
282  nl = OutputCubes[0]->lineCount();
283  nb = OutputCubes[0]->bandCount();
284  }
285  if (Type() == PerPixel) SetBrickSize(1, 1, nb);
286  else if (Type() == ByLine) SetBrickSize(ns, 1, nb);
287  else SetBrickSize(1, nl, nb);
288  }
289 
290 */
294  /*
295  void ProcessBySpectra::SetBrickSizesForProcessCube() {
296  // Error checks ... there must be one input and output
297  if (InputCubes.size() != 1) {
298  string m = "You must specify exactly one input cube";
299  throw IException(IException::Programmer, m, _FILEINFO_);
300  }
301  else if (OutputCubes.size() != 1) {
302  string m = "You must specify exactly one output cube";
303  throw IException(IException::Programmer, m, _FILEINFO_);
304  }
305 
306  if (Type() == PerPixel) {
307  SetInputBrickSize(1, 1, InputCubes[0]->bandCount());
308  SetOutputBrickSize(1, 1, OutputCubes[0]->bandCount());
309  }
310  else if (Type() == ByLine) {
311  SetInputBrickSize(InputCubes[0]->sampleCount(), 1,
312  InputCubes[0]->bandCount());
313  SetOutputBrickSize(OutputCubes[0]->sampleCount(), 1,
314  OutputCubes[0]->bandCount());
315  }
316  else {
317  SetInputBrickSize(1, InputCubes[0]->lineCount(),
318  InputCubes[0]->bandCount());
319  SetOutputBrickSize(1, OutputCubes[0]->lineCount(),
320  OutputCubes[0]->bandCount());
321  }
322  }
323 
324 */
328  /*
329  void ProcessBySpectra::SetBrickSizesForProcessCubes() {
330  if (Type() == PerPixel) {
331  for (unsigned int i = 0; i < InputCubes.size(); i++) {
332  SetInputBrickSize(1, 1, InputCubes[i]->bandCount(), i + 1);
333  }
334  for (unsigned int i = 0; i < OutputCubes.size(); i++) {
335  SetOutputBrickSize(1, 1, OutputCubes[i]->bandCount(), i + 1);
336  }
337  }
338  else if (Type() == ByLine) {
339  for (unsigned int i = 0; i < InputCubes.size(); i++) {
340  SetInputBrickSize(InputCubes[i]->sampleCount(), 1,
341  InputCubes[i]->bandCount(), i + 1);
342  }
343  for (unsigned int i = 0; i < OutputCubes.size(); i++) {
344  SetOutputBrickSize(OutputCubes[i]->sampleCount(), 1,
345  OutputCubes[i]->bandCount(), i + 1);
346  }
347  }
348  else {
349  for (unsigned int i = 0; i < InputCubes.size(); i++) {
350  SetInputBrickSize(1, InputCubes[i]->lineCount(),
351  InputCubes[i]->bandCount(), i + 1);
352  }
353  for (unsigned int i = 0; i < OutputCubes.size(); i++) {
354  SetOutputBrickSize(1, OutputCubes[i]->lineCount(),
355  OutputCubes[i]->bandCount(), i + 1);
356  }
357  }
358  }
359  */
360 
361 
362 }
Buffer for reading and writing cube data.
Definition: Buffer.h:69
Manipulate and parse attributes of input cube filenames.
Namespace for the standard library.
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
IO Handler for Isis Cubes.
Definition: Cube.h:170