- 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)++;
|
||||
i++;
|
||||
}
|
||||
*line_pos = 0;
|
||||
if (*line_pos == 80)
|
||||
*line_pos = 0;
|
||||
else
|
||||
input.putback(c);
|
||||
} else {
|
||||
line += c;
|
||||
}
|
||||
|
@ -551,6 +554,8 @@ E00::readIFO ()
|
|||
IFO::Entry entry;
|
||||
ifo.fileName = line;
|
||||
|
||||
// cout << "Reading IFO file " << line << endl;
|
||||
|
||||
// 'XX' may be absent
|
||||
*_input >> ifo.isArcInfo;
|
||||
if (ifo.isArcInfo == "XX") {
|
||||
|
@ -589,6 +594,7 @@ E00::readIFO ()
|
|||
// Read the data records
|
||||
ifo.entries.resize(0);
|
||||
for (int i = 0; i < ifo.numDataRecords; i++) {
|
||||
// cout << " Reading entry " << i << endl;
|
||||
entry.resize(0);
|
||||
line_pos = 0;
|
||||
skipNewlines(*_input, &line_pos);
|
||||
|
@ -641,7 +647,7 @@ E00::readIFO ()
|
|||
<< " assuming integer" << endl;
|
||||
exit(1);
|
||||
}
|
||||
// cout << " Read item '" << line << '\'' << endl;
|
||||
// cout << " Read item " << j << ": '" << line << '\'' << endl;
|
||||
entry.push_back(line);
|
||||
}
|
||||
ifo.entries.push_back(entry);
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
|
||||
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;
|
||||
sg_gzifstream input(av[i]);
|
||||
E00 data;
|
||||
|
@ -20,42 +22,60 @@ int main (int ac, const char ** av)
|
|||
<< e.getMessage() << endl;
|
||||
exit(1);
|
||||
}
|
||||
cerr << "Read " << av[i] << " successfully" << endl;
|
||||
cerr << "Read " << data.nPoints() << " point(s)" << endl;
|
||||
cerr << "Read " << data.nLines() << " line segment(s)" << endl;
|
||||
cerr << "Read " << data.nPolygons() << " polygon(s)" << endl;
|
||||
cerr << " (including enclosing polygon)" << endl;
|
||||
cout << "Read " << av[i] << " successfully" << endl;
|
||||
cout << "Read " << data.nPoints() << " point(s)" << endl;
|
||||
cout << "Read " << data.nLines() << " line segment(s)" << endl;
|
||||
cout << "Read " << data.nPolygons() << " polygon(s)" << endl;
|
||||
cout << " (including enclosing polygon)" << endl;
|
||||
|
||||
for (int i = 1; i <= data.nInfoFiles(); i++) {
|
||||
const E00::IFO &ifo = data.getIFO(i);
|
||||
cout << "IFO file: " << ifo.fileName << endl;
|
||||
for (int j = 0; j < ifo.numItems; j++) {
|
||||
cout << " " << ifo.defs[j].itemName << endl;
|
||||
// for (j = 1; j <= data.nInfoFiles(); j++) {
|
||||
// const E00::IFO &ifo = data.getIFO(j);
|
||||
// cout << "IFO file: " << ifo.fileName << endl;
|
||||
// for (k = 0; k < ifo.numItems; k++) {
|
||||
// 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++) {
|
||||
// const E00::PAL &pal = data.getPAL(i);
|
||||
// for (int j = 0; j < pal.numArcs; j++) {
|
||||
// int arcNum = pal.arcs[j].arcNum;
|
||||
// if (arcNum == 0) {
|
||||
// cout << endl;
|
||||
// } else if (arcNum < 0) {
|
||||
// const E00::ARC &arc = data.getARC(0-arcNum);
|
||||
// for (int k = arc.numberOfCoordinates - 1; k >= 0; k--) {
|
||||
// cout << arc.coordinates[k].x << '\t'
|
||||
// << arc.coordinates[k].y << endl;
|
||||
// }
|
||||
// } else {
|
||||
// const E00::ARC &arc = data.getARC(arcNum);
|
||||
// for (int k = 0; k < arc.numberOfCoordinates; k++) {
|
||||
// cout << arc.coordinates[k].x << '\t'
|
||||
// << arc.coordinates[k].y << endl;
|
||||
// }
|
||||
// }
|
||||
// cout << endl;
|
||||
// }
|
||||
// }
|
||||
cout << "Largest polygon (excluding enclosing polygon) has "
|
||||
<< maxPolySize << " points" << endl;
|
||||
|
||||
// Go over the line segments
|
||||
cout << "Looking for longest line segment..." << endl;
|
||||
int maxLineSize = 0;
|
||||
for (j = 1; j <= data.nLines(); j++) {
|
||||
const E00::ARC &arc = data.getARC(j);
|
||||
if (arc.numberOfCoordinates > maxLineSize)
|
||||
maxLineSize = arc.numberOfCoordinates;
|
||||
}
|
||||
|
||||
cout << "Largest line segment (outside of polygon) has "
|
||||
<< maxLineSize << " points" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue