Isis 3 Programmer Reference
ProcessImport.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "ProcessImport.h"
8 
9 #include <float.h>
10 #include <iostream>
11 #include <QString>
12 #include <sstream>
13 
14 #include "Application.h"
15 #include "BoxcarCachingAlgorithm.h"
16 #include "Brick.h"
17 #include "Cube.h"
18 #include "CubeAttribute.h"
19 #include "IException.h"
20 #include "IString.h"
21 #include "JP2Decoder.h"
22 #include "LineManager.h"
23 #include "PixelType.h"
24 #include "Process.h"
25 #include "Pvl.h"
26 #include "PvlTokenizer.h"
27 #include "SpecialPixel.h"
28 #include "UserInterface.h"
29 
30 #define EXPONENT_MASK ((char) 0x7F)
31 
32 
33 using namespace std;
34 namespace Isis {
35 
37  ProcessImport::ProcessImport() : Isis::Process() {
38 
39  p_progress->SetText("Importing");
40 
41  // Initialize input file information
42  p_inFile = "";
43  p_pixelType = Isis::None;
44  p_suffixPixelType = Isis::None;
45  p_ns = p_nl = p_nb = 0;
46  p_byteOrder = Isis::NoByteOrder;
50  p_dataPreBytes = 0;
51  p_dataPostBytes = 0;
52  p_suffixData = 0;
54 
55  p_base.push_back(0.0);
56  p_mult.push_back(1.0);
57  // Make all special pixels invalid
58  SetNull(DBL_MAX, -DBL_MAX);
59  SetHRS(DBL_MAX, -DBL_MAX);
60  SetLRS(DBL_MAX, -DBL_MAX);
61  SetHIS(DBL_MAX, -DBL_MAX);
62  SetLIS(DBL_MAX, -DBL_MAX);
63 
64  p_saveFileHeader = false;
65  p_saveDataHeader = false;
66  p_saveDataTrailer = false;
67  p_saveDataPre = false;
68  p_saveDataPost = false;
69  p_saveFileTrailer = false;
70  p_vax_convert = false;
71 
72  p_fileHeader = NULL;
73  p_fileTrailer = NULL;
74  }
75 
76 
79  if (p_fileHeader) {
80  delete [] p_fileHeader;
81  p_fileHeader = NULL;
82  }
83 
84  for(unsigned int i = 0; i < p_dataHeader.size(); i++) {
85  delete [] p_dataHeader[i];
86  }
87 
88  for(unsigned int i = 0; i < p_dataTrailer.size(); i++) {
89  delete [] p_dataTrailer[i];
90  }
91 
92  vector<char *> temp;
93  for(unsigned int j = 0; j < p_dataPre.size(); j++) {
94  temp = p_dataPre[j];
95  for(unsigned int i = 0; i < temp.size(); i++) delete [] temp[i];
96  }
97 
98  for(unsigned int j = 0; j < p_dataPost.size(); j++) {
99  temp = p_dataPost[j];
100  for(unsigned int i = 0; i < temp.size(); i++) delete [] temp[i];
101  }
102 
103  if (p_fileTrailer) {
104  delete p_fileTrailer;
105  }
106  }
107 
108 
118  bool ProcessImport::IsVAXSpecial(unsigned int *vax, VAXSpecialPixel pix) {
119 
120  unsigned int VAX_NULL = 0xFFFFFFFF;
121  unsigned int VAX_MIN = 0xFFEFFFFF;
122  unsigned int VAX_LRS = 0xFFFEFFFF;
123  unsigned int VAX_LIS = 0xFFFDFFFF;
124  unsigned int VAX_HIS = 0xFFFCFFFF;
125  unsigned int VAX_HRS = 0xFFFBFFFF;
126  int n;
127 
128  unsigned int x;
129  memcpy(&x, vax, sizeof(unsigned int));
130 
131  switch(pix) {
132  case VAX_NULL4:
133  n = memcmp(&VAX_NULL, &x, sizeof(unsigned int));
134  if (n == 0) return true;
135  break;
136  case VAX_LRS4:
137  n = memcmp(&VAX_LRS, &x, sizeof(unsigned int));
138  if (n == 0) return true;
139  break;
140  case VAX_LIS4:
141  n = memcmp(&VAX_LIS, &x, sizeof(unsigned int));
142  if (n == 0) return true;
143  break;
144  case VAX_HIS4:
145  n = memcmp(&VAX_HIS, &x, sizeof(unsigned int));
146  if (n == 0) return true;
147  break;
148  case VAX_HRS4:
149  n = memcmp(&VAX_HRS, &x, sizeof(unsigned int));
150  if (n == 0) return true;
151  break;
152  case VAX_MIN4:
153  n = memcmp(&VAX_MIN, &x, sizeof(unsigned int));
154  if (n == 0) return true;
155  break;
156  default:
157  return false;
158  }
159 
160  return false;
161 
162  }
163 
164 
171  double ProcessImport::VAXConversion(void *ibuf) {
172 
173  float result;
174  double dresult;
175  bool swap_bytes = false;
176  bool swap_words = true;
177  int exp_adjust = -1;
178  int exp_mask = 0;
179  int exp_word = 1;
180  int exp_byte;
181  Isis::ByteOrder in_order = p_byteOrder;
182  Isis::ByteOrder out_order;
183 
184  unsigned int *oli, *ili; //4-byte buffer io ptrs
185  unsigned short *osi; //2-byte buffer io ptrs
186  char *oci; //1-byte buffer io ptrs
187 
188  if ( Isis::IsLsb() ) {
189  exp_byte = 1;
190  out_order = Isis::Lsb;
191  }
192  else {
193  exp_byte = 0;
194  out_order = Isis::Msb;
195  }
196 
197  if (in_order != out_order) {
198  swap_bytes =true;
199  }
200 
201  oli = (unsigned int * ) ibuf;
202  ili = (unsigned int * ) ibuf;
203 
204  if (IsVAXSpecial(oli, ProcessImport::VAX_NULL4) ) {
205  return Isis::NULL8;
206  }
207 
208  if (IsVAXSpecial(oli, ProcessImport::VAX_LIS4) ) {
209  return Isis::LOW_INSTR_SAT8;
210  }
211 
212  if (IsVAXSpecial(oli, ProcessImport::VAX_LRS4) ) {
213  return Isis::LOW_REPR_SAT8;
214  }
215 
216  if (IsVAXSpecial(oli, ProcessImport::VAX_HIS4) ) {
217  return Isis::HIGH_INSTR_SAT8;
218  }
219 
220  if (IsVAXSpecial(oli, ProcessImport::VAX_HRS4) ) {
221  return Isis::HIGH_REPR_SAT8;
222  }
223 
224  if (IsVAXSpecial(oli, ProcessImport::VAX_MIN4) ) {
225  return Isis::VALID_MIN8;
226  }
227 
228  //test for word swapping
229  if (swap_words) {
230  *oli = (*ili <<16) | (*ili >> 16);
231  }
232 
233  osi = (unsigned short* ) oli;
234 
235  //test for byte swapping
236 
237  if (swap_bytes) {
238  osi[0] = (osi[0] >> 8 ) | (osi[0] << 8);
239  osi[1] = (osi[1] >> 8 ) | (osi[1] << 8);
240  }
241 
242  //Isolate the exponent and do the conversion
243  oci = (char *) &osi[exp_word];
244 
245  if ( (oci[exp_byte] & EXPONENT_MASK) != exp_mask) {
246  oci[exp_byte] += exp_adjust;
247  }
248 
249  result = *(float *)oli;
250  dresult = static_cast<double>(result);
251  return dresult;
252 
253  }
254 
255 
265 
266  if ((type == Isis::Double) || (type == Isis::Real) || (type == Isis::SignedWord) ||
267  (type == Isis::UnsignedWord) || (type == Isis::UnsignedByte) ||
268  (type == Isis::SignedInteger) || type==Isis::UnsignedInteger) {
269  p_pixelType = type;
270  }
271  else {
272  QString msg = "Unsupported pixel type [" +
273  Isis::PixelTypeName(type) + "]";
274  throw IException(IException::Programmer, msg, _FILEINFO_);
275  }
276  }
277 
278  void ProcessImport::SetSuffixPixelType(const Isis::PixelType type) {
279 
280  if ((type == Isis::Double) || (type == Isis::Real) || (type == Isis::SignedWord) ||
281  (type == Isis::UnsignedWord) || (type == Isis::UnsignedByte)) {
282  p_suffixPixelType = type;
283  }
284  else {
285  QString msg = "Unsupported pixel type [" +
286  Isis::PixelTypeName(type) + "]";
287  throw IException(IException::Programmer, msg, _FILEINFO_);
288  }
289  }
290 
291 
304  void ProcessImport::SetDimensions(const int ns, const int nl, const int nb) {
305  if (ns > 0 && nl > 0 && nb > 0) {
306  p_ns = ns;
307  p_nl = nl;
308  p_nb = nb;
309  }
310  else {
311  QString msg = "Illegal dimension [" + toString(ns) + ", " +
312  toString(nl) + ", " + toString(nb) + "]";
313  throw IException(IException::Programmer, msg, _FILEINFO_);
314  }
315  }
316 
317 
325  p_byteOrder = order;
326  }
327 
328 
349  void ProcessImport::SetFileHeaderBytes(const int bytes) {
350  if (bytes >= 0) {
351  p_fileHeaderBytes = bytes;
352  }
353  else {
354  QString msg = "Illegal file header size [" + toString(bytes) + "]";
355  throw IException(IException::Programmer, msg, _FILEINFO_);
356  }
357  }
358 
359 
379  void ProcessImport::SetFileTrailerBytes(const int bytes) {
380  if (bytes >= 0) {
381  p_fileTrailerBytes = bytes;
382  }
383  else {
384  QString msg = "Illegal file trailer size [" + toString(bytes) + "]";
385  throw IException(IException::Programmer, msg, _FILEINFO_);
386  }
387  }
388 
389 
408  void ProcessImport::SetDataHeaderBytes(const int bytes) {
409  if (bytes >= 0) {
410  p_dataHeaderBytes = bytes;
411  }
412  else {
413  QString msg = "Illegal data header size [" + toString(bytes) + "]";
414  throw IException(IException::Programmer, msg, _FILEINFO_);
415  }
416  }
417 
418 
419  void ProcessImport::SetSuffixOffset(int samples, int lines, int coreBands, int itemBytes) {
420  p_suffixData = samples*lines*coreBands*itemBytes;
421  }
422 
423 
443  void ProcessImport::SetDataTrailerBytes(const int bytes) {
444 
445  if (bytes >= 0) {
446  p_dataTrailerBytes = bytes;
447  }
448  else {
449  QString msg = "Illegal data trailer size [" + toString(bytes) + "]";
450  throw IException(IException::Programmer, msg, _FILEINFO_);
451  }
452  }
453 
454 
473  void ProcessImport::SetDataPrefixBytes(const int bytes) {
474 
475  if (bytes >= 0) {
476  p_dataPreBytes = bytes;
477  }
478  else {
479  QString msg = "Illegal data prefix size [" + toString(bytes) + "]";
480  throw IException(IException::Programmer, msg, _FILEINFO_);
481  }
482  }
483 
484 
503  void ProcessImport::SetDataSuffixBytes(const int bytes) {
504 
505  if (bytes >= 0) {
506  p_dataPostBytes = bytes;
507  }
508  else {
509  QString msg = "Illegal data suffix size [" + toString(bytes) + "]";
510  throw IException(IException::Programmer, msg, _FILEINFO_);
511  }
512  }
513 
514 
533  if (p_fileHeaderBytes == 0) {
534  QString msg = "File header bytes equals 0. There is nothing to save. "
535  "Use SetFileHeaderBytes() first.";
536  throw IException(IException::Programmer, msg, _FILEINFO_);
537  }
538  p_saveFileHeader = true;
539  }
540 
541 
560  if (p_fileTrailerBytes == 0) {
561  QString msg = "File trailer bytes equals 0. There is nothing to save. "
562  "Use SetFileTrailerBytes() first.";
564  _FILEINFO_);
565  }
566  p_saveFileTrailer = true;
567  }
568 
569 
589  if (p_dataHeaderBytes == 0) {
590  QString msg = "Data header bytes equals 0. There is nothing to save. "
591  "Use SetDataHeaderBytes() first.";
593  _FILEINFO_);
594  }
595  p_saveDataHeader = true;
596  }
597 
598 
618  if (p_dataTrailerBytes == 0) {
619  QString msg = "Data trailer bytes equals 0. There is nothing to save. "
620  "Use SetDataTrailerBytes() first.";
622  _FILEINFO_);
623  }
624  p_saveDataTrailer = true;
625  }
626 
627 
646  if (p_dataPreBytes == 0) {
647  QString msg = "Data prefix bytes equals 0. There is nothing to save. "
648  "Use SetDataPrefixBytes() first.";
650  _FILEINFO_);
651  }
652  p_saveDataPre = true;
653  }
654 
655 
675  if (p_dataPostBytes == 0) {
676  QString msg = "Data suffix bytes equals 0. There is nothing to save. "
677  "Use SetDataSuffixBytes() first.";
679  _FILEINFO_);
680  }
681  p_saveDataPost = true;
682  }
683 
684 
689 
690  return p_fileHeaderBytes;
691  }
692 
693 
698  return p_fileTrailerBytes;
699  }
700 
701 
706  return p_dataHeaderBytes;
707  }
708 
709 
714  return p_dataTrailerBytes;
715  }
716 
717 
722  return p_dataPreBytes;
723  }
724 
725 
730 
731  return p_dataPostBytes;
732  }
733 
734 
754  if (p_saveFileHeader) {
755  return p_fileHeader;
756  }
757  QString msg = "File header was not saved. Use SaveFileHeader().";
758  throw IException(IException::Programmer, msg, _FILEINFO_);
759  }
760 
761 
780  if (p_saveFileTrailer) {
781  return p_fileTrailer;
782  }
783  QString msg = "File trailer was not saved. Use SaveFileTrailer()";
784  throw IException(IException::Programmer, msg, _FILEINFO_);
785  }
786 
787 
807  std::vector<char *> ProcessImport::DataHeader() {
808  if (p_saveDataHeader) {
809  return p_dataHeader;
810  }
811  QString msg = "Data header was not saved. Use SaveDataHeader()";
812  throw IException(IException::Programmer, msg, _FILEINFO_);
813  }
814 
815 
835  std::vector<char *> ProcessImport::DataTrailer() {
836  if (p_saveDataTrailer) {
837  return p_dataTrailer;
838  }
839  QString msg = "Data trailer was not saved. Use SaveDataTrailer()";
840  throw IException(IException::Programmer, msg, _FILEINFO_);
841  }
842 
843 
863  std::vector<std::vector<char *> > ProcessImport::DataPrefix() {
864  if (p_saveDataPre) {
865  return p_dataPre;
866  }
867  QString msg = "Data prefix was not saved. Use SaveDataPrefix()";
868  throw IException(IException::Programmer, msg, _FILEINFO_);
869  }
870 
871 
891  std::vector<std::vector<char *> > ProcessImport::DataSuffix() {
892  if (p_saveDataPost) {
893  return p_dataPost;
894  }
895  QString msg = "Data suffix was not saved. Use SaveDataSuffix()";
896  throw IException(IException::Programmer, msg, _FILEINFO_);
897  }
898 
899 
908  p_organization = org;
909  }
910 
911 
919  void ProcessImport::SetVAXConvert(const bool vax_convert) {
920  p_vax_convert = vax_convert;
921  }
922 
923 
929  return p_organization;
930  }
931 
932 
938  void ProcessImport::SetBase(const double base) {
939  p_base.clear();
940  p_base.push_back(base);
941  }
942 
943 
949  void ProcessImport::SetBase(const std::vector<double> base) {
950  p_base = base;
951  }
952 
953 
959  void ProcessImport::SetMultiplier(const double mult) {
960  p_mult.clear();
961  p_mult.push_back(mult);
962  }
963 
964 
970  void ProcessImport::SetMultiplier(const std::vector<double> mult) {
971  p_mult = mult;
972  }
973 
974 
993  void ProcessImport::SetSpecialValues(const double null, const double lrs,
994  const double lis, const double hrs,
995  const double his) {
996  SetNull(null, null);
997  SetLRS(lrs, lrs);
998  SetLIS(lis, lis);
999  SetHRS(hrs, hrs);
1000  SetHIS(his, his);
1001  }
1002 
1003 
1014  void ProcessImport::SetNull(const double null_min, const double null_max) {
1015  CheckPixelRange("Null", null_min, null_max);
1016  p_null_min = null_min;
1017  p_null_max = null_max;
1018  }
1019 
1020 
1031  void ProcessImport::SetLRS(const double lrs_min, const double lrs_max) {
1032  CheckPixelRange("LRS", lrs_min, lrs_max);
1033  p_lrs_min = lrs_min;
1034  p_lrs_max = lrs_max;
1035  }
1036 
1037 
1048  void ProcessImport::SetLIS(const double lis_min, const double lis_max) {
1049  CheckPixelRange("LIS", lis_min, lis_max);
1050  p_lis_min = lis_min;
1051  p_lis_max = lis_max;
1052  }
1053 
1054 
1065  void ProcessImport::SetHRS(const double hrs_min, const double hrs_max) {
1066  CheckPixelRange("HRS", hrs_min, hrs_max);
1067  p_hrs_min = hrs_min;
1068  p_hrs_max = hrs_max;
1069  }
1070 
1071 
1082  void ProcessImport::SetHIS(const double his_min, const double his_max) {
1083  CheckPixelRange("HIS", his_min, his_max);
1084  p_his_min = his_min;
1085  p_his_max = his_max;
1086  }
1087 
1088 
1098  void ProcessImport::CheckPixelRange(QString pixelName, double pixelMin,
1099  double pixelMax) {
1100  if (pixelMin == DBL_MAX || pixelMax == -DBL_MAX) return;
1101 
1102  if (p_null_min != DBL_MAX && p_null_max != -DBL_MAX && ( //-null has been set
1103  (pixelMin > p_null_min && pixelMin < p_null_max) || // --min crossing
1104  (pixelMax > p_null_min && pixelMax < p_null_max) || // --max crossing
1105  (pixelMin < p_null_min && pixelMax > p_null_max))) { // --straddling
1106  // values
1107  QString msg = "The " + pixelName + " range [" + toString(pixelMin) +
1108  "," + toString(pixelMax) + "] overlaps the NULL range [" +
1109  toString(p_null_min) + "," + toString(p_null_max) + "]";
1110  throw IException(IException::User, msg, _FILEINFO_);
1111  }
1112 
1113  if (p_lrs_min != DBL_MAX && p_lrs_max != -DBL_MAX && (
1114  (pixelMin > p_lrs_min && pixelMin < p_lrs_max) ||
1115  (pixelMax > p_lrs_min && pixelMax < p_lrs_max) ||
1116  (pixelMin < p_lrs_min && pixelMax > p_lrs_max))) {
1117  QString msg = "The " + pixelName + " range [" + toString(pixelMin) +
1118  "," + toString(pixelMax) + "] overlaps the LRS range [" +
1119  toString(p_lrs_min) + "," + toString(p_lrs_max) + "]";
1120  throw IException(IException::User, msg, _FILEINFO_);
1121  }
1122 
1123  if (p_lis_min != DBL_MAX && p_lis_max != -DBL_MAX && (
1124  (pixelMin > p_lis_min && pixelMin < p_lis_max) ||
1125  (pixelMax > p_lis_min && pixelMax < p_lis_max) ||
1126  (pixelMin < p_lis_min && pixelMax > p_lis_max))) {
1127  QString msg = "The " + pixelName + " range [" + toString(pixelMin) +
1128  "," + toString(pixelMax) + "] overlaps the LIS range [" +
1129  toString(p_lis_min) + "," + toString(p_lis_max) + "]";
1130  throw IException(IException::User, msg, _FILEINFO_);
1131  }
1132 
1133  if (p_hrs_min != DBL_MAX && p_hrs_max != -DBL_MAX && (
1134  (pixelMin > p_hrs_min && pixelMin < p_hrs_max) ||
1135  (pixelMax > p_hrs_min && pixelMax < p_hrs_max) ||
1136  (pixelMin < p_hrs_min && pixelMax > p_hrs_max))) {
1137  QString msg = "The " + pixelName + " range [" + toString(pixelMin) +
1138  "," + toString(pixelMax) + "] overlaps the HRS range [" +
1139  toString(p_hrs_min) + "," + toString(p_hrs_max) + "]";
1140  throw IException(IException::User, msg, _FILEINFO_);
1141  }
1142 
1143  if (p_his_min != DBL_MAX && p_his_max != -DBL_MAX && (
1144  (pixelMin > p_his_min && pixelMin < p_his_max) ||
1145  (pixelMax > p_his_min && pixelMax < p_his_max) ||
1146  (pixelMin < p_his_min && pixelMax > p_his_max))) {
1147  QString msg = "The " + pixelName + " range [" + toString(pixelMin) +
1148  "," + toString(pixelMax) + "] overlaps the HIS range [" +
1149  toString(p_his_min) + "," + toString(p_his_max) + "]";
1150  throw IException(IException::User, msg, _FILEINFO_);
1151  }
1152 
1153  }
1154 
1155 
1167  double ProcessImport::TestPixel(const double pixel) {
1168  if (pixel <= p_null_max && pixel >= p_null_min) {
1169  return Isis::NULL8;
1170  }
1171  else if (pixel <= p_hrs_max && pixel >= p_hrs_min) {
1172  return Isis::HIGH_REPR_SAT8;
1173  }
1174  else if (pixel <= p_lrs_max && pixel >= p_lrs_min) {
1175  return Isis::LOW_REPR_SAT8;
1176  }
1177  else if (pixel <= p_his_max && pixel >= p_his_min) {
1178  return Isis::HIGH_INSTR_SAT8;
1179  }
1180  else if (pixel <= p_lis_max && pixel >= p_lis_min) {
1181  return Isis::LOW_INSTR_SAT8;
1182  }
1183  else {
1184  return pixel;
1185  }
1186  }
1187 
1188 
1199  if (att.propagateMinimumMaximum()) {
1200  double min, max;
1201  if ((p_pixelType == Isis::Double) ||
1202  (p_pixelType == Isis::Real) ||
1203  (p_base.size() > 1) || (p_mult.size() > 1)) {
1204  min = Isis::VALID_MIN4;
1205  max = Isis::VALID_MAX4;
1206  }
1207  else if (p_pixelType == Isis::SignedInteger) {
1208  min = Isis::IVALID_MIN4;
1209  max = Isis::IVALID_MAX4;
1210  }
1211 
1212  else if (p_pixelType == Isis::UnsignedInteger) {
1213  min = Isis::VALID_MINUI4;
1214  max = Isis::VALID_MAXUI4;
1215  }
1216  else if (p_pixelType == Isis::SignedWord) {
1217  min = Isis::VALID_MIN2 * p_mult[0] + p_base[0];
1218  max = Isis::VALID_MAX2 * p_mult[0] + p_base[0];
1219  }
1220  else if (p_pixelType == Isis::UnsignedWord) {
1221  min = Isis::VALID_MINU2 * p_mult[0] + p_base[0];
1222  max = Isis::VALID_MAXU2 * p_mult[0] + p_base[0];
1223  }
1224  else if (p_pixelType == Isis::UnsignedByte) {
1225  min = Isis::VALID_MIN1 * p_mult[0] + p_base[0];
1226  max = Isis::VALID_MAX1 * p_mult[0] + p_base[0];
1227  }
1228  else {
1229  QString msg = "Unsupported pixel type [" +
1231  throw IException(IException::Programmer, msg, _FILEINFO_);
1232  }
1233  att.setMinimum(min);
1234  att.setMaximum(max);
1235  }
1236 
1237  if (att.propagatePixelType()) {
1238  if ((p_base.size() > 1) || (p_mult.size() > 1)) {
1239  att.setPixelType(Isis::Real);
1240  }
1241  else if (p_pixelType == Isis::Double || p_pixelType == Isis::SignedInteger) {
1242  att.setPixelType(Isis::Real);
1243  }
1244  else {
1246  }
1247  }
1248  }
1249 
1250 
1261  Isis::Cube *ProcessImport::SetOutputCube(const QString &parameter) {
1262  CubeAttributeOutput &att =
1264 
1265  SetAttributes(att);
1266 
1267  return Process::SetOutputCube(Application::GetUserInterface().GetFileName(parameter), att, p_ns, p_nl, p_nb);
1268  }
1269 
1270 
1275  Isis::Cube *ProcessImport::SetOutputCube(const QString &parameter, UserInterface &ui){
1276  CubeAttributeOutput &att = ui.GetOutputAttribute(parameter);
1277  SetAttributes(att);
1278  return Isis::Process::SetOutputCube(ui.GetFileName(parameter), att, p_ns, p_nl, p_nb);
1279  }
1280 
1296  SetAttributes(att);
1297  return Isis::Process::SetOutputCube(fname, att, p_ns, p_nl, p_nb);
1298  }
1299 
1300 
1304  ProcessJp2();
1305  }
1306  else if (p_organization == ProcessImport::BSQ) {
1307  ProcessBsq();
1308  }
1309  else if (p_organization == ProcessImport::BIL) {
1310  ProcessBil();
1311  }
1312  else if (p_organization == ProcessImport::BIP) {
1313  ProcessBip();
1314  }
1315  else {
1316  QString msg = "File [" + p_inFile
1317  + "] is not in a supported organization.";
1318  throw IException(IException::Programmer, msg, _FILEINFO_);
1319  }
1320  }
1321 
1322 
1334  ProcessJp2(funct);
1335  }
1336  else if (p_organization == ProcessImport::BSQ) {
1337  ProcessBsq(funct);
1338  }
1339  else if (p_organization == ProcessImport::BIL) {
1340  ProcessBil(funct);
1341  }
1342  else if (p_organization == ProcessImport::BIP) {
1343  ProcessBip(funct);
1344  }
1345  else {
1346  QString msg = "File [" + p_inFile + "] is not in a supported organization.";
1347  throw IException(IException::Programmer, msg, _FILEINFO_);
1348  }
1349  }
1350 
1351 
1363  void ProcessImport::ProcessBsq(void funct(Isis::Buffer &out)) {
1364  // Figure out the number of bytes to read for a single line
1365  int readBytes = Isis::SizeOf(p_pixelType);
1366  readBytes = readBytes * p_ns;
1367  char *in = new char [readBytes];
1368 
1369  // Set up an Isis::EndianSwapper object
1370  QString tok(Isis::ByteOrderName(p_byteOrder));
1371  tok = tok.toUpper();
1372  Isis::EndianSwapper swapper(tok);
1373 
1374  ifstream fin;
1375  // Open input file
1376  Isis::FileName inFile(p_inFile);
1377  QString inFileName(inFile.expanded());
1378  fin.open(inFileName.toLatin1().data(), ios::in | ios::binary);
1379  if (!fin.is_open()) {
1380  QString msg = "Cannot open input file [" + p_inFile + "]";
1381  throw IException(IException::Io, msg, _FILEINFO_);
1382  }
1383 
1384  // Handle the file header
1385  streampos pos = fin.tellg();
1386  if (p_saveFileHeader) {
1387  p_fileHeader = new char[p_fileHeaderBytes];
1388  fin.read(p_fileHeader, p_fileHeaderBytes);
1389  fin.seekg(p_suffixData+p_fileHeaderBytes, ios_base::beg);
1390  }
1391  else {
1392  fin.seekg(p_fileHeaderBytes+p_suffixData, ios_base::beg);
1393  }
1394 
1395  // Check the last io
1396  if (!fin.good()) {
1397  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1398  toString((int)pos) + "]. Byte count [" +
1399  toString(p_fileHeaderBytes) + "]" ;
1400  throw IException(IException::Io, msg, _FILEINFO_);
1401  }
1402 
1403  // Construct a line buffer manager
1404  Isis::Buffer *out = NULL;
1405 
1406  if (funct != NULL) {
1407  out = new Isis::Brick(p_ns, 1, 1, p_pixelType);
1408  }
1409  else {
1410  out = new Isis::LineManager(*OutputCubes[0]);
1411  }
1412 
1413  // Loop once for each band in the image
1416 
1417  // Loop for each band
1418  for(int band = 0; band < p_nb; band++) {
1419  // Set the base multiplier
1420  double base, mult;
1421  if (p_base.size() > 1) {
1422  base = p_base[band];
1423  mult = p_mult[band];
1424  }
1425  else {
1426  base = p_base[0];
1427  mult = p_mult[0];
1428  }
1429 
1430  // Handle any data headers (e.g., the data at the beginning of each band)
1431  pos = fin.tellg();
1432  if (p_saveDataHeader) {
1433  p_dataHeader.push_back(new char[p_dataHeaderBytes]);
1434  fin.read(p_dataHeader.back(), p_dataHeaderBytes);
1435  }
1436  else {
1437  fin.seekg(p_dataHeaderBytes, ios_base::cur);
1438  }
1439 
1440  // Check the last io
1441  if (!fin.good()) {
1442  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1443  toString((int)pos) + "]. Byte count [" +
1444  toString(p_dataHeaderBytes) + "]" ;
1445  throw IException(IException::Io, msg, _FILEINFO_);
1446  }
1447 
1448  // Space for storing prefix and suffix data pointers
1449  vector<char *> tempPre, tempPost;
1450 
1451  // Loop for each line in a band
1452  for(int line = 0; line < p_nl; line++) {
1453 
1454  // Handle any line prefix bytes
1455  pos = fin.tellg();
1456  if (p_saveDataPre) {
1457  tempPre.push_back(new char[p_dataPreBytes]);
1458  fin.read(tempPre.back(), p_dataPreBytes);
1459  }
1460  else {
1461  fin.seekg(p_dataPreBytes, ios_base::cur);
1462  }
1463 
1464  // Check the last io
1465  if (!fin.good()) {
1466  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1467  toString((int)pos) + "]. Byte count [" +
1468  toString(p_dataPreBytes) + "]" ;
1469  throw IException(IException::Io, msg, _FILEINFO_);
1470  }
1471 
1472  // Get a line of data from the input file
1473  pos = fin.tellg();
1474  fin.read(in, readBytes);
1475  if (!fin.good()) {
1476  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1477  toString((int)pos) + "]. Byte count [" +
1478  toString(readBytes) + "]" ;
1479  throw IException(IException::Io, msg, _FILEINFO_);
1480  }
1481 
1482  // Swap the bytes if necessary and convert any out of bounds pixels
1483  // to special pixels
1484  for(int samp = 0; samp < p_ns; samp++) {
1485  switch(p_pixelType) {
1486  case Isis::UnsignedByte:
1487  (*out)[samp] = (double)((unsigned char *)in)[samp];
1488  break;
1489  case Isis::UnsignedWord:
1490  (*out)[samp] =
1491  (double)swapper.UnsignedShortInt((unsigned short int *)in+samp);
1492  break;
1493  case Isis::SignedWord:
1494  (*out)[samp] = (double)swapper.ShortInt((short int *)in+samp);
1495  break;
1496  case Isis::SignedInteger:
1497  (*out)[samp] = (double)swapper.Int((int *)in+samp);
1498  break;
1499 
1500  case Isis::UnsignedInteger:
1501  (*out)[samp] = (double)swapper.Uint32_t((unsigned int *)in+samp);
1502  break;
1503  case Isis::Real:
1504  if(p_vax_convert) {
1505  (*out)[samp]= VAXConversion( (float *)in+samp );
1506  }
1507  else {
1508  (*out)[samp] = (double)swapper.Float((float *)in+samp);
1509  }
1510  break;
1511  case Isis::Double:
1512  (*out)[samp] = (double)swapper.Double((double *)in+samp);
1513  break;
1514  default:
1515  break;
1516  }
1517 
1518  (*out)[samp] = TestPixel((*out)[samp]);
1519 
1520  if (Isis::IsValidPixel((*out)[samp])) {
1521  (*out)[samp] = mult * ((*out)[samp]) + base;
1522  }
1523  } // End sample loop
1524 
1525  if (funct == NULL) {
1526  // Set the buffer position and write the line to the output file
1527  ((Isis::LineManager *)out)->SetLine((band * p_nl) + line + 1);
1528  OutputCubes[0]->write(*out);
1529  }
1530  else {
1531  ((Isis::Brick *)out)->SetBaseSample(1);
1532  ((Isis::Brick *)out)->SetBaseLine(line + 1);
1533  ((Isis::Brick *)out)->SetBaseBand(band + 1);
1534  funct(*out);
1535  }
1536 
1538 
1539  // Handle any line suffix bytes
1540  pos = fin.tellg();
1541  if (p_saveDataPost) {
1542  tempPost.push_back(new char[p_dataPostBytes]);
1543  fin.read(tempPost.back(), p_dataPostBytes);
1544  }
1545  else {
1546  fin.seekg(p_dataPostBytes, ios_base::cur);
1547  }
1548 
1549  // Check the last io
1550  if (!fin.good()) {
1551  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1552  toString((int)pos) + "]. Byte count [" +
1553  toString(p_dataPreBytes) + "]" ;
1554  throw IException(IException::Io, msg, _FILEINFO_);
1555  }
1556  } // End line loop
1557 
1558  // Save off the prefix bytes vector
1559  if (p_saveDataPre) {
1560  p_dataPre.push_back(tempPre);
1561  tempPre.clear();
1562  }
1563 
1564  // Save off the suffix bytes vector
1565  if (p_saveDataPost) {
1566  p_dataPost.push_back(tempPost);
1567  tempPost.clear();
1568  }
1569 
1570  // Handle the band trailer
1571  pos = fin.tellg();
1572  if (p_saveDataTrailer) {
1573  p_dataTrailer.push_back(new char[p_dataTrailerBytes]);
1574  fin.read(p_dataTrailer.back(), p_dataTrailerBytes);
1575  }
1576  else {
1577  fin.seekg(p_dataTrailerBytes, ios_base::cur);
1578  }
1579 
1580  // Check the last io
1581  if (!fin.good()) {
1582  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1583  toString((int)pos) + "]. Byte count [" +
1584  toString(p_fileHeaderBytes) + "]" ;
1585  throw IException(IException::Io, msg, _FILEINFO_);
1586  }
1587 
1588  } // End band loop
1589 
1590  // Handle the file trailer
1591  pos = fin.tellg();
1592  if (p_saveFileTrailer) {
1593  fin.seekg(0, ios_base::end);
1594  streampos e = fin.tellg();
1595  p_fileTrailerBytes = (int)(e - pos + (streampos)1);
1596  p_fileTrailer = new char[p_fileTrailerBytes];
1597  fin.seekg(pos);
1598  fin.read(p_fileTrailer, p_fileTrailerBytes);
1599 
1600  // Check the io
1601  if (!fin.good()) {
1602  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1603  toString((int)pos) + "]. Byte count [" +
1604  toString(p_fileTrailerBytes) + "]" ;
1605  throw IException(IException::Io, msg, _FILEINFO_);
1606  }
1607 
1608  }
1609 
1610  // Close the file and clean up
1611  fin.close();
1612  delete [] in;
1613  }
1614 
1615 
1626  void ProcessImport::ProcessBil(void funct(Isis::Buffer &someBuf)) {
1627 
1628  // Figure out the number of bytes to read for a single line
1629  int readBytes = Isis::SizeOf(p_pixelType);
1630  readBytes = readBytes * p_ns;
1631  char *in = new char [readBytes];
1632 
1633  // Set up an Isis::EndianSwapper object
1634  QString tok(Isis::ByteOrderName(p_byteOrder));
1635  tok = tok.toUpper();
1636  Isis::EndianSwapper swapper(tok);
1637 
1638  ifstream fin;
1639  // Open input file
1640  Isis::FileName inFile(p_inFile);
1641  QString inFileName(inFile.expanded());
1642  fin.open(inFileName.toLatin1().data(), ios::in | ios::binary);
1643  if (!fin.is_open()) {
1644  QString msg = "Cannot open input file [" + p_inFile + "]";
1645  throw IException(IException::Io, msg, _FILEINFO_);
1646  }
1647 
1648  // Handle the file header
1649  streampos pos = fin.tellg();
1650 
1651  if (p_saveFileHeader) {
1652  p_fileHeader = new char[p_fileHeaderBytes];
1653  fin.read(p_fileHeader, p_fileHeaderBytes);
1654  fin.seekg(p_suffixData+p_fileHeaderBytes, ios_base::beg);
1655  }
1656  else {
1657  fin.seekg(p_fileHeaderBytes+p_suffixData, ios_base::beg);
1658  }
1659 
1660  // Check the last io
1661  if (!fin.good()) {
1662  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1663  toString((int)pos) + "]. Byte count [" +
1664  toString(p_fileHeaderBytes) + "]" ;
1665  throw IException(IException::Io, msg, _FILEINFO_);
1666  }
1667 
1668  // Construct a line buffer manager
1669  Isis::Buffer *out = NULL;
1670 
1671  if (funct != NULL) {
1672  out = new Isis::Brick(p_ns, p_nl, p_nb, p_ns, 1, 1, p_pixelType, true);
1673  ((Isis::Brick *)out)->setpos(0);
1674  }
1675  else {
1676  OutputCubes[0]->addCachingAlgorithm(new BoxcarCachingAlgorithm());
1677  out = new Isis::LineManager(*OutputCubes[0]);
1678  }
1679 
1680  // Loop once for each line in the image
1683 
1684  // Loop for each line
1685  for(int line = 0; line < p_nl; line++) {
1686  // Loop for each band
1687  for(int band = 0; band < p_nb; band++) {
1688  // Set the base multiplier
1689  double base, mult;
1690  if (p_base.size() > 1) {
1691  base = p_base[band];
1692  mult = p_mult[band];
1693  }
1694  else {
1695  base = p_base[0];
1696  mult = p_mult[0];
1697  }
1698 
1699  // Check the last io
1700  if (!fin.good()) {
1701  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1702  toString((int)pos) + "]. Byte count [" +
1703  toString(p_dataHeaderBytes) + "]" ;
1704  throw IException(IException::Io, msg, _FILEINFO_);
1705  }
1706 
1707  // Space for storing prefix and suffix data pointers
1708  vector<char *> tempPre, tempPost;
1709 
1710  // Handle any line prefix bytes
1711  pos = fin.tellg();
1712  if (p_saveDataPre) {
1713  tempPre.push_back(new char[p_dataPreBytes]);
1714  fin.read(tempPre.back(), p_dataPreBytes);
1715  }
1716  else {
1717  fin.seekg(p_dataPreBytes, ios_base::cur);
1718  }
1719 
1720  // Check the last io
1721  if (!fin.good()) {
1722  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1723  toString((int)pos) + "]. Byte count [" +
1724  toString(p_dataPreBytes) + "]" ;
1725  throw IException(IException::Io, msg, _FILEINFO_);
1726  }
1727 
1728 
1729  // Get a line of data from the input file
1730  pos = fin.tellg();
1731  fin.read(in, readBytes);
1732  if (!fin.good()) {
1733  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1734  toString((int)pos) + "]. Byte count [" +
1735  toString(readBytes) + "]" ;
1736  throw IException(IException::Io, msg, _FILEINFO_);
1737  }
1738 
1739  // Swap the bytes if necessary and convert any out of bounds pixels
1740  // to special pixels
1741  for(int samp = 0; samp < p_ns; samp++) {
1742  switch(p_pixelType) {
1743  case Isis::UnsignedByte:
1744  (*out)[samp] = (double)((unsigned char *)in)[samp];
1745  break;
1746  case Isis::UnsignedWord:
1747  (*out)[samp] =
1748  (double)swapper.UnsignedShortInt((unsigned short int *)in+samp);
1749  break;
1750  case Isis::SignedWord:
1751  (*out)[samp] = (double)swapper.ShortInt((short int *)in+samp);
1752  break;
1753  case Isis::SignedInteger:
1754  (*out)[samp] = (double)swapper.Int((int *)in+samp);
1755  break;
1756  case Isis::UnsignedInteger:
1757  (*out)[samp] = (double)swapper.Uint32_t((unsigned int *)in+samp);
1758  break;
1759  case Isis::Real:
1760  if(p_vax_convert) {
1761  (*out)[samp]= VAXConversion( (float *)in+samp );
1762  }
1763  else {
1764  (*out)[samp] = (double)swapper.Float((float *)in+samp);
1765  }
1766  break;
1767  case Isis::Double:
1768  (*out)[samp] = (double)swapper.Double((double *)in+samp);
1769  break;
1770  default:
1771  break;
1772  }
1773 
1774  // Sets out to isis special pixel or leaves it if valid
1775  (*out)[samp] = TestPixel((*out)[samp]);
1776 
1777  if (Isis::IsValidPixel((*out)[samp])) {
1778  (*out)[samp] = mult * ((*out)[samp]) + base;
1779  }
1780  } // End sample loop
1781 
1782  if (funct == NULL) {
1783  ((Isis::LineManager *)out)->SetLine((band * p_nl) + line + 1);
1784  OutputCubes[0]->write(*out);
1785  }
1786  else {
1787  funct(*out);
1788  (*((Isis::Brick *)out))++;
1789  }
1790 
1792 
1793  // Handle any line suffix bytes
1794  pos = fin.tellg();
1795  if (p_saveDataPost) {
1796  tempPost.push_back(new char[p_dataPostBytes]);
1797  fin.read(tempPost.back(), p_dataPostBytes);
1798  }
1799  else {
1800  fin.seekg(p_dataPostBytes, ios_base::cur);
1801  }
1802 
1803  // Check the last io
1804  if (!fin.good()) {
1805  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1806  toString((int)pos) + "]. Byte count [" +
1807  toString(p_dataPreBytes) + "]" ;
1808  throw IException(IException::Io, msg, _FILEINFO_);
1809  }
1810 
1811  // Save off the prefix bytes vector
1812  if (p_saveDataPre) {
1813  p_dataPre.push_back(tempPre);
1814  tempPre.clear();
1815  }
1816 
1817  // Save off the suffix bytes vector
1818  if (p_saveDataPost) {
1819  p_dataPost.push_back(tempPost);
1820  tempPost.clear();
1821  }
1822 
1823  // Check the last io
1824  if (!fin.good()) {
1825  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1826  toString((int)pos) + "]. Byte count [" +
1827  toString(p_fileHeaderBytes) + "]" ;
1828  throw IException(IException::Io, msg, _FILEINFO_);
1829  }
1830 
1831  } // End band loop
1832 
1833  } // End line loop
1834 
1835  // Handle the file trailer
1836  pos = fin.tellg();
1837  if (p_saveFileTrailer) {
1838  fin.seekg(0, ios_base::end);
1839  streampos e = fin.tellg();
1840  p_fileTrailerBytes = (int)(e - pos + (streampos)1);
1841  p_fileTrailer = new char[p_fileTrailerBytes];
1842  fin.seekg(pos);
1843  fin.read(p_fileTrailer, p_fileTrailerBytes);
1844 
1845  // Check the io
1846  if (!fin.good()) {
1847  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1848  toString((int)pos) + "]. Byte count [" +
1849  toString(p_fileTrailerBytes) + "]" ;
1850  throw IException(IException::Io, msg, _FILEINFO_);
1851  }
1852 
1853  }
1854 
1855  // Close the file and clean up
1856  fin.close();
1857  delete [] in;
1858  }
1859 
1860 
1871  void ProcessImport::ProcessBip(void funct(Isis::Buffer &out)) {
1872 
1873  // Set up an Isis::EndianSwapper object
1874  QString tok(Isis::ByteOrderName(p_byteOrder));
1875  tok = tok.toUpper();
1876  Isis::EndianSwapper swapper(tok);
1877 
1878  ifstream fin;
1879  // Open input file
1880  Isis::FileName inFile(p_inFile);
1881  QString inFileName(inFile.expanded());
1882  fin.open(inFileName.toLatin1().data(), ios::in | ios::binary);
1883  if (!fin.is_open()) {
1884  QString msg = "Cannot open input file [" + p_inFile + "]";
1885  throw IException(IException::Io, msg, _FILEINFO_);
1886  }
1887 
1888  // Handle the file header
1889  streampos pos = fin.tellg();
1890  if (p_saveFileHeader) {
1891  p_fileHeader = new char[p_fileHeaderBytes];
1892  fin.read(p_fileHeader, p_fileHeaderBytes);
1893  fin.seekg(p_suffixData+p_fileHeaderBytes, ios_base::beg);
1894  }
1895  else {
1896  fin.seekg(p_fileHeaderBytes+p_suffixData, ios_base::beg);
1897  }
1898 
1899  // Check the last io
1900  if (!fin.good()) {
1901  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1902  toString((int)pos) + "]. Byte count [" +
1903  toString(p_fileHeaderBytes) + "]" ;
1904  throw IException(IException::Io, msg, _FILEINFO_);
1905  }
1906 
1907  OutputCubes[0]->addCachingAlgorithm(new BoxcarCachingAlgorithm());
1908 
1909  // Construct a line buffer manager
1910  Isis::Buffer *out = NULL;
1911 
1912  if (funct != NULL) {
1913  out = new Isis::Buffer(p_ns, p_nl, p_nb, p_pixelType);
1914  }
1915  else {
1916  out = new Isis::LineManager(*OutputCubes[0]);
1917  }
1918 
1919  // Loop once for each line in the image
1922 
1923  // Figure out the number of bytes to read for a single line
1924  int sampleBytes = Isis::SizeOf(p_pixelType) * p_nb + p_dataPreBytes + p_dataPostBytes;
1925  int readBytes = p_ns * sampleBytes;
1926  char *in = new char [readBytes];
1927 
1928  // Loop for each line
1929  for(int line = 0; line < p_nl; line++) {
1930  // Check the last io
1931  if (!fin.good()) {
1932  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1933  toString((int)pos) + "]. Byte count [" +
1934  toString(p_dataHeaderBytes) + "]" ;
1935  throw IException(IException::Io, msg, _FILEINFO_);
1936  }
1937 
1938  // Space for storing prefix and suffix data pointers
1939  vector<char *> tempPre, tempPost;
1940 
1941  // Check the last io
1942  if (!fin.good()) {
1943  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1944  toString((int)pos) + "]. Byte count [" +
1945  toString(p_dataPreBytes) + "]" ;
1946  throw IException(IException::Io, msg, _FILEINFO_);
1947  }
1948 
1949  // Get a line of data from the input file
1950  pos = fin.tellg();
1951  fin.read(in, readBytes);
1952  if (!fin.good()) {
1953  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
1954  toString((int)pos) + "]. Byte count [" +
1955  toString(readBytes) + "]" ;
1956  throw IException(IException::Io, msg, _FILEINFO_);
1957  }
1958 
1959  // Loop for each band
1960  for(int band = 0; band < p_nb; band++) {
1961  // Set the base multiplier
1962  double base, mult;
1963  if (p_base.size() > 1) {
1964  base = p_base[band];
1965  mult = p_mult[band];
1966  }
1967  else {
1968  base = p_base[0];
1969  mult = p_mult[0];
1970  }
1971 
1972  // Swap the bytes if necessary and convert any out of bounds pixels
1973  // to special pixels
1974  int osamp = 0;
1975 
1976  for(int samp = 0; samp < p_ns; samp++) {
1977  int bufferIndex = p_dataPreBytes + Isis::SizeOf(p_pixelType)*band + samp*sampleBytes;
1978  switch(p_pixelType) {
1979  case Isis::UnsignedByte:
1980  (*out)[osamp] = (double)((unsigned char *)in)[bufferIndex];
1981  break;
1982  case Isis::UnsignedWord:
1983  (*out)[osamp] =
1984  (double)swapper.UnsignedShortInt(&in[bufferIndex]);
1985  break;
1986  case Isis::SignedWord:
1987  (*out)[osamp] = (double)swapper.ShortInt(&in[bufferIndex]);
1988  break;
1989  case Isis::SignedInteger:
1990  (*out)[samp] = (double)swapper.Int(&in[bufferIndex]);
1991  break;
1992  case Isis::UnsignedInteger:
1993  (*out)[samp] = (double)swapper.Uint32_t(&in[bufferIndex]);
1994  break;
1995  case Isis::Real:
1996  if(p_vax_convert) {
1997  (*out)[osamp]= VAXConversion(&in[bufferIndex]);
1998  }
1999  else {
2000  (*out)[osamp] = (double)swapper.Float(&in[bufferIndex]);
2001  }
2002  break;
2003  case Isis::Double:
2004  (*out)[osamp] = (double)swapper.Double(&in[bufferIndex]);
2005  break;
2006  default:
2007  break;
2008  }
2009 
2010  // Sets out to isis special pixel or leaves it if valid
2011  (*out)[osamp] = TestPixel((*out)[osamp]);
2012 
2013  if (Isis::IsValidPixel((*out)[osamp])) {
2014  (*out)[osamp] = mult * ((*out)[osamp]) + base;
2015  }
2016  osamp++;
2017  } // End sample loop
2018 
2019  if (funct == NULL) {
2020  //Set the buffer position and write the line to the output file
2021  ((Isis::LineManager *)out)->SetLine((band * p_nl) + line + 1);
2022  OutputCubes[0]->write(*out);
2023  }
2024  else {
2025  funct(*out);
2026  }
2027 
2028  } // End band loop
2029 
2030  // Handle record prefix and suffix
2031  if (p_saveDataPre) {
2032  for(int samp = 0; samp < p_ns; samp++) {
2033  char *samplePrefix = new char[p_dataPreBytes];
2034  memcpy(samplePrefix, &in[samp*sampleBytes], p_dataPreBytes);
2035  tempPre.push_back(samplePrefix);
2036  }
2037  p_dataPre.push_back(tempPre);
2038  tempPre.clear();
2039  }
2040  if (p_saveDataPost) {
2041  for(int samp = 0; samp < p_ns; samp++) {
2042  char *sampleSuffix = new char[p_dataPostBytes];
2043  int suffixIndex = p_dataPreBytes + Isis::SizeOf(p_pixelType)*p_nb + samp*sampleBytes;
2044  memcpy(sampleSuffix, &in[suffixIndex], p_dataPostBytes);
2045  tempPost.push_back(sampleSuffix);
2046  }
2047  p_dataPost.push_back(tempPost);
2048  tempPost.clear();
2049  }
2050 
2051  // Check the last io
2052  if (!fin.good()) {
2053  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
2054  toString((int)pos) + "]. Byte count [" +
2055  toString(p_dataPreBytes) + "]" ;
2056  throw IException(IException::Io, msg, _FILEINFO_);
2057  }
2058 
2059  // Handle the data trailer
2060  pos = fin.tellg();
2061  if (p_saveDataTrailer) {
2062  p_dataTrailer.push_back(new char[p_dataTrailerBytes]);
2063  fin.read(p_dataTrailer.back(), p_dataTrailerBytes);
2064  }
2065  else {
2066  fin.seekg(p_dataTrailerBytes, ios_base::cur);
2067  }
2068 
2069  // Check the last io
2070  if (!fin.good()) {
2071  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
2072  toString((int)pos) + "]. Byte count [" +
2073  toString(p_fileHeaderBytes) + "]" ;
2074  throw IException(IException::Io, msg, _FILEINFO_);
2075  }
2076 
2078 
2079  } // End line loop
2080 
2081  // Handle the file trailer
2082  pos = fin.tellg();
2083  if (p_saveFileTrailer) {
2084  fin.seekg(0, ios_base::end);
2085  streampos e = fin.tellg();
2086  p_fileTrailerBytes = (int)(e - pos + (streampos)1);
2087  p_fileTrailer = new char[p_fileTrailerBytes];
2088  fin.seekg(pos);
2089  fin.read(p_fileTrailer, p_fileTrailerBytes);
2090 
2091  // Check the io
2092  if (!fin.good()) {
2093  QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
2094  toString((int)pos) + "]. Byte count [" +
2095  toString(p_fileTrailerBytes) + "]" ;
2096  throw IException(IException::Io, msg, _FILEINFO_);
2097  }
2098 
2099  }
2100 
2101  // Close the file and clean up
2102  fin.close();
2103  delete [] in;
2104 
2105  }
2106 
2107 
2123  void ProcessImport::ProcessJp2(void funct(Isis::Buffer &out)) {
2124 
2125  // Set up an Isis::Jp2Decoder object
2126  JP2Decoder *JP2_decoder;
2127  JP2_decoder = new JP2Decoder(p_inFile);
2128 
2129  // Open JP2 file
2130  JP2_decoder->OpenFile();
2131 
2132  // Make sure JP2 file dimensions match PDS labels
2133  p_ns = JP2_decoder->GetSampleDimension();
2134  p_nl = JP2_decoder->GetLineDimension();
2135  p_nb = JP2_decoder->GetBandDimension();
2136 
2137  // Figure out the number of bytes to read for a single line
2138  // from all bands
2139  int sizeofpixel = Isis::SizeOf(p_pixelType);
2140  int startsamp = p_dataPreBytes / sizeofpixel;
2141  int endsamp = startsamp + p_ns;
2142  int readBytes = sizeofpixel * p_ns * p_nb
2144  char **in = new char* [p_nb];
2145  for(int i = 0; i < p_nb; i++) {
2146  in[i] = new char [readBytes];
2147  }
2148 
2149  // Construct a line buffer manager
2150  Isis::Buffer *out = NULL;
2151 
2152  if (funct != NULL) {
2153  out = new Isis::Buffer(p_ns, p_nl, p_nb, p_pixelType);
2154  }
2155  else {
2156  out = new Isis::LineManager(*OutputCubes[0]);
2157  }
2158 
2159  // Loop once for each line in the image
2162 
2163  // Loop for each line
2164  for(int line = 0; line < p_nl; line++) {
2165  if (p_pixelType == Isis::UnsignedByte) {
2166  JP2_decoder->Read((unsigned char **)in);
2167  }
2168  else {
2169  JP2_decoder->Read((short int **)in);
2170  }
2171  // Loop for each band
2172  for(int band = 0; band < p_nb; band++) {
2173  // Set the base multiplier
2174  double base, mult;
2175  if (p_base.size() > 1) {
2176  base = p_base[band];
2177  mult = p_mult[band];
2178  }
2179  else {
2180  base = p_base[0];
2181  mult = p_mult[0];
2182  }
2183 
2184  // Space for storing prefix and suffix data pointers
2185  vector<char *> tempPre, tempPost;
2186 
2187 
2188  // Handle any line prefix bytes
2189  if (p_saveDataPre) {
2190  tempPre.push_back(new char[p_dataPreBytes]);
2191  memcpy(&tempPre[0], in[band], p_dataPreBytes);
2192  }
2193 
2194  // Swap the bytes if necessary and convert any out of bounds pixels
2195  // to special pixels
2196  for(int samp = startsamp; samp < endsamp; samp++) {
2197  switch(p_pixelType) {
2198  case Isis::UnsignedByte:
2199  (*out)[samp] = (double)((unsigned char *)in[band])[samp];
2200  break;
2201  case Isis::UnsignedWord:
2202  (*out)[samp] = (double)((unsigned short int *)in[band])[samp];
2203  break;
2204  case Isis::SignedWord:
2205  (*out)[samp] = (double)((short int *)in[band])[samp];
2206  break;
2207  default:
2208  break;
2209  }
2210 
2211  // Sets out to isis special pixel or leaves it if valid
2212  (*out)[samp] = TestPixel((*out)[samp]);
2213 
2214  if (Isis::IsValidPixel((*out)[samp])) {
2215  (*out)[samp] = mult * ((*out)[samp]) + base;
2216  }
2217  } // End sample loop
2218 
2219  if (funct == NULL) {
2220  //Set the buffer position and write the line to the output file
2221  ((Isis::LineManager *)out)->SetLine((band * p_nl) + line + 1);
2222  OutputCubes[0]->write(*out);
2223  }
2224  else {
2225  funct(*out);
2226  }
2227 
2229 
2230  // Handle any line suffix bytes
2231  if (p_saveDataPost) {
2232  tempPost.push_back(new char[p_dataPostBytes]);
2233  memcpy(&tempPost[0], &in[band][p_dataPreBytes+p_ns*sizeofpixel],
2234  p_dataPostBytes);
2235  }
2236 
2237  // Save off the prefix bytes vector
2238  if (p_saveDataPre) {
2239  p_dataPre.push_back(tempPre);
2240  tempPre.clear();
2241  }
2242 
2243  // Save off the suffix bytes vector
2244  if (p_saveDataPost) {
2245  p_dataPost.push_back(tempPost);
2246  tempPost.clear();
2247  }
2248 
2249  } // End band loop
2250 
2251  } // End line loop
2252 
2253  // Close the file and clean up
2254  delete JP2_decoder;
2255  delete [] in;
2256  }
2257 
2258 
2259 #if 0
2260 
2267  void ProcessImport::AddLabel(Isis::Pvl &label) {
2268 
2269  label.Root();
2270 
2271  Isis::Pvl *output = OutputCubes[0]->Label();
2272  output->Find("IsisCube");
2273  output->Insert(label);
2274  }
2275 
2282  void ProcessImport::AddImportLabel(Isis::Pvl &importLab) {
2283 
2284  importLab.Root();
2285 
2286  Isis::Pvl *output = OutputCubes[0]->Label();
2287  output->Find("IsisCube");
2288  output->addObject("ImportLabel");
2289  output->Insert(importLab);
2290  }
2291 #endif
2292 
2293 
2302  void ProcessImport::SetInputFile(const QString &file) {
2303  p_inFile = file;
2304  if (!Isis::FileName(file).fileExists()) {
2305  QString msg = "File [" + file + "] does not exist";
2306  throw IException(IException::User, msg, _FILEINFO_);
2307  }
2308  }
2309 
2310 
2320  if (p_inFile.size() <= 0) {
2321  QString msg = "No input file has been set";
2322  throw IException(IException::Programmer, msg, _FILEINFO_);
2323  }
2324  return p_inFile;
2325  }
2326 
2327 }
Isis::EndianSwapper::Float
float Float(void *buf)
Swaps a floating point value.
Definition: EndianSwapper.cpp:78
Isis::EndianSwapper::UnsignedShortInt
unsigned short int UnsignedShortInt(void *buf)
Swaps an unsigned short integer value.
Definition: EndianSwapper.cpp:197
Isis::ProcessImport::DataHeader
std::vector< char * > DataHeader()
This method returns a pointer to the data header.
Definition: ProcessImport.cpp:807
Isis::SizeOf
int SizeOf(Isis::PixelType pixelType)
Returns the number of bytes of the specified PixelType.
Definition: PixelType.h:46
Isis::ProcessImport::p_mult
std::vector< double > p_mult
An array containing the core multiplier for each band.
Definition: ProcessImport.h:395
IsisAml::GetOutputAttribute
Isis::CubeAttributeOutput & GetOutputAttribute(const QString &paramName)
Gets the attributes for an output cube.
Definition: IsisAml.cpp:1919
Isis::ProcessImport::SetDataPrefixBytes
void SetDataPrefixBytes(const int bytes)
This method sets the number of bytes at the beginning of each data record of a file.
Definition: ProcessImport.cpp:473
Isis::ProcessImport::SetLIS
void SetLIS(const double lis_min, const double lis_max)
Sets the range that will be considered Isis::Null.
Definition: ProcessImport.cpp:1048
Isis::ProcessImport::SetDataHeaderBytes
void SetDataHeaderBytes(const int bytes)
This method sets the number of bytes in the header of each datablock of a file.
Definition: ProcessImport.cpp:408
Isis::ProcessImport::IsVAXSpecial
bool IsVAXSpecial(unsigned int *vax, VAXSpecialPixel pix)
Determines if the VAX encoded pixel value is special or not.
Definition: ProcessImport.cpp:118
Isis::ProcessImport::p_lrs_min
double p_lrs_min
The pixel value which is the lower bound of LRS data.
Definition: ProcessImport.h:424
Isis::CubeAttributeOutput::setMaximum
void setMaximum(double max)
Set the output cube attribute maximum.
Definition: CubeAttribute.cpp:342
Isis::IException::Io
@ Io
A type of error that occurred when performing an actual I/O operation.
Definition: IException.h:155
Isis::LineManager
Buffer manager, for moving through a cube in lines.
Definition: LineManager.h:39
Isis::ProcessImport::ProcessBsq
void ProcessBsq(void funct(Isis::Buffer &out)=NULL)
Process the import data as a band sequential file.
Definition: ProcessImport.cpp:1363
Isis::ProcessImport::p_suffixPixelType
Isis::PixelType p_suffixPixelType
The pixel type of the suffix data.
Definition: ProcessImport.h:331
Isis::JP2Decoder::OpenFile
void OpenFile()
Open the JPEG2000 file.
Definition: JP2Decoder.cpp:52
Isis::CubeAttributeOutput::setPixelType
void setPixelType(PixelType type)
Set the pixel type to that given by the parameter.
Definition: CubeAttribute.cpp:390
Isis::Progress::CheckStatus
void CheckStatus()
Checks and updates the status.
Definition: Progress.cpp:105
Isis::BoxcarCachingAlgorithm
This algorithm is designed for applications that jump around between a couple of spots in the cube wi...
Definition: BoxcarCachingAlgorithm.h:32
Isis::ProcessImport::p_null_max
double p_null_max
The pixel value which is the upper bound of NULL data.
Definition: ProcessImport.h:404
Isis::ProcessImport::p_dataPreBytes
int p_dataPreBytes
Number of bytes of non-image data preceding each data record, such as line prefix data in a band sequ...
Definition: ProcessImport.h:357
Isis::ProcessImport::p_lis_max
double p_lis_max
The pixel value which is the upper bound of LIS data.
Definition: ProcessImport.h:436
Isis::ProcessImport::SetBase
void SetBase(const double base)
Sets the core base of the input cube.
Definition: ProcessImport.cpp:938
Isis::ProcessImport::ProcessBip
void ProcessBip(void funct(Isis::Buffer &out)=NULL)
Function to process files stored as Band Interleaved by Pixel.
Definition: ProcessImport.cpp:1871
Isis::ProcessImport::InputFile
QString InputFile()
Sets the name of the input file to be read in the import StartProcess method and verifies its existan...
Definition: ProcessImport.cpp:2319
Isis::ProcessImport::SetVAXConvert
void SetVAXConvert(const bool vax_convert)
Sets the VAX flag of the input cube.
Definition: ProcessImport.cpp:919
Isis::ProcessImport::DataSuffixBytes
int DataSuffixBytes() const
This method returns the number of data duffix bytes.
Definition: ProcessImport.cpp:729
Isis::ProcessImport::p_dataHeader
std::vector< char * > p_dataHeader
The data header.
Definition: ProcessImport.h:376
Isis::EndianSwapper::Uint32_t
uint32_t Uint32_t(void *buf)
Swaps a 32bit unsigned integer.
Definition: EndianSwapper.cpp:130
Isis::ProcessImport::SetFileTrailerBytes
void SetFileTrailerBytes(const int bytes)
This method sets the number of bytes in the trailer of a file.
Definition: ProcessImport.cpp:379
Isis::IsLsb
bool IsLsb()
Return true if this host is an LSB first machine and false if it is not.
Definition: Endian.h:67
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::Progress::SetMaximumSteps
void SetMaximumSteps(const int steps)
This sets the maximum number of steps in the process.
Definition: Progress.cpp:85
Isis::ProcessImport::DataSuffix
std::vector< std::vector< char * > > DataSuffix()
This method returns a pointer to the data suffix.
Definition: ProcessImport.cpp:891
Isis::JP2Decoder::Read
void Read(unsigned char **inbuf)
Read data from JP2 file containing 8-bit data.
Definition: JP2Decoder.cpp:168
Isis::ProcessImport::p_dataPost
std::vector< std::vector< char * > > p_dataPost
The data suffix.
Definition: ProcessImport.h:379
Isis::ProcessImport::BIL
@ BIL
Band Interleaved By Line Format (i.e.
Definition: ProcessImport.h:284
Isis::ProcessImport::p_fileHeader
char * p_fileHeader
The file header.
Definition: ProcessImport.h:375
IsisAml::GetFileName
QString GetFileName(const QString &paramName, QString extension="") const
Allows the retrieval of a value for a parameter of type "filename".
Definition: IsisAml.cpp:607
Isis::ProcessImport::p_saveFileHeader
bool p_saveFileHeader
Flag indicating whether to save the file header or not.
Definition: ProcessImport.h:363
Isis::Process::OutputCubes
std::vector< Isis::Cube * > OutputCubes
A vector of pointers to allocated Cube objects.
Definition: Process.h:191
Isis::Process
Base class for all cube processing derivatives.
Definition: Process.h:143
Isis::ProcessImport::p_dataTrailer
std::vector< char * > p_dataTrailer
The data trailer.
Definition: ProcessImport.h:377
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::CubeAttributeOutput
Manipulate and parse attributes of output cube filenames.
Definition: CubeAttribute.h:473
Isis::ProcessImport::p_lrs_max
double p_lrs_max
The pixel value which is the upper bound of LRS data.
Definition: ProcessImport.h:428
Isis::PvlObject::addObject
void addObject(const PvlObject &object)
Add a PvlObject.
Definition: PvlObject.h:307
Isis::ProcessImport::SetAttributes
void SetAttributes(CubeAttributeOutput &att)
Given a CubeAttributeOutput object, set min/max to propagate if propagating min/max attributes was re...
Definition: ProcessImport.cpp:1198
Isis::ProcessImport::p_pixelType
Isis::PixelType p_pixelType
Pixel type of input data.
Definition: ProcessImport.h:329
Isis::ProcessImport::~ProcessImport
virtual ~ProcessImport()
Destroys the Import object.
Definition: ProcessImport.cpp:78
Isis::ProcessImport::p_his_max
double p_his_max
The pixel value which is the upper bound of HIS data.
Definition: ProcessImport.h:420
Isis::ProcessImport::p_hrs_max
double p_hrs_max
The pixel value which is the upper bound of HRS data.
Definition: ProcessImport.h:412
Isis::ProcessImport::p_fileTrailer
char * p_fileTrailer
The file trailer.
Definition: ProcessImport.h:380
Isis::ProcessImport::SaveDataTrailer
void SaveDataTrailer()
This method marks the data block trailers to be saved.
Definition: ProcessImport.cpp:617
Isis::ProcessImport::p_saveDataPost
bool p_saveDataPost
Flag indicating whether to save the data suffix or not.
Definition: ProcessImport.h:371
Isis::ProcessImport::SaveDataHeader
void SaveDataHeader()
This method marks the data block headers to be saved.
Definition: ProcessImport.cpp:588
Isis::EndianSwapper::ShortInt
short int ShortInt(void *buf)
Swaps a short integer value.
Definition: EndianSwapper.cpp:174
Isis::Brick
Buffer for containing a three dimensional section of an image.
Definition: Brick.h:45
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::ByteOrder
ByteOrder
Tests the current architecture for byte order.
Definition: Endian.h:42
Isis::ProcessImport::SaveDataSuffix
void SaveDataSuffix()
This method marks the data suffix to be saved.
Definition: ProcessImport.cpp:674
Isis::Buffer
Buffer for reading and writing cube data.
Definition: Buffer.h:53
Isis::ProcessImport::SaveDataPrefix
void SaveDataPrefix()
This method marks the data prefix to be saved.
Definition: ProcessImport.cpp:645
Isis::ProcessImport::p_nl
int p_nl
Number of lines.
Definition: ProcessImport.h:333
Isis::ProcessImport::DataTrailer
std::vector< char * > DataTrailer()
This method returns a pointer to the data trailer.
Definition: ProcessImport.cpp:835
Isis::ProcessImport::p_organization
ProcessImport::Interleave p_organization
The format of the input file.
Definition: ProcessImport.h:384
Isis::ProcessImport::DataPrefix
std::vector< std::vector< char * > > DataPrefix()
This method returns a pointer to the data prefix.
Definition: ProcessImport.cpp:863
Isis::Application::GetUserInterface
static UserInterface & GetUserInterface()
Returns the UserInterface object.
Definition: Application.cpp:463
Isis::ProcessImport::SetDimensions
void SetDimensions(const int ns, const int nl, const int nb)
Sets the physical size of the input cube.
Definition: ProcessImport.cpp:304
Isis::FileName::expanded
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:196
Isis::ProcessImport::SetOutputCube
Isis::Cube * SetOutputCube(const QString &parameter)
Create the output file.
Definition: ProcessImport.cpp:1261
Isis::ProcessImport::p_lis_min
double p_lis_min
The pixel value which is the lower bound of LIS data.
Definition: ProcessImport.h:432
Isis::ProcessImport::p_byteOrder
Isis::ByteOrder p_byteOrder
Byte order of data.
Definition: ProcessImport.h:335
Isis::ProcessImport::DataPrefixBytes
int DataPrefixBytes() const
This method returns the number of data prefix bytes.
Definition: ProcessImport.cpp:721
Isis::ProcessImport::VAXConversion
double VAXConversion(void *ibuf)
Conversion routine which translates VAX_REAL to IEEE_REAL.
Definition: ProcessImport.cpp:171
Isis::ProcessImport::p_ns
int p_ns
Number of samples.
Definition: ProcessImport.h:332
Isis::ProcessImport::p_dataTrailerBytes
int p_dataTrailerBytes
Number of bytes of non-image data after the image data of each data block, such as band trailer data ...
Definition: ProcessImport.h:353
Isis::ProcessImport::p_suffixData
int p_suffixData
The number of bytes past the file header bytes where the suffix data bands are stored.
Definition: ProcessImport.h:337
Isis::ProcessImport::p_fileHeaderBytes
int p_fileHeaderBytes
The number of bytes of non-image data at the beginning of a file.
Definition: ProcessImport.h:341
Isis::ProcessImport::p_his_min
double p_his_min
The pixel value which is the lower bound of HIS data.
Definition: ProcessImport.h:416
Isis::ProcessImport::SetInputFile
void SetInputFile(const QString &file)
Sets the name of the input file to be read in the import StartProcess method and verifies its existan...
Definition: ProcessImport.cpp:2302
Isis::Progress::SetText
void SetText(const QString &text)
Changes the value of the text string reported just before 0% processed.
Definition: Progress.cpp:61
Isis::ProcessImport::Organization
Interleave Organization() const
Gets the organization of the input cube.
Definition: ProcessImport.cpp:928
Isis::ProcessImport::SetHIS
void SetHIS(const double his_min, const double his_max)
Sets the range that will be considered Isis::Null.
Definition: ProcessImport.cpp:1082
Isis::ProcessImport::SetSpecialValues
void SetSpecialValues(const double null, const double lrs, const double lis, const double hrs, const double his)
Sets a mapping of input pixel values to output special pixel values.
Definition: ProcessImport.cpp:993
Isis::ProcessImport::SetDataSuffixBytes
void SetDataSuffixBytes(const int bytes)
This method sets the number of bytes at the end of each data record of a file.
Definition: ProcessImport.cpp:503
Isis::CubeAttributeOutput::propagateMinimumMaximum
bool propagateMinimumMaximum() const
Return true if the min/max are to be propagated from an input cube.
Definition: CubeAttribute.cpp:177
Isis::ProcessImport::FileTrailerBytes
int FileTrailerBytes() const
This method returns the number of file trailer bytes.
Definition: ProcessImport.cpp:697
Isis::ProcessImport::p_base
std::vector< double > p_base
An array containing the core base for each band.
Definition: ProcessImport.h:391
Isis::ProcessImport::p_saveDataHeader
bool p_saveDataHeader
Flag indicating whether to save the data header or not.
Definition: ProcessImport.h:365
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::ProcessImport::SetPixelType
void SetPixelType(const Isis::PixelType type)
Sets the pixel type of the input file.
Definition: ProcessImport.cpp:264
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::ProcessImport::SaveFileTrailer
void SaveFileTrailer()
This method marks the file trailer to be saved.
Definition: ProcessImport.cpp:559
Isis::ProcessImport::DataTrailerBytes
int DataTrailerBytes() const
This method returns the number of data trailer bytes.
Definition: ProcessImport.cpp:713
Isis::ProcessImport::SetOrganization
void SetOrganization(const ProcessImport::Interleave org)
Sets the organization of the input cube.
Definition: ProcessImport.cpp:907
Isis::ProcessImport::StartProcess
virtual void StartProcess()
Process the input file and write it to the output.
Definition: ProcessImport.cpp:1302
Isis::ProcessImport::Interleave
Interleave
This enum includes how the document should be read: by BSQ, BIL, BIP, JP2, or InterleaveUndefined.
Definition: ProcessImport.h:278
Isis::JP2Decoder
JPEG2000 decoder class.
Definition: JP2Decoder.h:83
Isis::Process::SetOutputCube
virtual Isis::Cube * SetOutputCube(const QString &parameter)
Allocates a user-specified output cube whose size matches the first input cube.
Definition: Process.cpp:160
Isis::ProcessImport::p_saveDataTrailer
bool p_saveDataTrailer
Flag indicating whether to save the data trailer or not.
Definition: ProcessImport.h:367
Isis::ProcessImport::SetNull
void SetNull(const double null_min, const double null_max)
Sets the range that will be considered Isis::Null.
Definition: ProcessImport.cpp:1014
Isis::ProcessImport::FileHeaderBytes
int FileHeaderBytes() const
This method returns the number of file header bytes.
Definition: ProcessImport.cpp:688
Isis::EndianSwapper::Int
int Int(void *buf)
Swaps a 4 byte integer value.
Definition: EndianSwapper.cpp:108
Isis::PixelType
PixelType
Enumerations for Isis Pixel Types.
Definition: PixelType.h:27
Isis::ProcessImport::p_null_min
double p_null_min
The pixel value which is the lower bound of NULL data.
Definition: ProcessImport.h:400
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
std
Namespace for the standard library.
Isis::IsValidPixel
bool IsValidPixel(const double d)
Returns if the input pixel is valid.
Definition: SpecialPixel.h:223
Isis::UserInterface
Command Line and Xml loader, validation, and access.
Definition: UserInterface.h:140
Isis::ProcessImport::SetMultiplier
void SetMultiplier(const double mult)
Sets the core multiplier of the input cube.
Definition: ProcessImport.cpp:959
Isis::ProcessImport::ProcessJp2
void ProcessJp2(void funct(Isis::Buffer &out)=NULL)
Function to process files containing compressed JPEG2000 data (which is always BSQ but is processed a...
Definition: ProcessImport.cpp:2123
Isis::PixelTypeName
QString PixelTypeName(Isis::PixelType pixelType)
Returns string name of PixelType enumeration entered as input parameter.
Definition: PixelType.h:66
Isis::ProcessImport::SaveFileHeader
void SaveFileHeader()
This method marks the file header to be saved.
Definition: ProcessImport.cpp:532
Isis::ProcessImport::DataHeaderBytes
int DataHeaderBytes() const
This method returns the number of data header bytes.
Definition: ProcessImport.cpp:705
Isis::ProcessImport::p_inFile
QString p_inFile
Input file name.
Definition: ProcessImport.h:328
Isis::EndianSwapper
Byte swapper.
Definition: EndianSwapper.h:38
Isis::ProcessImport::p_fileTrailerBytes
int p_fileTrailerBytes
The number of bytes of non-image data at the end of a file.
Definition: ProcessImport.h:345
Isis::ProcessImport::SetByteOrder
void SetByteOrder(const Isis::ByteOrder order)
Sets the byte order of the input file.
Definition: ProcessImport.cpp:324
Isis::ProcessImport::TestPixel
double TestPixel(const double pixel)
Tests the pixel.
Definition: ProcessImport.cpp:1167
Isis::ProcessImport::p_dataPre
std::vector< std::vector< char * > > p_dataPre
The data prefix.
Definition: ProcessImport.h:378
Isis::Process::p_progress
Isis::Progress * p_progress
Pointer to a Progress object.
Definition: Process.h:145
Isis::ProcessImport::BSQ
@ BSQ
Band Sequential Format (i.e.
Definition: ProcessImport.h:281
Isis::ProcessImport::ProcessBil
void ProcessBil(void funct(Isis::Buffer &out)=NULL)
Function to process files stored as Band Interleaved by Line.
Definition: ProcessImport.cpp:1626
Isis::ProcessImport::p_dataPostBytes
int p_dataPostBytes
Number of bytes of non-image data following each data record, such as line suffix data in a band sequ...
Definition: ProcessImport.h:360
Isis::ProcessImport::SetFileHeaderBytes
void SetFileHeaderBytes(const int bytes)
This method sets the number of bytes in the header of a file.
Definition: ProcessImport.cpp:349
Isis::ProcessImport::CheckPixelRange
void CheckPixelRange(QString pixelName, double min, double max)
Checks the special pixel range of the given against all other special pixel value ranges,...
Definition: ProcessImport.cpp:1098
Isis::ProcessImport::JP2
@ JP2
Jpeg 2000 Format (always band sequential).
Definition: ProcessImport.h:280
Isis::ProcessImport::p_saveFileTrailer
bool p_saveFileTrailer
Flag indicating whether to save the file trailer or not.
Definition: ProcessImport.h:373
Isis::ProcessImport::FileTrailer
char * FileTrailer()
This method returns a pointer to the file trailer.
Definition: ProcessImport.cpp:779
Isis::CubeAttributeOutput::propagatePixelType
bool propagatePixelType() const
Return true if the pixel type is to be propagated from an input cube.
Definition: CubeAttribute.cpp:165
Isis::ProcessImport::p_saveDataPre
bool p_saveDataPre
Flag indicating whether to save the data prefix or not.
Definition: ProcessImport.h:369
Isis::EndianSwapper::Double
double Double(void *buf)
Swaps a double precision value.
Definition: EndianSwapper.cpp:55
Isis::ProcessImport::p_dataHeaderBytes
int p_dataHeaderBytes
Number of bytes of non-image data after the file header and before the image data of each data block,...
Definition: ProcessImport.h:349
Isis::CubeAttributeOutput::setMinimum
void setMinimum(double min)
Set the output cube attribute minimum.
Definition: CubeAttribute.cpp:324
Isis::ProcessImport::SetLRS
void SetLRS(const double lrs_min, const double lrs_max)
Sets the range that will be considered Isis::Null.
Definition: ProcessImport.cpp:1031
Isis::ProcessImport::SetDataTrailerBytes
void SetDataTrailerBytes(const int bytes)
This method sets the number of bytes in the trailer of each datablock of a file.
Definition: ProcessImport.cpp:443
Isis::ProcessImport::p_hrs_min
double p_hrs_min
The pixel value which is the lower bound of HRS data.
Definition: ProcessImport.h:408
Isis::ProcessImport::p_nb
int p_nb
Number of bands.
Definition: ProcessImport.h:334
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::ProcessImport::BIP
@ BIP
Band Interleaved By Pixel Format (i.e.
Definition: ProcessImport.h:288
Isis::IException::User
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition: IException.h:126
Isis::ProcessImport::SetHRS
void SetHRS(const double hrs_min, const double hrs_max)
Sets the range that will be considered Isis::Null.
Definition: ProcessImport.cpp:1065
Isis::ProcessImport::FileHeader
char * FileHeader()
This method returns a pointer to the file header.
Definition: ProcessImport.cpp:753