55 && std::toupper(header[pos+0]) ==
'S'
56 && std::toupper(header[pos+1]) ==
'O'
57 && std::toupper(header[pos+2]) ==
'L'
58 && std::toupper(header[pos+3]) ==
'I'
59 && std::toupper(header[pos+4]) ==
'D'
79 const int64_t contentSize =
88 && (nTris >= contentSize/50)
89 && (nTris <= contentSize/25)
125 const bool unCompressed =
133 <<
"Cannot read file " << filename
134 <<
" or file " << filename +
".gz"
159 is.read(
reinterpret_cast<char*
>(&nTris),
sizeof(int32_t));
161 bool ok = (is && nTris >= 0);
163 if (ok && unCompressed)
174 return (ok ? nTris : 0);
178std::unique_ptr<std::istream>
182 label& nTrisEstimated
187 std::unique_ptr<std::istream> streamPtr;
188 bool unCompressed(
true);
197 streamPtr.reset(isPtr.
release());
199 auto& is = *streamPtr;
204 <<
"Cannot read file " << filename
205 <<
" or file " << filename +
".gz"
218 <<
"problem reading header, perhaps file is not binary "
233 is.read(
reinterpret_cast<char*
>(&nTris),
sizeof(int32_t));
235 bool ok = (is && nTris >= 0);
237 if (ok && unCompressed)
245 <<
"problem reading number of triangles, perhaps file is not binary"
249 nTrisEstimated = nTris;
263 ::snprintf(header,
STLHeaderSize,
"STL binary file %u facets", nTris);
272 os.write(
reinterpret_cast<char*
>(&nTris),
sizeof(uint32_t));
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
static bool startsWithSolid(const char header[STLHeaderSize])
static constexpr const unsigned STLHeaderSize
static bool checkBinaryFileSize(const int64_t nTris, const Foam::fileName &file)
@ UNCOMPRESSED
compression = false
A class for handling file names.
bool has_ext() const
Various checks for extensions.
A wrapped std::ifstream with possible compression handling (igzstream) that behaves much like a std::...
IOstreamOption::compressionType whichCompression() const
Which compression type?
std::istream * release() noexcept
Return managed pointer and release ownership.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
word format(conversionProperties.get< word >("format"))