Go to the documentation of this file.
38 static 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;
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())
402 bool 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...
A class for handling file names.
Input from file stream, using an ISstream.
void endFacet()
Action on 'endfacet'.
static word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
Internal class used when parsing STL ASCII format.
static std::string perrorEOF(std::string expected)
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
void clear()
Clear the addressed list, i.e. set the size to zero.
A lexer for parsing STL ASCII files.
graph_traits< Graph >::vertices_size_type size_type
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool addVertexComponent(float val)
Add next vertex component. On each third call, adds the point.
void execute(std::istream &is)
Execute parser.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static const word null
An empty word.
STLAsciiParseManual(const label approxNpoints)
From input stream and the approximate number of vertices in the STL.
void beginSolid(word solidName)
Action when entering 'solid'.
bool isspace(char c)
Test for horizontal whitespace.
Database for solution data, solver performance and other reduced data.
static std::string perrorParse(std::string expected, std::string found)
void beginFacet()
Action when entering 'facet'.