From Paul de Repentigny, ciyple fo fixes for the DXF reader.

This commit is contained in:
Robert Osfield 2005-12-15 15:36:55 +00:00
parent 9cce605cb2
commit cc78197fb3
2 changed files with 81 additions and 75 deletions

View File

@ -19,70 +19,72 @@ typedef std::map<std::string, osg::ref_ptr<osg::Group> > LayerTable;
class dxfDataType {
public:
enum TYPE {
UNKNOWN,
STRING,
HEX,
BOOL,
SHORT,
INT,
LONG,
DOUBLE
};
inline static bool between(int a, int m, int x) { return (a >= m && a <= x); }
inline static int typeForCode(int gc) {
if ( between(gc, 0, 9) ||
gc == 100 || gc == 102 ||
between(gc, 300, 309) ||
between(gc, 410, 419) ||
between(gc, 430, 439) ||
between(gc, 470, 479) ||
gc == 999 ||
between(gc, 1000, 1009)
)
return STRING;
else if ( gc == 105 ||
between(gc, 310, 319) ||
between(gc, 320, 329) ||
between(gc, 330, 369) ||
between(gc, 390, 399)
)
return HEX;
else if ( between(gc, 290, 299 ) )
return BOOL;
else if ( between(gc, 60, 79) ||
between(gc, 170, 179) ||
between(gc, 270, 279) ||
between(gc, 280, 289) ||
between(gc, 370, 379) ||
between(gc, 380, 389) ||
between(gc, 400, 409)
)
return SHORT;
else if ( between(gc, 90, 99) ||
between(gc, 450, 459) ||
between(gc, 1060, 1070)
)
return LONG;
else if ( between(gc, 420, 429) ||
between(gc, 440, 449) ||
gc == 1071
)
return INT;
else if ( between(gc, 10, 39) ||
between(gc, 40, 59) ||
between(gc, 110, 119) ||
between(gc, 120, 129) ||
between(gc, 130, 139) ||
between(gc, 140, 149) ||
between(gc, 210, 239) ||
between(gc, 460, 469) ||
between(gc, 1010, 1019)
)
return DOUBLE;
else
return UNKNOWN;
}
enum TYPE {
UNKNOWN,
STRING,
HEX,
BOOL,
SHORT,
INT,
LONG,
DOUBLE
};
inline static bool between(int a, int m, int x) { return (a >= m && a <= x); }
inline static int typeForCode(int gc) {
if ( between(gc, 0, 9) ||
gc == 100 || gc == 102 ||
between(gc, 300, 309) ||
between(gc, 410, 419) ||
between(gc, 430, 439) ||
between(gc, 470, 479) ||
gc == 999 ||
between(gc, 1000, 1009)
)
return STRING;
else if ( gc == 105 ||
between(gc, 310, 319) ||
between(gc, 320, 329) ||
between(gc, 330, 369) ||
between(gc, 390, 399)
)
return HEX;
else if ( between(gc, 290, 299 ) )
return BOOL;
else if ( between(gc, 70, 78 ) ) // 2005.12.13 PdR 70 to 78 should be INT, not U_SHORT
return INT;
else if ( between(gc, 60, 79) ||
between(gc, 170, 179) ||
between(gc, 270, 279) ||
between(gc, 280, 289) ||
between(gc, 370, 379) ||
between(gc, 380, 389) ||
between(gc, 400, 409)
)
return SHORT;
else if ( between(gc, 90, 99) ||
between(gc, 450, 459) ||
between(gc, 1060, 1070)
)
return LONG;
else if ( between(gc, 420, 429) ||
between(gc, 440, 449) ||
gc == 1071
)
return INT;
else if ( between(gc, 10, 39) ||
between(gc, 40, 59) ||
between(gc, 110, 119) ||
between(gc, 120, 129) ||
between(gc, 130, 139) ||
between(gc, 140, 149) ||
between(gc, 210, 239) ||
between(gc, 460, 469) ||
between(gc, 1010, 1019)
)
return DOUBLE;
else
return UNKNOWN;
}
};
#endif

View File

@ -98,7 +98,10 @@ void
dxfVertex::assign(dxfFile* dxf, codeValue& cv)
{
double d = cv._double;
unsigned short s = cv._short;
// 2005.12.13 pdr: learned today that negative indices mean something and were possible
int s = cv._int; // 2005.12.13 pdr: group codes [70,78] now signed int.
if ( s < 0 ) s = -s;
switch (cv._groupCode) {
case 10:
_vertex.x() = d;
@ -356,22 +359,22 @@ dxfPolyline::assign(dxfFile* dxf, codeValue& cv)
_elevation = d; // what is elevation?
break;
case 70:
_flag = cv._short;
_flag = cv._int; // 2005.12.13 pdr: group codes [70,78] now signed int.
break;
case 71:
_mcount = cv._short;
_mcount = cv._int; // 2005.12.13 pdr: group codes [70,78] now signed int.
break;
case 72:
_ncount = cv._short;
_ncount = cv._int; // 2005.12.13 pdr: group codes [70,78] now signed int.
break;
case 73:
_mdensity = cv._short;
_mdensity = cv._int; // 2005.12.13 pdr: group codes [70,78] now signed int.
break;
case 74:
_ndensity = cv._short;
_ndensity = cv._int; // 2005.12.13 pdr: group codes [70,78] now signed int.
break;
case 75:
_surfacetype = cv._short;
_surfacetype = cv._int; // 2005.12.13 pdr: group codes [70,78] now signed int.
break;
case 210:
_ocs.x() = d;
@ -575,9 +578,10 @@ dxfPolyline::drawScene(scene* sc)
qlist.push_back(b);
qlist.push_back(a);
} else {
qlist.push_back(c);
qlist.push_back(b);
qlist.push_back(a);
// 2005.12.13 pdr: vlist! not qlist!
vlist.push_back(c);
vlist.push_back(b);
vlist.push_back(a);
}
}
if (vlist.size())
@ -622,7 +626,7 @@ dxfLWPolyline::assign(dxfFile* dxf, codeValue& cv)
_elevation = d; // what is elevation?
break;
case 70:
_flag = cv._short;
_flag = cv._int; // 2005.12.13 pdr: group codes [70,78] now signed int.
break;
case 90:
_vcount = cv._short;