48 void ProcessImportVicar::SetVicarFile(
const QString &vicarFile,
Pvl &vicarLab) {
50 ifstream vicFile(vicarFile.toLatin1().data(), ios::in);
53 QString msg =
"Cannot open vicar file [" + vicarFile +
"]";
59 IString vicLabels = ExtractPvlLabel(0, vicFile);
63 lbl << vicLabels <<
" End" << endl;
69 SetFileHeaderBytes(vLab[
"LBLSIZE"]);
72 SetDataHeaderBytes((
int) vLab[
"NLB"] * (
int)vLab[
"RECSIZE"]);
75 SetDataPrefixBytes(vLab[
"NBB"]);
76 SetDataSuffixBytes(0);
78 SetDimensions(vLab[
"NS"], vLab[
"NL"], vLab[
"NB"]);
80 QString pixType = vLab[
"FORMAT"];
82 if(pixType ==
"BYTE") pixelType = UnsignedByte;
83 if(pixType ==
"WORD") pixelType = UnsignedWord;
84 if(pixType ==
"HALF") pixelType = SignedWord;
85 if(pixType ==
"REAL") pixelType = Real;
86 if(pixelType == None) {
87 QString msg =
"Unsupported pixel type [FORMAT=" + pixType +
"]";
90 SetPixelType(pixelType);
92 QString order = vLab[
"INTFMT"];
100 QString organization = vLab[
"ORG"];
101 if(organization ==
"BSQ") {
102 SetOrganization(ProcessImport::BSQ);
104 else if(organization ==
"BIL") {
105 SetOrganization(ProcessImport::BIL);
107 else if(organization ==
"BIP") {
108 SetOrganization(ProcessImport::BIP);
111 QString msg =
"Unsupported file organization [" + organization +
"]";
117 if(vLab.hasKeyword(
"EOL")) {
118 if((
int) vLab[
"EOL"] == 1) {
119 int startByte = (int) vLab[
"LBLSIZE"] +
120 (
int) vLab[
"NLB"] * (int) vLab[
"RECSIZE"] +
121 (
int) vLab[
"NL"] * (int) vLab[
"NB"] *
122 (
int) vLab[
"RECSIZE"];
123 ifstream vicFile(vicarFile.toLatin1().data(), ios::in);
125 QString endPvlLabel = ExtractPvlLabel(startByte, vicFile);
133 for(
int k = 0; k < endLab.keywords(); k++) {
134 vicarLab += endLab[k];
140 QString msg =
"Input file [" + vicarFile +
"] does not appear to be a vicar file";
144 SetInputFile(vicarFile);
155 QString ProcessImportVicar::ExtractPvlLabel(
int startPos, std::ifstream &vicarFile)
const {
156 vicarFile.seekg(startPos, ios::beg);
159 char *lblSizeValue =
new char [1024];
160 vicarFile.seekg(QString(
"LBLSIZE=").size(), ios_base::cur);
162 for(
int pos = 0; pos < 1024 - 1; pos++) {
163 if(!vicarFile.good())
166 if(vicarFile.peek() ==
' ')
169 lblSizeValue[pos] = vicarFile.get();
170 lblSizeValue[pos + 1] =
'\0';
174 QString msg =
"Cannot find label size in VICAR file";
180 delete [] lblSizeValue;
183 char *buf =
new char[lblSize+1];
186 vicarFile.seekg(startPos, ios::beg);
187 vicarFile.read(buf, lblSize);
192 QString vicLabels = buf;
194 bool inQuote =
false;
195 for(
int pos = 0; pos < vicLabels.size(); pos++) {
196 if(vicLabels[pos] ==
'\'' || vicLabels[pos] ==
'"') {
200 if(!inQuote && vicLabels[pos] ==
' ') {
201 vicLabels[pos] =
'\n';
Namespace for the standard library.
int ToInteger() const
Returns the object string as an integer.
PixelType
Enumerations for Isis Pixel Types.
#define _FILEINFO_
Macro for the filename and line number.
Container for cube-like labels.
Adds specific functionality to C++ strings.
Namespace for ISIS/Bullet specific routines.