USGS

Isis 3.0 Object Programmers' Reference

Home

ProcessExport.h

Go to the documentation of this file.
00001 #ifndef ProcessExport_h
00002 #define ProcessExport_h
00003 
00025 #include <iostream>
00026 #include <string>
00027 #include <fstream>
00028 #include "Process.h"
00029 #include "Buffer.h"
00030 #include "BufferManager.h"
00031 #include "SpecialPixel.h"
00032 #include "Endian.h"
00033 #include "EndianSwapper.h"
00034 #include "Stretch.h"
00035 
00036 namespace Isis {
00107   class ProcessExport : public Isis::Process {
00108 
00109     public:
00110 
00112       enum ExportFormat { 
00113         BSQ, 
00114         BIL, 
00115         BIP, 
00116         JP2  
00117       };
00118 
00119       ProcessExport();
00120       ~ProcessExport();
00121       void StartProcess(void funct(Isis::Buffer &in));
00122       void StartProcess(void funct(std::vector<Isis::Buffer *> &in));
00123       void StartProcess(std::ofstream &fout);
00124       void SetOutputRange(const double minimum, const double maximum);
00125       void SetOutputNull(const double value);
00126       void SetOutputLis(const double value);
00127       void SetOutputLrs(const double value);
00128       void SetOutputHis(const double value);
00129       void SetOutputHrs(const double value);
00130       double OutputNull();
00131       double OutputLis();
00132       double OutputLrs();
00133       double OutputHis();
00134       double OutputHrs();
00135       bool HasInputRange() const;
00136       void SetInputRange();
00137       void SetInputRange(const double minimum, const double maximum);
00138       void SetInputRange(const double minimum, const double maximum, const int index);
00139       void SetInputRange(const double minimum, const double middle,
00140                          const double maximum);
00141       void SetInputRange(const double minimum, const double middle,
00142                          const double maximum, const int index);
00143       void CreateWorldFile(const QString &worldFile);
00144       void SetOutputEndian(enum ByteOrder endianness);
00145       void SetOutputType(Isis::PixelType pixelIn);
00146 
00147       double GetInputMinimum(unsigned int n=0) const;
00148       double GetInputMaximum(unsigned int n=0) const;
00149 
00151       double GetOutputMinimum() {
00152         return (p_outputMinimum);
00153       };
00155       double GetOutputMaximum() {
00156         return (p_outputMaximum);
00157       };
00158 
00160       void SetFormat(ExportFormat format) {
00161         p_format = format;
00162       };
00163 
00164 
00165       template <typename Functor> void ProcessCubes(const Functor & functor) {
00166         int length = (p_format == BIP) ?
00167           InputCubes[0]->bandCount() : InputCubes[0]->lineCount();
00168 
00169         int samples = InputCubes[0]->sampleCount();
00170 
00171         // Loop and let the app programmer fiddle with the lines
00172         std::vector<BufferManager *> imgrs = GetBuffers();
00173         for (int k = 1; k <= length; k++) {
00174           std::vector<Buffer *> ibufs;
00175 
00176           for (unsigned int j = 0; j < InputCubes.size(); j++) {
00177             // Read a line of data
00178             InputCubes[j]->read(*imgrs[j]);
00179 
00180             // Stretch the pixels into the desired range
00181             for (int i = 0; i < samples; i++)
00182               (*imgrs[j])[i] = p_str[j]->Map((*imgrs[j])[i]);
00183 
00184             ibufs.push_back(imgrs[j]);
00185           }
00186 
00187           // Invoke the user function
00188           functor(ibufs);
00189 
00190           for (unsigned int i = 0; i < imgrs.size(); i++) imgrs[i]->next();
00191           p_progress->CheckStatus();
00192         }
00193       }
00194 
00195     protected:
00196 
00198       ExportFormat p_format;
00199 
00200       std::vector<BufferManager *> GetBuffers();
00201       std::vector<BufferManager *> GetBuffersBSQ();
00202       std::vector<BufferManager *> GetBuffersBIL();
00203       std::vector<BufferManager *> GetBuffersBIP();
00204 
00205       double p_outputMinimum; 
00206       double p_outputMiddle;  
00208       double p_outputMaximum; 
00209 
00210       std::vector<double> p_inputMinimum; 
00213       std::vector<double> p_inputMiddle;  
00217       std::vector<double> p_inputMaximum; 
00220       EndianSwapper *p_endianSwap; 
00222       ByteOrder p_endianType; 
00223 
00224       PixelType p_pixelType;  
00226       std::vector<Stretch *> p_str; 
00230       double p_Null; 
00231       double p_Lis;  
00232       double p_Lrs;  
00233       double p_His;  
00234       double p_Hrs;  
00235 
00236       bool p_Null_Set; 
00237       bool p_Lis_Set;  
00238       bool p_Lrs_Set;  
00239       bool p_His_Set;  
00240       bool p_Hrs_Set;  
00241 
00242     private:
00244       void isisOut8(Buffer &in, std::ofstream &fout);
00245 
00247       void isisOut16s(Buffer &in, std::ofstream &fout);
00248 
00250       void isisOut16u(Buffer &in, std::ofstream &fout);
00251 
00254       void isisOut32(Buffer &in, std::ofstream &fout);
00255 
00259       void InitProcess();
00260 
00261 
00262   };
00263 };
00264 
00265 #endif