7#include "ProcessImportVicar.h"
13#include "Preference.h"
14#include "IException.h"
15#include "LineManager.h"
18#include "SpecialPixel.h"
20#include "UserInterface.h"
34 ifstream vicFile(vicarFile.toLatin1().data(), ios::in);
37 QString msg =
"Cannot open vicar file [" + vicarFile +
"]";
38 throw IException(IException::User, msg, _FILEINFO_);
47 lbl << vicLabels <<
" End" << endl;
64 QString pixType = vLab[
"FORMAT"];
65 Isis::PixelType pixelType = None;
66 if(pixType ==
"BYTE") pixelType = UnsignedByte;
67 if(pixType ==
"WORD") pixelType = UnsignedWord;
68 if(pixType ==
"HALF") pixelType = SignedWord;
69 if(pixType ==
"REAL") pixelType = Real;
70 if(pixelType == None) {
71 QString msg =
"Unsupported pixel type [FORMAT=" + pixType +
"]";
72 throw IException(IException::Io, msg, _FILEINFO_);
76 QString order = vLab[
"INTFMT"];
84 QString organization = vLab[
"ORG"];
85 if(organization ==
"BSQ") {
88 else if(organization ==
"BIL") {
91 else if(organization ==
"BIP") {
95 QString msg =
"Unsupported file organization [" + organization +
"]";
96 throw IException(IException::Io, msg, _FILEINFO_);
101 if(vLab.hasKeyword(
"EOL")) {
102 if((
int) vLab[
"EOL"] == 1) {
103 int startByte = (int) vLab[
"LBLSIZE"] +
104 (
int) vLab[
"NLB"] * (int) vLab[
"RECSIZE"] +
105 (
int) vLab[
"NL"] * (int) vLab[
"NB"] *
106 (
int) vLab[
"RECSIZE"];
107 ifstream vicFile(vicarFile.toLatin1().data(), ios::in);
117 for(
int k = 0; k < endLab.keywords(); k++) {
118 vicarLab += endLab[k];
123 catch(IException &e) {
124 QString msg =
"Input file [" + vicarFile +
"] does not appear to be a vicar file";
125 throw IException(IException::User, msg, _FILEINFO_);
140 vicarFile.seekg(startPos, ios::beg);
143 char *lblSizeValue =
new char [1024];
144 vicarFile.seekg(QString(
"LBLSIZE=").size(), ios_base::cur);
146 for(
int pos = 0; pos < 1024 - 1; pos++) {
147 if(!vicarFile.good())
150 if(vicarFile.peek() ==
' ')
153 lblSizeValue[pos] = vicarFile.get();
154 lblSizeValue[pos + 1] =
'\0';
158 QString msg =
"Cannot find label size in VICAR file";
159 throw IException(IException::User, msg, _FILEINFO_);
163 int lblSize = IString(lblSizeValue).ToInteger();
164 delete [] lblSizeValue;
167 char *buf =
new char[lblSize+1];
170 vicarFile.seekg(startPos, ios::beg);
171 vicarFile.read(buf, lblSize);
176 QString vicLabels = buf;
178 bool inQuote =
false;
179 for(
int pos = 0; pos < vicLabels.size(); pos++) {
180 if(vicLabels[pos] ==
'\'' || vicLabels[pos] ==
'"') {
184 if(!inQuote && vicLabels[pos] ==
' ') {
185 vicLabels[pos] =
'\n';
void SetPixelType(const Isis::PixelType type)
Sets the pixel type of the input file.
void SetFileHeaderBytes(const int bytes)
This method sets the number of bytes in the header of a file.
void SetOrganization(const ProcessImport::Interleave org)
Sets the organization of the input cube.
void SetDataPrefixBytes(const int bytes)
This method sets the number of bytes at the beginning of each data record of a file.
void SetInputFile(const QString &file)
Sets the name of the input file to be read in the import StartProcess method and verifies its existan...
void SetDataHeaderBytes(const int bytes)
This method sets the number of bytes in the header of each datablock of a file.
void SetByteOrder(const Isis::ByteOrder order)
Sets the byte order of the input file.
@ BIL
Band Interleaved By Line Format (i.e.
@ BIP
Band Interleaved By Pixel Format (i.e.
@ BSQ
Band Sequential Format (i.e.
void SetDataSuffixBytes(const int bytes)
This method sets the number of bytes at the end of each data record of a file.
void SetDimensions(const int ns, const int nl, const int nb)
Sets the physical size of the input cube.
QString ExtractPvlLabel(int startPos, std::ifstream &vicarFile) const
Returns a valid PVL label based on the start position in the VICAR file.
void SetVicarFile(const QString &vicarFile, Pvl &vicarLab)
Opens a vicar file which can then be immediately imported by invoking the inherited StartProcess meth...
This is free and unencumbered software released into the public domain.
Namespace for the standard library.