81static bool hasReadWriteTypes(
const word& readType,
const word& writeType)
83 volatile bool good =
true;
101int main(
int argc,
char *argv[])
105 "Convert between surface formats, using triSurface library components"
115 "Perform some surface checking/cleanup on the input surface"
120 "Reorder faces into groups; one per region"
126 "The input format (default: use file extension)"
132 "The output format (default: use file extension)"
138 "Input geometry scaling factor"
144 "The output precision"
152 const unsigned prec =
args.getOrDefault<
unsigned>(
"precision", 0u);
155 Info<<
"Output write precision set to " << prec <<
endl;
158 Sout.precision(prec);
165 const int optVerbose =
args.verbose();
167 if (importName == exportName)
170 <<
"Output file would overwrite input file." <<
nl
174 const word readFileType
176 args.getOrDefault<
word>(
"read-format", getExtension(importName))
179 const word writeFileType
181 args.getOrDefault<
word>(
"write-format", getExtension(exportName))
186 if (!hasReadWriteTypes(readFileType, writeFileType))
189 <<
"Unsupported file format(s)" <<
nl
194 scalar scaleFactor(0);
196 Info<<
"Reading : " << importName <<
endl;
197 triSurface surf(importName, readFileType, scaleFactor);
199 if (
args.readIfPresent(
"scale", scaleFactor) && scaleFactor > 0)
201 Info<<
"scale input " << scaleFactor <<
nl;
202 surf.scalePoints(scaleFactor);
207 surf.writeStats(
Info);
210 if (
args.found(
"clean"))
212 Info<<
"Cleaning up surface" <<
endl;
213 surf.cleanup(optVerbose);
215 Info<<
"After cleaning up surface:" <<
endl;
216 surf.writeStats(
Info);
220 const bool sortByRegion =
args.found(
"group");
223 Info<<
"Reordering faces into groups; one per region." <<
endl;
227 Info<<
"Maintaining face ordering" <<
endl;
230 Info<<
"writing " << exportName <<
endl;
232 surf.write(exportName, writeFileType, sortByRegion);
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
static unsigned int defaultPrecision() noexcept
Return the default precision.
Extract command arguments and options from the supplied argc and argv parameters.
static void addVerboseOption(const string &usage="", bool advanced=false)
Enable a 'verbose' bool option, with usage information.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
static void noParallel()
Remove the parallel options.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
static void addNote(const string ¬e)
Add extra notes for the usage information.
static void addOptionCompat(const word &optName, std::pair< const char *, int > compat)
Specify an alias for the option name.
A class for handling file names.
Triangulated surface description with patch information.
static bool canWriteType(const word &fileType, bool verbose=false)
Can we write this file format?
static bool canReadType(const word &fileType, bool verbose=false)
Can we read this file format?
A class for handling words, derived from Foam::string.
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.
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)
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)