Go to the documentation of this file.
33 #undef DEBUG_STLBINARY
50 IFstream str(filename, IOstream::BINARY);
54 char header[headerSize];
55 is.read(header, headerSize);
66 is.read(
reinterpret_cast<char*
>(&nTris),
sizeof(
unsigned int));
77 || nTris < (dataFileSize - headerSize)/50
78 || nTris > (dataFileSize - headerSize)/25
92 const off_t dataFileSize
98 char header[headerSize];
99 is.read(header, headerSize);
105 <<
"problem reading header, perhaps file is not binary "
112 is.read(
reinterpret_cast<char*
>(&nTris),
sizeof(
unsigned int));
123 || nTris <
int(dataFileSize - headerSize)/50
124 || nTris >
int(dataFileSize - headerSize)/25
128 <<
"problem reading number of triangles, perhaps file is not binary"
132 #ifdef DEBUG_STLBINARY
133 Info<<
"# " << nTris <<
" facets" <<
endl;
137 points_.setSize(3*nTris);
138 zoneIds_.setSize(nTris);
151 points_[ptI++] = stlTri.
a();
152 points_[ptI++] = stlTri.
b();
153 points_[ptI++] = stlTri.
c();
170 zoneI = dynSizes.size();
171 lookup.insert(origId, zoneI);
175 zoneIds_[faceI] = zoneI;
178 #ifdef DEBUG_STLBINARY
179 if (prevZone != zoneI)
183 Info<<
"endsolid zone" << prevZone <<
nl;
187 Info<<
"solid zone" << prevZone <<
nl;
191 <<
" outer loop" <<
nl
192 <<
" vertex " << stlTri.
a() <<
nl
193 <<
" vertex " << stlTri.
b() <<
nl
194 <<
" vertex " << stlTri.
c() <<
nl
195 <<
" outer loop" <<
nl
196 <<
" endfacet" <<
endl;
201 sizes_.transfer(dynSizes);
223 if (detectBINARY(filename))
227 IFstream(filename, IOstream::BINARY)().stdStream(),
257 char header[headerSize];
258 sprintf(header,
"STL binary file %u facets", nTris);
261 for (
size_t i = strlen(header); i < headerSize; ++i)
266 os.write(header, headerSize);
267 os.write(
reinterpret_cast<char*
>(&nTris),
sizeof(
unsigned int));
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
virtual istream & stdStream()
Access to underlying std::istream.
A class for handling file names.
#define forAll(list, i)
Loop across all elements in list.
unsigned short attrib() const
Ostream & endl(Ostream &os)
Add newline and flush stream.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const STLpoint & b() const
const STLpoint & c() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A triangle representation for STL files.
const STLpoint & normal() const
off_t fileSize(const fileName &)
Return size of file.
const STLpoint & a() const
stressControl lookup("compactNormalStress") >> compactNormalStress