Isis 3 Programmer Reference
ProcessBySpectra.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 
8 #include "ProcessBySpectra.h"
9 
10 #include "Buffer.h"
11 #include "Cube.h"
12 #include "IException.h"
13 #include "Process.h"
14 #include "ProcessByBrick.h"
15 
16 using namespace std;
17 namespace Isis {
18 
41  Isis::Cube *ProcessBySpectra::SetInputCube(const QString &parameter,
42  const int requirements) {
43  return ProcessByBrick::SetInputCube(parameter,
44  Isis::SpatialMatch | requirements);
45  }
46 
47 
60  Isis::Cube *ProcessBySpectra::SetInputCube(const QString &file,
62  const int requirements) {
63  return ProcessByBrick::SetInputCube(file, att,
64  Isis::SpatialMatch | requirements);
65  }
66 
67 
81  void ProcessBySpectra::StartProcess(void funct(Isis::Buffer &in)) {
82 
83 
84  VerifyCubes(InPlace);
85  SetBricks(InPlace);
86  //SetBrickSizesForProcessCubeInPlace();
87  ProcessByBrick::StartProcess(funct);
88  }
89 
90 
103  void ProcessBySpectra::StartProcess(void
104  funct(Isis::Buffer &in,
105  Isis::Buffer &out)) {
106 
107  VerifyCubes(InputOutput);
108  SetBricks(InputOutput);
109  //SetBrickSizesForProcessCube();
110  ProcessByBrick::StartProcess(funct);
111  }
112 
113 
125  void ProcessBySpectra::StartProcess(void funct(std::vector<Isis::Buffer *> &in,
126  std::vector<Isis::Buffer *> &out)) {
127  //SetBrickSizesForProcessCubes();
128  VerifyCubes(InputOutputList);
129  SetBricks(InputOutputList);
130  ProcessByBrick::StartProcess(funct);
131  }
132 
133 
143  void ProcessBySpectra::SetType(const int type) {
144  if (type != PerPixel && type != ByLine && type != BySample) {
145  string m = "The specified spectra type is invalid";
146  throw IException(IException::Programmer, m, _FILEINFO_);
147  }
148  else p_spectraType = type;
149  }
150 
151 
152  void ProcessBySpectra::SetBricks(IOCubes cn){
153 
154 
155 
156 
157  switch(cn){
158 
159  case InPlace:
160  int ns, nl, nb;
161  if(InputCubes.size() == 1) {
162 
163  ns = InputCubes[0]->sampleCount();
164  nl = InputCubes[0]->lineCount();
165  nb = InputCubes[0]->bandCount();
166  }
167  else {
168  ns = OutputCubes[0]->sampleCount();
169  nl = OutputCubes[0]->lineCount();
170  nb = OutputCubes[0]->bandCount();
171  }
172 
173  if(Type() == PerPixel) SetBrickSize(1, 1, nb);
174 
175  else if(Type() == ByLine) SetBrickSize(ns, 1, nb);
176 
177  else SetBrickSize(1, nl, nb);
178 
179  break;
180 
181  case InputOutput:
182 
183  if(Type() == PerPixel) {
184  SetInputBrickSize(1, 1, InputCubes[0]->bandCount());
185  SetOutputBrickSize(1, 1, OutputCubes[0]->bandCount());
186  }
187  else if(Type() == ByLine) {
188  SetInputBrickSize(InputCubes[0]->sampleCount(), 1,
189  InputCubes[0]->bandCount());
190  SetOutputBrickSize(OutputCubes[0]->sampleCount(), 1,
191  OutputCubes[0]->bandCount());
192  }
193  else {
194  SetInputBrickSize(1, InputCubes[0]->lineCount(),
195  InputCubes[0]->bandCount());
196  SetOutputBrickSize(1, OutputCubes[0]->lineCount(),
197  OutputCubes[0]->bandCount());
198  }
199 
200  break;
201 
202 
203  case InputOutputList:
204 
205  if(Type() == PerPixel) {
206  for(unsigned int i = 0; i < InputCubes.size(); i++) {
207  SetInputBrickSize(1, 1, InputCubes[i]->bandCount(), i + 1);
208  }
209  for(unsigned int i = 0; i < OutputCubes.size(); i++) {
210  SetOutputBrickSize(1, 1, OutputCubes[i]->bandCount(), i + 1);
211  }
212  }
213  else if(Type() == ByLine) {
214  for(unsigned int i = 0; i < InputCubes.size(); i++) {
215  SetInputBrickSize(InputCubes[i]->sampleCount(), 1,
216  InputCubes[i]->bandCount(), i + 1);
217  }
218  for(unsigned int i = 0; i < OutputCubes.size(); i++) {
219  SetOutputBrickSize(OutputCubes[i]->sampleCount(), 1,
220  OutputCubes[i]->bandCount(), i + 1);
221  }
222  }
223  else {
224  for(unsigned int i = 0; i < InputCubes.size(); i++) {
225  SetInputBrickSize(1, InputCubes[i]->lineCount(),
226  InputCubes[i]->bandCount(), i + 1);
227  }
228  for(unsigned int i = 0; i < OutputCubes.size(); i++) {
229  SetOutputBrickSize(1, OutputCubes[i]->lineCount(),
230  OutputCubes[i]->bandCount(), i + 1);
231  }
232  }
233 
234  break;
235 
236  }
237 
238 
239  }
240 
241 
246  /*
247  void ProcessBySpectra::SetBrickSizesForProcessCubeInPlace() {
248  // Error checks
249  if ((InputCubes.size() + OutputCubes.size()) > 1) {
250  string m = "You can only specify exactly one input or output cube";
251  throw IException(IException::Programmer, m, _FILEINFO_);
252  }
253  else if ((InputCubes.size() + OutputCubes.size()) == 0) {
254  string m = "You haven't specified an input or output cube";
255  throw IException(IException::Programmer, m, _FILEINFO_);
256  }
257 
258  int ns, nl, nb;
259  if (InputCubes.size() == 1) {
260  ns = InputCubes[0]->sampleCount();
261  nl = InputCubes[0]->lineCount();
262  nb = InputCubes[0]->bandCount();
263  }
264  else {
265  ns = OutputCubes[0]->sampleCount();
266  nl = OutputCubes[0]->lineCount();
267  nb = OutputCubes[0]->bandCount();
268  }
269  if (Type() == PerPixel) SetBrickSize(1, 1, nb);
270  else if (Type() == ByLine) SetBrickSize(ns, 1, nb);
271  else SetBrickSize(1, nl, nb);
272  }
273 
274 */
278  /*
279  void ProcessBySpectra::SetBrickSizesForProcessCube() {
280  // Error checks ... there must be one input and output
281  if (InputCubes.size() != 1) {
282  string m = "You must specify exactly one input cube";
283  throw IException(IException::Programmer, m, _FILEINFO_);
284  }
285  else if (OutputCubes.size() != 1) {
286  string m = "You must specify exactly one output cube";
287  throw IException(IException::Programmer, m, _FILEINFO_);
288  }
289 
290  if (Type() == PerPixel) {
291  SetInputBrickSize(1, 1, InputCubes[0]->bandCount());
292  SetOutputBrickSize(1, 1, OutputCubes[0]->bandCount());
293  }
294  else if (Type() == ByLine) {
295  SetInputBrickSize(InputCubes[0]->sampleCount(), 1,
296  InputCubes[0]->bandCount());
297  SetOutputBrickSize(OutputCubes[0]->sampleCount(), 1,
298  OutputCubes[0]->bandCount());
299  }
300  else {
301  SetInputBrickSize(1, InputCubes[0]->lineCount(),
302  InputCubes[0]->bandCount());
303  SetOutputBrickSize(1, OutputCubes[0]->lineCount(),
304  OutputCubes[0]->bandCount());
305  }
306  }
307 
308 */
312  /*
313  void ProcessBySpectra::SetBrickSizesForProcessCubes() {
314  if (Type() == PerPixel) {
315  for (unsigned int i = 0; i < InputCubes.size(); i++) {
316  SetInputBrickSize(1, 1, InputCubes[i]->bandCount(), i + 1);
317  }
318  for (unsigned int i = 0; i < OutputCubes.size(); i++) {
319  SetOutputBrickSize(1, 1, OutputCubes[i]->bandCount(), i + 1);
320  }
321  }
322  else if (Type() == ByLine) {
323  for (unsigned int i = 0; i < InputCubes.size(); i++) {
324  SetInputBrickSize(InputCubes[i]->sampleCount(), 1,
325  InputCubes[i]->bandCount(), i + 1);
326  }
327  for (unsigned int i = 0; i < OutputCubes.size(); i++) {
328  SetOutputBrickSize(OutputCubes[i]->sampleCount(), 1,
329  OutputCubes[i]->bandCount(), i + 1);
330  }
331  }
332  else {
333  for (unsigned int i = 0; i < InputCubes.size(); i++) {
334  SetInputBrickSize(1, InputCubes[i]->lineCount(),
335  InputCubes[i]->bandCount(), i + 1);
336  }
337  for (unsigned int i = 0; i < OutputCubes.size(); i++) {
338  SetOutputBrickSize(1, OutputCubes[i]->lineCount(),
339  OutputCubes[i]->bandCount(), i + 1);
340  }
341  }
342  }
343  */
344 
345 
346 }
Isis::Buffer
Buffer for reading and writing cube data.
Definition: Buffer.h:53
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::IException
Isis exception class.
Definition: IException.h:91
std
Namespace for the standard library.
Isis::CubeAttributeInput
Manipulate and parse attributes of input cube filenames.
Definition: CubeAttribute.h:381
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16