82static bool hasReadWriteTypes(
const word& readType,
const word& writeType)
84 volatile bool good =
true;
86 if (!triSurface::canReadType(readType,
true))
91 if (!triSurface::canWriteType(writeType,
true))
102int main(
int argc,
char *argv[])
106 "Convert between surface formats, using triSurface library components"
109 argList::noParallel();
110 argList::addArgument(
"input",
"The input surface file");
111 argList::addArgument(
"output",
"The output surface file");
113 argList::addBoolOption
116 "Perform some surface checking/cleanup on the input surface"
118 argList::addBoolOption
121 "Reorder faces into groups; one per region"
127 "The input format (default: use file extension)"
133 "The output format (default: use file extension)"
139 "Input geometry scaling factor"
145 "The output precision"
147 argList::addOptionCompat(
"precision", {
"writePrecision", 1812});
155 Info<<
"Output write precision set to " << prec <<
endl;
157 IOstream::defaultPrecision(prec);
165 if (importName == exportName)
168 <<
"Output file would overwrite input file." <<
nl
172 const word readFileType
177 const word writeFileType
184 if (!hasReadWriteTypes(readFileType, writeFileType))
187 <<
"Unsupported file format(s)" <<
nl
192 scalar scaleFactor(0);
194 Info<<
"Reading : " << importName <<
endl;
195 triSurface surf(importName, readFileType, scaleFactor);
199 Info<<
"scale input " << scaleFactor <<
nl;
200 surf.scalePoints(scaleFactor);
205 surf.writeStats(Info);
210 Info<<
"Cleaning up surface" <<
endl;
213 Info<<
"After cleaning up surface:" <<
endl;
214 surf.writeStats(Info);
218 const bool sortByRegion =
args.
found(
"group");
221 Info<<
"Reordering faces into groups; one per region." <<
endl;
225 Info<<
"Maintaining face ordering" <<
endl;
228 Info<<
"writing " << exportName <<
endl;
230 surf.
write(exportName, writeFileType, sortByRegion);
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
virtual int precision() const
Get precision of output field.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Extract command arguments and options from the supplied argc and argv parameters.
T get(const label index) const
Get a value from the argument at index.
bool found(const word &optName) const
Return true if the named option is found.
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
A class for handling file names.
Triangulated surface description with patch information.
A class for handling words, derived from Foam::string.
word ext() const
Return file name extension (part after last .)
word lessExt() const
Return word without extension (part before last .)
messageStream Info
Information stream (stdout output on master, null elsewhere)
OSstream Sout
OSstream wrapped stdout (std::cout)
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
Foam::argList args(argc, argv)