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)
104 format == STLFormat::UNKNOWN
106 :
format == STLFormat::BINARY
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);
178 std::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));
A wrapped std::ifstream with possible compression handling (igzstream) that behaves much like a std::...
A class for handling file names.
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
IOstreamOption::compressionType whichCompression() const
Which compression type?
std::istream * release() noexcept
Return managed pointer and release ownership.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
dimensionedScalar pos(const dimensionedScalar &ds)
static constexpr const unsigned STLHeaderSize
static bool startsWithSolid(const char header[STLHeaderSize])
static bool checkBinaryFileSize(const int64_t nTris, const Foam::fileName &file)
OBJstream os(runTime.globalPath()/outputName)
word format(conversionProperties.get< word >("format"))
bool isspace(char c) noexcept
Test for whitespace (C-locale)
bool has_ext() const
Various checks for extensions.