- yet more bug-fixes to deal with padding IFO records to 80
characters; now works with DCW ponet files - fixed another minor bug - compatibility fixes
This commit is contained in:
parent
e5028b5637
commit
bc0e84e259
2 changed files with 61 additions and 35 deletions
|
@ -99,7 +99,10 @@ readItem (istream &input, string &line, int width, int * line_pos)
|
||||||
(*line_pos)++;
|
(*line_pos)++;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
*line_pos = 0;
|
if (*line_pos == 80)
|
||||||
|
*line_pos = 0;
|
||||||
|
else
|
||||||
|
input.putback(c);
|
||||||
} else {
|
} else {
|
||||||
line += c;
|
line += c;
|
||||||
}
|
}
|
||||||
|
@ -551,6 +554,8 @@ E00::readIFO ()
|
||||||
IFO::Entry entry;
|
IFO::Entry entry;
|
||||||
ifo.fileName = line;
|
ifo.fileName = line;
|
||||||
|
|
||||||
|
// cout << "Reading IFO file " << line << endl;
|
||||||
|
|
||||||
// 'XX' may be absent
|
// 'XX' may be absent
|
||||||
*_input >> ifo.isArcInfo;
|
*_input >> ifo.isArcInfo;
|
||||||
if (ifo.isArcInfo == "XX") {
|
if (ifo.isArcInfo == "XX") {
|
||||||
|
@ -589,6 +594,7 @@ E00::readIFO ()
|
||||||
// Read the data records
|
// Read the data records
|
||||||
ifo.entries.resize(0);
|
ifo.entries.resize(0);
|
||||||
for (int i = 0; i < ifo.numDataRecords; i++) {
|
for (int i = 0; i < ifo.numDataRecords; i++) {
|
||||||
|
// cout << " Reading entry " << i << endl;
|
||||||
entry.resize(0);
|
entry.resize(0);
|
||||||
line_pos = 0;
|
line_pos = 0;
|
||||||
skipNewlines(*_input, &line_pos);
|
skipNewlines(*_input, &line_pos);
|
||||||
|
@ -641,7 +647,7 @@ E00::readIFO ()
|
||||||
<< " assuming integer" << endl;
|
<< " assuming integer" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
// cout << " Read item '" << line << '\'' << endl;
|
// cout << " Read item " << j << ": '" << line << '\'' << endl;
|
||||||
entry.push_back(line);
|
entry.push_back(line);
|
||||||
}
|
}
|
||||||
ifo.entries.push_back(entry);
|
ifo.entries.push_back(entry);
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
|
|
||||||
int main (int ac, const char ** av)
|
int main (int ac, const char ** av)
|
||||||
{
|
{
|
||||||
for (int i = 1; i < ac; i++) {
|
int i, j, k;
|
||||||
|
|
||||||
|
for (i = 1; i < ac; i++) {
|
||||||
cerr << "Reading " << av[i] << endl;
|
cerr << "Reading " << av[i] << endl;
|
||||||
sg_gzifstream input(av[i]);
|
sg_gzifstream input(av[i]);
|
||||||
E00 data;
|
E00 data;
|
||||||
|
@ -20,42 +22,60 @@ int main (int ac, const char ** av)
|
||||||
<< e.getMessage() << endl;
|
<< e.getMessage() << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
cerr << "Read " << av[i] << " successfully" << endl;
|
cout << "Read " << av[i] << " successfully" << endl;
|
||||||
cerr << "Read " << data.nPoints() << " point(s)" << endl;
|
cout << "Read " << data.nPoints() << " point(s)" << endl;
|
||||||
cerr << "Read " << data.nLines() << " line segment(s)" << endl;
|
cout << "Read " << data.nLines() << " line segment(s)" << endl;
|
||||||
cerr << "Read " << data.nPolygons() << " polygon(s)" << endl;
|
cout << "Read " << data.nPolygons() << " polygon(s)" << endl;
|
||||||
cerr << " (including enclosing polygon)" << endl;
|
cout << " (including enclosing polygon)" << endl;
|
||||||
|
|
||||||
for (int i = 1; i <= data.nInfoFiles(); i++) {
|
// for (j = 1; j <= data.nInfoFiles(); j++) {
|
||||||
const E00::IFO &ifo = data.getIFO(i);
|
// const E00::IFO &ifo = data.getIFO(j);
|
||||||
cout << "IFO file: " << ifo.fileName << endl;
|
// cout << "IFO file: " << ifo.fileName << endl;
|
||||||
for (int j = 0; j < ifo.numItems; j++) {
|
// for (k = 0; k < ifo.numItems; k++) {
|
||||||
cout << " " << ifo.defs[j].itemName << endl;
|
// cout << " " << ifo.defs[k].itemName << endl;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// Go over the polygons
|
||||||
|
cout << "Looking for largest polygon..." << endl;
|
||||||
|
int maxPolySize = 0;
|
||||||
|
for (j = 2; j <= data.nPolygons(); j++) {
|
||||||
|
int size = 0;
|
||||||
|
const E00::PAL &pal = data.getPAL(j);
|
||||||
|
for (k = 0; k < pal.numArcs; k++) {
|
||||||
|
int arcNum = pal.arcs[k].arcNum;
|
||||||
|
if (arcNum == 0) {
|
||||||
|
// contour boundary; do nothing
|
||||||
|
} else if (arcNum < 0) {
|
||||||
|
const E00::ARC &arc = data.getARC(0-arcNum);
|
||||||
|
size += arc.numberOfCoordinates;
|
||||||
|
} else {
|
||||||
|
const E00::ARC &arc = data.getARC(arcNum);
|
||||||
|
size += arc.numberOfCoordinates;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (size > maxPolySize)
|
||||||
|
maxPolySize = size;
|
||||||
|
if (size > 1000) {
|
||||||
|
cout << "** Large polygon " << j << ": " << size << " points" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (int i = 2; i <= data.nPolygons(); i++) {
|
cout << "Largest polygon (excluding enclosing polygon) has "
|
||||||
// const E00::PAL &pal = data.getPAL(i);
|
<< maxPolySize << " points" << endl;
|
||||||
// for (int j = 0; j < pal.numArcs; j++) {
|
|
||||||
// int arcNum = pal.arcs[j].arcNum;
|
// Go over the line segments
|
||||||
// if (arcNum == 0) {
|
cout << "Looking for longest line segment..." << endl;
|
||||||
// cout << endl;
|
int maxLineSize = 0;
|
||||||
// } else if (arcNum < 0) {
|
for (j = 1; j <= data.nLines(); j++) {
|
||||||
// const E00::ARC &arc = data.getARC(0-arcNum);
|
const E00::ARC &arc = data.getARC(j);
|
||||||
// for (int k = arc.numberOfCoordinates - 1; k >= 0; k--) {
|
if (arc.numberOfCoordinates > maxLineSize)
|
||||||
// cout << arc.coordinates[k].x << '\t'
|
maxLineSize = arc.numberOfCoordinates;
|
||||||
// << arc.coordinates[k].y << endl;
|
}
|
||||||
// }
|
|
||||||
// } else {
|
cout << "Largest line segment (outside of polygon) has "
|
||||||
// const E00::ARC &arc = data.getARC(arcNum);
|
<< maxLineSize << " points" << endl;
|
||||||
// for (int k = 0; k < arc.numberOfCoordinates; k++) {
|
|
||||||
// cout << arc.coordinates[k].x << '\t'
|
|
||||||
// << arc.coordinates[k].y << endl;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// cout << endl;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue