38static inline std::string
perrorEOF(std::string expected)
40 return "Premature EOF while reading '" + expected +
"'";
46 return "Parse error. Expecting '" + expected +
"' found '" +
found +
"'";
80 typedef std::pair<const char*, const char*> tokenType;
86 inline std::string::size_type tokenize(
const char *
p,
const char *pe)
88 const char* start =
p;
110 tokens_.
append(tokenType(beg,
p));
137 void execute(std::istream& is);
147#define INBUFLEN 16384
158 std::streamsize pending = 0;
172 <<
"buffer full while scanning near line " <<
lineNum_ <<
nl;
176 char *
data = inbuf + pending;
177 const std::streamsize buflen =
INBUFLEN - pending;
179 is.read(
data, buflen);
180 const std::streamsize gcount = is.gcount();
195 case scanFacet: { errMsg_ =
perrorEOF(
"facet");
break; }
196 case scanLoop: { errMsg_ =
perrorEOF(
"outer loop");
break; }
197 case scanVerts: { errMsg_ =
perrorEOF(
"vertex");
break; }
198 case scanEndLoop: { errMsg_ =
perrorEOF(
"endloop");
break; }
199 case scanEndFacet: { errMsg_ =
perrorEOF(
"endfacet");
break; }
200 case scanEndSolid: { errMsg_ =
perrorEOF(
"endsolid");
break; }
211 char *pe =
data + gcount;
216 while (*pe !=
'\n' && pe >= inbuf)
227 const auto parsedLen = tokenize(
p, pe);
229 if (!parsedLen || tokens_.empty())
235 cmd.assign(tokens_[0].first, tokens_[0].second);
273 else if (cmd ==
"facet")
278 else if (cmd ==
"endsolid")
306 if (tokens_.size() > 3)
316 errMsg_ =
"Error parsing vertex value";
319 else if (cmd ==
"endloop")
321 state_ = scanEndFacet;
331 if (cmd ==
"endloop")
333 state_ = scanEndFacet;
343 if (cmd ==
"endfacet")
356 if (cmd ==
"endsolid")
368 while (errMsg_.empty());
371 pending =
data + gcount - pe;
375 memmove(inbuf, pe, pending);
383 if (!errMsg_.empty())
389 if (!errMsg_.empty())
402bool Foam::fileFormats::STLReader::readAsciiManual
411 <<
"file " << filename <<
" not found"
417 lexer.execute(is.stdStream());
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
static std::string perrorParse(std::string expected, std::string found)
static std::string perrorEOF(std::string expected)
A lexer for parsing STL ASCII files.
void execute(std::istream &is)
Execute parser.
STLAsciiParseManual(const label approxNpoints)
From input stream and the approximate number of vertices in the STL.
Internal class used when parsing STL ASCII format.
void beginFacet()
Action when entering 'facet'.
void beginSolid(word solidName)
Action when entering 'solid'.
bool addVertexComponent(float val)
Add next vertex component. On each third call, adds the point.
void endFacet()
Action on 'endfacet'.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Copy append an element to the end of this list.
Input from file stream, using an ISstream.
void append(const T &val)
Append an element at the end of the list.
void clear()
Clear the list, i.e. set size to zero.
Database for solution data, solver performance and other reduced data.
A class for handling file names.
virtual bool execute()
Calculate the output fields.
virtual void validate()
Validate the turbulence fields after construction.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
bool isspace(char c) noexcept
Test for whitespace (C-locale)
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)
constexpr char nl
The newline '\n' character (0x0a)