94static bool hasReadWriteTypes(
const word& readType,
const word& writeType)
96 volatile bool good =
true;
98 if (!meshedSurface::canReadType(readType,
true))
103 if (!meshedSurface::canWriteType(writeType,
true))
114int main(
int argc,
char *argv[])
118 "Convert between surface formats, using MeshSurface library components"
121 argList::noParallel();
122 argList::addArgument(
"input",
"The input surface file");
123 argList::addArgument(
"output",
"The output surface file");
125 argList::addBoolOption
128 "Perform some surface checking/cleanup on the input surface"
134 "Input format (default: use file extension)"
140 "Output format (default: use file extension)"
146 "Input geometry scaling factor"
152 "Output geometry scaling factor"
155 argList::addOptionCompat(
"read-scale", {
"scaleIn", 1912});
156 argList::addOptionCompat(
"write-scale", {
"scaleOut", 1912});
158 argList::addOption(
"dict",
"file",
"Alternative coordinateSystems");
164 "The source coordinate system, applied after '-read-scale'",
171 "The target coordinate system, applied before '-write-scale'",
174 argList::addBoolOption
177 "Triangulate surface"
187 if (importName == exportName)
190 <<
"Output file would overwrite input file."
194 const word readFileType
199 const word writeFileType
206 if (!hasReadWriteTypes(readFileType, writeFileType))
209 <<
"Unsupported file format(s)" <<
nl
214 scalar scaleFactor(0);
222 IOobject ioCsys = IOobject::selectIO
226 coordinateSystems::typeName,
239 <<
"Cannot open coordinateSystems file\n "
249 const auto* csPtr = globalCoords.cfind(csName);
254 <<
"Cannot find -from " << csName <<
nl
255 <<
"available coordinateSystems: "
266 const auto* csPtr = globalCoords.cfind(csName);
271 <<
"Cannot find -to " << csName <<
nl
272 <<
"available coordinateSystems: "
281 if (fromCsys && toCsys)
284 <<
"Only allowed '-from' or '-to' option at the moment."
295 Info<<
"scale input " << scaleFactor <<
nl;
296 surf.scalePoints(scaleFactor);
306 Info<<
"move points from coordinate system: "
307 << fromCsys->name() <<
nl;
309 surf.movePoints(tpf());
314 Info<<
"move points to coordinate system: "
315 << toCsys->name() <<
nl;
317 surf.movePoints(tpf());
322 Info<<
"scale output " << scaleFactor <<
nl;
323 surf.scalePoints(scaleFactor);
328 Info<<
"triangulate" <<
nl;
332 Info<<
"writing " << exportName;
333 surf.write(exportName, writeFileType);
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 (uses typeFilePath to find file) and check its info.
fileName objectPath() const
The complete path + object name.
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.
T get(const label index) const
Get a value from the argument at index.
const fileName & rootPath() const noexcept
Return root path.
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.
const fileName & caseName() const noexcept
Return case name (parallel run) or global case (serial run)
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
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.
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)
Ostream & endl(Ostream &os)
Add newline and flush stream.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
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)