94static bool hasReadWriteTypes(
const word& readType,
const word& writeType)
96 volatile bool good =
true;
114int main(
int argc,
char *argv[])
118 "Convert between surface formats, using MeshSurface library components"
128 "Perform some surface checking/cleanup on the input surface"
135 "Input format (default: use file extension)"
141 "Output format (default: use file extension)"
147 "Input geometry scaling factor"
153 "Output geometry scaling factor"
165 "The source coordinate system, applied after '-read-scale'",
172 "The target coordinate system, applied before '-write-scale'",
178 "Triangulate surface"
187 const int optVerbose =
args.verbose();
189 if (importName == exportName)
192 <<
"Output file would overwrite input file."
196 const word readFileType
198 args.getOrDefault<
word>(
"read-format", getExtension(importName))
201 const word writeFileType
203 args.getOrDefault<
word>(
"write-format", getExtension(exportName))
208 if (!hasReadWriteTypes(readFileType, writeFileType))
211 <<
"Unsupported file format(s)" <<
nl
216 scalar scaleFactor(0);
222 if (
args.found(
"from") ||
args.found(
"to"))
228 coordinateSystems::typeName,
241 <<
"Cannot open coordinateSystems file\n "
248 if (
args.found(
"from"))
251 const auto* csPtr = globalCoords.cfind(csName);
256 <<
"Cannot find -from " << csName <<
nl
257 <<
"available coordinateSystems: "
265 if (
args.found(
"to"))
268 const auto* csPtr = globalCoords.cfind(csName);
273 <<
"Cannot find -to " << csName <<
nl
274 <<
"available coordinateSystems: "
283 if (fromCsys && toCsys)
286 <<
"Only allowed '-from' or '-to' option at the moment."
295 if (
args.readIfPresent(
"read-scale", scaleFactor) && scaleFactor > 0)
297 Info<<
"scale input " << scaleFactor <<
nl;
298 surf.scalePoints(scaleFactor);
301 if (
args.found(
"clean"))
303 surf.cleanup(optVerbose);
308 Info<<
"move points from coordinate system: "
309 << fromCsys->name() <<
nl;
311 surf.movePoints(tpf());
316 Info<<
"move points to coordinate system: "
317 << toCsys->name() <<
nl;
319 surf.movePoints(tpf());
322 if (
args.readIfPresent(
"write-scale", scaleFactor) && scaleFactor > 0)
324 Info<<
"scale output " << scaleFactor <<
nl;
325 surf.scalePoints(scaleFactor);
328 if (
args.found(
"tri"))
330 Info<<
"triangulate" <<
nl;
334 Info<<
"writing " << exportName;
335 surf.write(exportName, writeFileType);
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (respects is_globalIOobject trait) and check its info. A void type suppresses trait and t...
static IOobject selectIO(const IOobject &io, const fileName &altFile, const word &ioName="")
Return the IOobject, but also consider an alternative file name.
fileName objectPath() const
The complete path + object name.
static bool canWriteType(const word &fileType, bool verbose=false)
static bool canReadType(const word &fileType, bool verbose=false)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
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.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
A centralized collection of named coordinate systems.
A class for handling file names.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
MeshedSurface< face > meshedSurface
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
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)