Loading isis/src/base/objs/ProcessImport/ProcessImport.cpp +42 −60 Original line number Diff line number Diff line Loading @@ -1847,11 +1847,6 @@ namespace Isis { */ void ProcessImport::ProcessBip(void funct(Isis::Buffer &out)) { // Figure out the number of bytes to read for a single line int readBytes = Isis::SizeOf(p_pixelType); readBytes = readBytes * p_ns * p_nb; char *in = new char [readBytes]; // Set up an Isis::EndianSwapper object QString tok(Isis::ByteOrderName(p_byteOrder)); tok = tok.toUpper(); Loading Loading @@ -1902,6 +1897,11 @@ namespace Isis { p_progress->SetMaximumSteps(p_nl); p_progress->CheckStatus(); // Figure out the number of bytes to read for a single line int sampleBytes = Isis::SizeOf(p_pixelType) * p_nb + p_dataPreBytes + p_dataPostBytes; int readBytes = p_ns * sampleBytes; char *in = new char [readBytes]; // Loop for each line for(int line = 0; line < p_nl; line++) { // Check the last io Loading @@ -1915,16 +1915,6 @@ namespace Isis { // Space for storing prefix and suffix data pointers vector<char *> tempPre, tempPost; // Handle any line prefix bytes pos = fin.tellg(); if (p_saveDataPre) { tempPre.push_back(new char[p_dataPreBytes]); fin.read(tempPre.back(), p_dataPreBytes); } else { fin.seekg(p_dataPreBytes, ios_base::cur); } // Check the last io if (!fin.good()) { QString msg = "Cannot read file [" + p_inFile + "]. Position [" + Loading Loading @@ -1960,31 +1950,32 @@ namespace Isis { // to special pixels int osamp = 0; for(int samp = band; samp < p_ns * p_nb; samp += p_nb) { for(int samp = 0; samp < p_ns; samp++) { int bufferIndex = p_dataPreBytes + Isis::SizeOf(p_pixelType)*band + samp*sampleBytes; switch(p_pixelType) { case Isis::UnsignedByte: (*out)[osamp] = (double)((unsigned char *)in)[samp]; (*out)[osamp] = (double)((unsigned char *)in)[bufferIndex]; break; case Isis::UnsignedWord: (*out)[osamp] = (double)swapper.UnsignedShortInt((unsigned short int *)in+samp); (double)swapper.UnsignedShortInt(&in[bufferIndex]); break; case Isis::SignedWord: (*out)[osamp] = (double)swapper.ShortInt((short int *)in+samp); (*out)[osamp] = (double)swapper.ShortInt(&in[bufferIndex]); break; case Isis::SignedInteger: (*out)[samp] = (double)swapper.Int((int *)in+samp); (*out)[samp] = (double)swapper.Int(&in[bufferIndex]); break; case Isis::Real: if(p_vax_convert) { (*out)[osamp]= VAXConversion( (float *)in+samp ); (*out)[osamp]= VAXConversion(&in[bufferIndex]); } else { (*out)[osamp] = (double)swapper.Float((float *)in+samp); (*out)[osamp] = (double)swapper.Float(&in[bufferIndex]); } break; case Isis::Double: (*out)[osamp] = (double)swapper.Double((double *)in+samp); (*out)[osamp] = (double)swapper.Double(&in[bufferIndex]); break; default: break; Loading @@ -2008,33 +1999,25 @@ namespace Isis { funct(*out); } // Handle any line suffix bytes pos = fin.tellg(); if (p_saveDataPost) { tempPost.push_back(new char[p_dataPostBytes]); fin.read(tempPost.back(), p_dataPostBytes); } else { fin.seekg(p_dataPostBytes, ios_base::cur); } // Check the last io if (!fin.good()) { QString msg = "Cannot read file [" + p_inFile + "]. Position [" + toString((int)pos) + "]. Byte count [" + toString(p_dataPreBytes) + "]" ; throw IException(IException::Io, msg, _FILEINFO_); } } // End band loop // Save off the prefix bytes vector // Handle record prefix and suffix if (p_saveDataPre) { for(int samp = 0; samp < p_ns; samp++) { char *samplePrefix = new char[p_dataPreBytes]; memcpy(samplePrefix, &in[samp*sampleBytes], p_dataPreBytes); tempPre.push_back(samplePrefix); } p_dataPre.push_back(tempPre); tempPre.clear(); } // Save off the suffix bytes vector if (p_saveDataPost) { for(int samp = 0; samp < p_ns; samp++) { char *sampleSuffix = new char[p_dataPostBytes]; int suffixIndex = p_dataPreBytes + Isis::SizeOf(p_pixelType)*p_nb + samp*sampleBytes; memcpy(sampleSuffix, &in[suffixIndex], p_dataPostBytes); tempPost.push_back(sampleSuffix); } p_dataPost.push_back(tempPost); tempPost.clear(); } Loading @@ -2043,12 +2026,11 @@ namespace Isis { if (!fin.good()) { QString msg = "Cannot read file [" + p_inFile + "]. Position [" + toString((int)pos) + "]. Byte count [" + toString(p_fileHeaderBytes) + "]" ; toString(p_dataPreBytes) + "]" ; throw IException(IException::Io, msg, _FILEINFO_); } } // End band loop // Handle the data trailer pos = fin.tellg(); if (p_saveDataTrailer) { p_dataTrailer.push_back(new char[p_dataTrailerBytes]); Loading isis/src/base/objs/ProcessImport/ProcessImport.h +13 −2 Original line number Diff line number Diff line Loading @@ -152,6 +152,17 @@ namespace Isis { * @history 2017-05-29 Kristin Berry - Added support for data trailers in BIP files and fixed * a typo so that DataTrailerBytes() will return the correct value. * References #3888. * @history 2018-05-01 Jesse Mapel - Changed data suffix and prefix in BIP files. Previously, * data suffixes and prefixes were for each band before/after each line. * Now, data suffixes and prefixes are before/after each sample. For a * RGB, 3-band image with n samples a line of data was previously * | Header | R prefix | G prefix | B prefix | R 1 | G 1 | B 1| ... * | R n | G n | B n| R suffix | G suffix | B suffix | Trailer |. Now * it is | Header | Prefix 1 | R 1 | G 1 | B 1 | Suffix 1 | ... * | Prefix n | R n | G n | B n | Suffix n | Trailer |. This change * was made to accomodate Rosetta VIRTIS-m calibrated data files and * has no impact on other supported BIP files. * Fixes #5398. * */ class ProcessImport : public Isis::Process { Loading Loading
isis/src/base/objs/ProcessImport/ProcessImport.cpp +42 −60 Original line number Diff line number Diff line Loading @@ -1847,11 +1847,6 @@ namespace Isis { */ void ProcessImport::ProcessBip(void funct(Isis::Buffer &out)) { // Figure out the number of bytes to read for a single line int readBytes = Isis::SizeOf(p_pixelType); readBytes = readBytes * p_ns * p_nb; char *in = new char [readBytes]; // Set up an Isis::EndianSwapper object QString tok(Isis::ByteOrderName(p_byteOrder)); tok = tok.toUpper(); Loading Loading @@ -1902,6 +1897,11 @@ namespace Isis { p_progress->SetMaximumSteps(p_nl); p_progress->CheckStatus(); // Figure out the number of bytes to read for a single line int sampleBytes = Isis::SizeOf(p_pixelType) * p_nb + p_dataPreBytes + p_dataPostBytes; int readBytes = p_ns * sampleBytes; char *in = new char [readBytes]; // Loop for each line for(int line = 0; line < p_nl; line++) { // Check the last io Loading @@ -1915,16 +1915,6 @@ namespace Isis { // Space for storing prefix and suffix data pointers vector<char *> tempPre, tempPost; // Handle any line prefix bytes pos = fin.tellg(); if (p_saveDataPre) { tempPre.push_back(new char[p_dataPreBytes]); fin.read(tempPre.back(), p_dataPreBytes); } else { fin.seekg(p_dataPreBytes, ios_base::cur); } // Check the last io if (!fin.good()) { QString msg = "Cannot read file [" + p_inFile + "]. Position [" + Loading Loading @@ -1960,31 +1950,32 @@ namespace Isis { // to special pixels int osamp = 0; for(int samp = band; samp < p_ns * p_nb; samp += p_nb) { for(int samp = 0; samp < p_ns; samp++) { int bufferIndex = p_dataPreBytes + Isis::SizeOf(p_pixelType)*band + samp*sampleBytes; switch(p_pixelType) { case Isis::UnsignedByte: (*out)[osamp] = (double)((unsigned char *)in)[samp]; (*out)[osamp] = (double)((unsigned char *)in)[bufferIndex]; break; case Isis::UnsignedWord: (*out)[osamp] = (double)swapper.UnsignedShortInt((unsigned short int *)in+samp); (double)swapper.UnsignedShortInt(&in[bufferIndex]); break; case Isis::SignedWord: (*out)[osamp] = (double)swapper.ShortInt((short int *)in+samp); (*out)[osamp] = (double)swapper.ShortInt(&in[bufferIndex]); break; case Isis::SignedInteger: (*out)[samp] = (double)swapper.Int((int *)in+samp); (*out)[samp] = (double)swapper.Int(&in[bufferIndex]); break; case Isis::Real: if(p_vax_convert) { (*out)[osamp]= VAXConversion( (float *)in+samp ); (*out)[osamp]= VAXConversion(&in[bufferIndex]); } else { (*out)[osamp] = (double)swapper.Float((float *)in+samp); (*out)[osamp] = (double)swapper.Float(&in[bufferIndex]); } break; case Isis::Double: (*out)[osamp] = (double)swapper.Double((double *)in+samp); (*out)[osamp] = (double)swapper.Double(&in[bufferIndex]); break; default: break; Loading @@ -2008,33 +1999,25 @@ namespace Isis { funct(*out); } // Handle any line suffix bytes pos = fin.tellg(); if (p_saveDataPost) { tempPost.push_back(new char[p_dataPostBytes]); fin.read(tempPost.back(), p_dataPostBytes); } else { fin.seekg(p_dataPostBytes, ios_base::cur); } // Check the last io if (!fin.good()) { QString msg = "Cannot read file [" + p_inFile + "]. Position [" + toString((int)pos) + "]. Byte count [" + toString(p_dataPreBytes) + "]" ; throw IException(IException::Io, msg, _FILEINFO_); } } // End band loop // Save off the prefix bytes vector // Handle record prefix and suffix if (p_saveDataPre) { for(int samp = 0; samp < p_ns; samp++) { char *samplePrefix = new char[p_dataPreBytes]; memcpy(samplePrefix, &in[samp*sampleBytes], p_dataPreBytes); tempPre.push_back(samplePrefix); } p_dataPre.push_back(tempPre); tempPre.clear(); } // Save off the suffix bytes vector if (p_saveDataPost) { for(int samp = 0; samp < p_ns; samp++) { char *sampleSuffix = new char[p_dataPostBytes]; int suffixIndex = p_dataPreBytes + Isis::SizeOf(p_pixelType)*p_nb + samp*sampleBytes; memcpy(sampleSuffix, &in[suffixIndex], p_dataPostBytes); tempPost.push_back(sampleSuffix); } p_dataPost.push_back(tempPost); tempPost.clear(); } Loading @@ -2043,12 +2026,11 @@ namespace Isis { if (!fin.good()) { QString msg = "Cannot read file [" + p_inFile + "]. Position [" + toString((int)pos) + "]. Byte count [" + toString(p_fileHeaderBytes) + "]" ; toString(p_dataPreBytes) + "]" ; throw IException(IException::Io, msg, _FILEINFO_); } } // End band loop // Handle the data trailer pos = fin.tellg(); if (p_saveDataTrailer) { p_dataTrailer.push_back(new char[p_dataTrailerBytes]); Loading
isis/src/base/objs/ProcessImport/ProcessImport.h +13 −2 Original line number Diff line number Diff line Loading @@ -152,6 +152,17 @@ namespace Isis { * @history 2017-05-29 Kristin Berry - Added support for data trailers in BIP files and fixed * a typo so that DataTrailerBytes() will return the correct value. * References #3888. * @history 2018-05-01 Jesse Mapel - Changed data suffix and prefix in BIP files. Previously, * data suffixes and prefixes were for each band before/after each line. * Now, data suffixes and prefixes are before/after each sample. For a * RGB, 3-band image with n samples a line of data was previously * | Header | R prefix | G prefix | B prefix | R 1 | G 1 | B 1| ... * | R n | G n | B n| R suffix | G suffix | B suffix | Trailer |. Now * it is | Header | Prefix 1 | R 1 | G 1 | B 1 | Suffix 1 | ... * | Prefix n | R n | G n | B n | Suffix n | Trailer |. This change * was made to accomodate Rosetta VIRTIS-m calibrated data files and * has no impact on other supported BIP files. * Fixes #5398. * */ class ProcessImport : public Isis::Process { Loading