USGS

Isis 3.0 Object Programmers' Reference

Home

ProcessExport.h
Go to the documentation of this file.
1 #ifndef ProcessExport_h
2 #define ProcessExport_h
3 
24 #include "Process.h"
25 
26 #include <fstream>
27 #include <iostream>
28 #include <string>
29 
30 #include "Buffer.h"
31 #include "BufferManager.h"
32 #include "Endian.h"
33 #include "EndianSwapper.h"
34 #include "SpecialPixel.h"
35 #include "Stretch.h"
36 
37 namespace Isis {
116  class ProcessExport : public Isis::Process {
117 
118  public:
119 
121  enum ExportFormat {
122  BSQ,
123  BIL,
124  BIP,
126  };
127 
128  ProcessExport();
129  virtual ~ProcessExport();
130  virtual void StartProcess(void funct(Isis::Buffer &in));
131  virtual void StartProcess(void funct(std::vector<Isis::Buffer *> &in));
132  virtual void StartProcess(std::ofstream &fout);
133  void SetOutputRange(const double minimum, const double maximum);
134  void SetOutputNull(const double value);
135  void SetOutputLis(const double value);
136  void SetOutputLrs(const double value);
137  void SetOutputHis(const double value);
138  void SetOutputHrs(const double value);
139  double OutputNull();
140  double OutputLis();
141  double OutputLrs();
142  double OutputHis();
143  double OutputHrs();
144  bool HasInputRange() const;
145  void SetInputRange();
146  void SetInputRange(const double minimum, const double maximum);
147  void SetInputRange(const double minimum, const double maximum, const int index);
148  void SetInputRange(const double minimum, const double middle,
149  const double maximum);
150  void SetInputRange(const double minimum, const double middle,
151  const double maximum, const int index);
152  void CreateWorldFile(const QString &worldFile);
153  void SetOutputEndian(enum ByteOrder endianness);
154  void SetOutputType(Isis::PixelType pixelIn);
155 
156  double GetInputMinimum(unsigned int n=0) const;
157  double GetInputMaximum(unsigned int n=0) const;
158 
160  double GetOutputMinimum() {
161  return (p_outputMinimum);
162  };
164  double GetOutputMaximum() {
165  return (p_outputMaximum);
166  };
167 
169  void setFormat(ExportFormat format) {
170  p_format = format;
171  };
172 
173 
174  template <typename Functor> void ProcessCubes(const Functor & functor) {
175 
176  int samples = InputCubes[0]->sampleCount();
177  int length = 0;
178  if (p_format == BIP) {
179  length = InputCubes[0]->bandCount();
180  }
181  else {
182  length = InputCubes[0]->lineCount();
183  }
184 
185  // Loop and let the app programmer fiddle with the lines
186  std::vector<BufferManager *> imgrs = GetBuffers();
187  for (int k = 1; k <= length; k++) {
188  std::vector<Buffer *> ibufs;
189 
190  for (unsigned int cubeIndex = 0; cubeIndex < InputCubes.size(); cubeIndex++) {
191  // Read a line of data from this cube
192  InputCubes[cubeIndex]->read(*imgrs[cubeIndex]);
193 
194  // Stretch the pixels into the desired range
195  for (int sampleIndex = 0; sampleIndex < samples; sampleIndex++) {
196  (*imgrs[cubeIndex])[sampleIndex] =
197  p_str[cubeIndex]->Map((*imgrs[cubeIndex])[sampleIndex]);
198  }
199 
200  ibufs.push_back(imgrs[cubeIndex]);
201  }
202 
203  // Invoke the user function
204  functor(ibufs);
205 
206  for (unsigned int i = 0; i < imgrs.size(); i++) imgrs[i]->next();
208  }
209  }
210 
211  protected:
212 
215 
216  std::vector<BufferManager *> GetBuffers();
217  std::vector<BufferManager *> GetBuffersBSQ();
218  std::vector<BufferManager *> GetBuffersBIL();
219  std::vector<BufferManager *> GetBuffersBIP();
220 
222  double p_outputMiddle;
225 
226  std::vector<double> p_inputMinimum;
229  std::vector<double> p_inputMiddle;
233  std::vector<double> p_inputMaximum;
239 
242  std::vector<Stretch *> p_str;
246  double p_Null;
247  double p_Lis;
249  double p_Lrs;
251  double p_His;
253  double p_Hrs;
256  bool p_Null_Set;
258  bool p_Lis_Set;
260  bool p_Lrs_Set;
262  bool p_His_Set;
264  bool p_Hrs_Set;
267  private:
269  void isisOut8(Buffer &in, std::ofstream &fout);
270 
272  void isisOut16s(Buffer &in, std::ofstream &fout);
273 
275  void isisOut16u(Buffer &in, std::ofstream &fout);
276 
279  void isisOut32(Buffer &in, std::ofstream &fout);
280 
284  void InitProcess();
285 
286 
287  };
288 };
289 
290 #endif