Automatically distinguish between ASCII and binary stl files

This commit is contained in:
Matthias Hochsteger 2019-09-20 11:55:46 +02:00
parent f6f4976402
commit 5cfb449d7a

View File

@ -338,6 +338,18 @@ void STLTopology :: Save (const char* filename) const
STLGeometry * STLTopology ::Load (istream & ist)
{
// Check if the file starts with "solid". If not, the file is binary
{
char buf[5+1];
FIOReadStringE(ist,buf,5);
if (strcmp(buf, "solid") != 0)
{
for (auto i : Range(5))
ist.unget();
return LoadBinary(ist);
}
}
STLGeometry * geom = new STLGeometry();
NgArray<STLReadTriangle> readtrigs;