32 #include <OpenFOAM/gzstream.h>
41 bool triSurface::readSTLBINARY(
const fileName& STLfileName)
43 bool compressed =
false;
45 autoPtr<istream> STLfilePtr
47 new ifstream(STLfileName.c_str(), std::ios::binary)
51 if (!STLfilePtr->good() &&
isFile(STLfileName +
".gz",
false))
54 STLfilePtr.reset(
new igzstream((STLfileName +
".gz").c_str()));
56 istream& STLfile = STLfilePtr();
60 FatalErrorIn(
"triSurface::readSTLBINARY(const fileName&)")
61 <<
"Cannot read file " << STLfileName
62 <<
" or file " << STLfileName +
".gz"
67 char header[STLheaderSize];
68 STLfile.read(header, STLheaderSize);
79 STLfile.read(reinterpret_cast<char*>(&nTris),
sizeof(
unsigned int));
83 if (!STLfile || nTris < 0)
94 if (nTris < dataFileSize/50 || nTris > dataFileSize/25)
114 STLtriangle stlTri(STLfile);
118 rawPoints[rawPointI] = stlTri.a();
121 rawPoints[rawPointI] = stlTri.b();
124 rawPoints[rawPointI] = stlTri.c();
132 stitchTriangles(rawPoints);