mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: simplify method names for reading argList options and arguments
- use succincter method names that more closely resemble dictionary
and HashTable method names. This improves method name consistency
between classes and also requires less typing effort:
args.found(optName) vs. args.optionFound(optName)
args.readIfPresent(..) vs. args.optionReadIfPresent(..)
...
args.opt<scalar>(optName) vs. args.optionRead<scalar>(optName)
args.read<scalar>(index) vs. args.argRead<scalar>(index)
- the older method names forms have been retained for code compatibility,
but are now deprecated
This commit is contained in:
@ -96,7 +96,7 @@ int main(int argc, char *argv[])
|
||||
Info<< nl << "Specify an option! " << nl << endl;
|
||||
}
|
||||
|
||||
if (args.optionFound("label"))
|
||||
if (args.found("label"))
|
||||
{
|
||||
FixedList<label, 100000> list1(1);
|
||||
FixedList<label, 100000> list2(0);
|
||||
@ -104,7 +104,7 @@ int main(int argc, char *argv[])
|
||||
runSwapTest(1000001, list1, list2);
|
||||
}
|
||||
|
||||
if (args.optionFound("float"))
|
||||
if (args.found("float"))
|
||||
{
|
||||
FixedList<double, 100000> list1(1.0);
|
||||
FixedList<double, 100000> list2(0.0);
|
||||
@ -112,7 +112,7 @@ int main(int argc, char *argv[])
|
||||
runSwapTest(1000001, list1, list2);
|
||||
}
|
||||
|
||||
if (args.optionFound("vector"))
|
||||
if (args.found("vector"))
|
||||
{
|
||||
FixedList<vector, 100000> list1(vector::one);
|
||||
FixedList<vector, 100000> list2(vector::zero);
|
||||
@ -120,7 +120,7 @@ int main(int argc, char *argv[])
|
||||
runSwapTest(100001, list1, list2);
|
||||
}
|
||||
|
||||
if (args.optionFound("labelList"))
|
||||
if (args.found("labelList"))
|
||||
{
|
||||
typedef labelList testType;
|
||||
testType initVal(500);
|
||||
@ -134,7 +134,7 @@ int main(int argc, char *argv[])
|
||||
runSwapTest(100001, list1, list2);
|
||||
}
|
||||
|
||||
if (args.optionFound("vectorList"))
|
||||
if (args.found("vectorList"))
|
||||
{
|
||||
typedef vectorList testType;
|
||||
testType initVal(500);
|
||||
@ -148,7 +148,7 @@ int main(int argc, char *argv[])
|
||||
runSwapTest(100001, list1, list2);
|
||||
}
|
||||
|
||||
if (args.optionFound("fixedLabel"))
|
||||
if (args.found("fixedLabel"))
|
||||
{
|
||||
typedef FixedList<label,1000> testType;
|
||||
|
||||
@ -163,7 +163,7 @@ int main(int argc, char *argv[])
|
||||
runSwapTest(100001, list1, list2);
|
||||
}
|
||||
|
||||
if (args.optionFound("fixedLabelList"))
|
||||
if (args.found("fixedLabelList"))
|
||||
{
|
||||
typedef labelList testType;
|
||||
typedef FixedList<testType,10> containerType;
|
||||
|
||||
@ -53,8 +53,8 @@ int main(int argc, char *argv[])
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
bool writeObj = args.optionFound("writeObj");
|
||||
bool normalise = args.optionFound("normalise");
|
||||
bool writeObj = args.found("writeObj");
|
||||
bool normalise = args.found("normalise");
|
||||
|
||||
#include "createMesh.H"
|
||||
|
||||
|
||||
@ -151,9 +151,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
const bool optStd = args.optionFound("std");
|
||||
const bool optSet = args.optionFound("set");
|
||||
const bool optFnd = args.optionFound("find");
|
||||
const bool optStd = args.found("std");
|
||||
const bool optSet = args.found("set");
|
||||
const bool optFnd = args.found("find");
|
||||
|
||||
|
||||
cpuTime timer;
|
||||
|
||||
@ -49,9 +49,9 @@ int main(int argc, char *argv[])
|
||||
#include "createTime.H"
|
||||
|
||||
wordReList matcher;
|
||||
if (args.optionFound("re"))
|
||||
if (args.found("re"))
|
||||
{
|
||||
matcher = args.optionReadList<wordRe>("re");
|
||||
matcher = args.readList<wordRe>("re");
|
||||
Info<<"limit names: " << matcher << nl;
|
||||
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ int main(int argc, char *argv[])
|
||||
printInfo(idl3);
|
||||
|
||||
fileName binaryOutput;
|
||||
if (args.optionReadIfPresent("binary", binaryOutput))
|
||||
if (args.readIfPresent("binary", binaryOutput))
|
||||
{
|
||||
Info<<"Writing output to " << binaryOutput << endl;
|
||||
|
||||
|
||||
@ -331,29 +331,29 @@ int main(int argc, char *argv[])
|
||||
|
||||
scalar xxx(-1);
|
||||
|
||||
if (args.optionFound("flag"))
|
||||
if (args.found("flag"))
|
||||
{
|
||||
Info<<"-flag:" << args["flag"] << endl;
|
||||
}
|
||||
|
||||
if (args.optionReadIfPresent<scalar>("float", xxx))
|
||||
if (args.readIfPresent<scalar>("float", xxx))
|
||||
{
|
||||
Info<<"read float " << xxx << endl;
|
||||
}
|
||||
|
||||
if (args.optionFound("reList"))
|
||||
if (args.found("reList"))
|
||||
{
|
||||
reLst = args.optionReadList<wordRe>("reList");
|
||||
reLst = args.readList<wordRe>("reList");
|
||||
}
|
||||
|
||||
if (args.optionFound("wordList"))
|
||||
if (args.found("wordList"))
|
||||
{
|
||||
wLst = args.optionReadList<word>("wordList");
|
||||
wLst = args.readList<word>("wordList");
|
||||
}
|
||||
|
||||
if (args.optionFound("stringList"))
|
||||
if (args.found("stringList"))
|
||||
{
|
||||
sLst = args.optionReadList<string>("stringList");
|
||||
sLst = args.readList<string>("stringList");
|
||||
}
|
||||
|
||||
Info<< nl
|
||||
|
||||
@ -212,28 +212,28 @@ int main(int argc, char *argv[])
|
||||
std::initializer_list<label> increments
|
||||
= {10000, 20000, 40000, 80000, 160000};
|
||||
|
||||
if (args.optionFound("label"))
|
||||
if (args.found("label"))
|
||||
{
|
||||
List<label> list(10, 1);
|
||||
|
||||
runResizeTest(100000, list, increments);
|
||||
}
|
||||
|
||||
if (args.optionFound("float"))
|
||||
if (args.found("float"))
|
||||
{
|
||||
List<double> list(10, 1.0);
|
||||
|
||||
runResizeTest(10000, list, increments);
|
||||
}
|
||||
|
||||
if (args.optionFound("vector"))
|
||||
if (args.found("vector"))
|
||||
{
|
||||
List<vector> list(10, vector::one);
|
||||
|
||||
runResizeTest(10000, list, increments);
|
||||
}
|
||||
|
||||
if (args.optionFound("labelList"))
|
||||
if (args.found("labelList"))
|
||||
{
|
||||
typedef labelList testType;
|
||||
testType initVal(500, label(1));
|
||||
@ -243,7 +243,7 @@ int main(int argc, char *argv[])
|
||||
runResizeTest(200, list, increments);
|
||||
}
|
||||
|
||||
if (args.optionFound("vectorList"))
|
||||
if (args.found("vectorList"))
|
||||
{
|
||||
typedef vectorList testType;
|
||||
testType initVal(500, vector::one);
|
||||
@ -253,7 +253,7 @@ int main(int argc, char *argv[])
|
||||
runResizeTest(100, list, increments);
|
||||
}
|
||||
|
||||
if (args.optionFound("order"))
|
||||
if (args.found("order"))
|
||||
{
|
||||
List<label> list(100000000, 1);
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ int main(int argc, char *argv[])
|
||||
argList args(argc, argv, false, true);
|
||||
|
||||
|
||||
if (args.optionFound("mask"))
|
||||
if (args.found("mask"))
|
||||
{
|
||||
Info<< "bit width: " << unsigned(sizeof(unsigned)*CHAR_BIT) << endl;
|
||||
reportInfo<1>();
|
||||
@ -135,7 +135,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "size: " << packLst.size() << nl;
|
||||
|
||||
if (args.optionFound("count"))
|
||||
if (args.found("count"))
|
||||
{
|
||||
unsigned int rawCount = 0;
|
||||
forAll(rawLst, elemI)
|
||||
@ -149,7 +149,7 @@ int main(int argc, char *argv[])
|
||||
<< "packed count: " << packLst.count() << nl;
|
||||
}
|
||||
|
||||
if (args.optionFound("info"))
|
||||
if (args.found("info"))
|
||||
{
|
||||
packLst.printInfo(Info);
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ Description
|
||||
|
||||
#include "argList.H"
|
||||
#include "IOstreams.H"
|
||||
#include "Switch.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
using namespace Foam;
|
||||
@ -40,9 +41,9 @@ int main(int argc, char *argv[])
|
||||
argList::noParallel();
|
||||
// argList::noFunctionObjects();
|
||||
argList::removeOption("case");
|
||||
|
||||
argList::addOption("label", "value", "Test parsing of label");
|
||||
argList::addOption("label", "value", "Test parsing of label");
|
||||
argList::addOption("scalar", "value", "Test parsing of scalar");
|
||||
argList::addOption("string", "value", "Test string lookup");
|
||||
|
||||
// These are actually lies (never had -parseLabel, -parseScalar etc),
|
||||
// but good for testing...
|
||||
@ -56,10 +57,15 @@ int main(int argc, char *argv[])
|
||||
// Fake a future option...
|
||||
argList::addOptionCompat("label", {"parse-label", 2112});
|
||||
|
||||
argList args(argc, argv);
|
||||
argList::addArgument("label");
|
||||
argList::addArgument("...");
|
||||
argList::addArgument("label");
|
||||
argList::nonMandatoryArgs();
|
||||
|
||||
argList args(argc, argv, false, true);
|
||||
|
||||
Info<<"have: "
|
||||
<<args.optionCount({"label", "scalar"}) << " options" << nl;
|
||||
<<args.count({"label", "scalar"}) << " options" << nl;
|
||||
|
||||
label ival;
|
||||
scalar sval;
|
||||
@ -67,23 +73,59 @@ int main(int argc, char *argv[])
|
||||
Info<< nl;
|
||||
|
||||
Info<< "-label = " << flush;
|
||||
if (args.optionReadIfPresent("label", ival))
|
||||
if (args.readIfPresent("label", ival))
|
||||
{
|
||||
Info<< ival << endl;
|
||||
Info<< ival << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "not specified" << endl;
|
||||
Info<< "not specified" << nl;
|
||||
}
|
||||
|
||||
Info<< "-scalar = " << flush;
|
||||
if (args.optionReadIfPresent("scalar", sval))
|
||||
if (args.readIfPresent("scalar", sval))
|
||||
{
|
||||
Info<< sval << endl;
|
||||
Info<< sval << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "not specified" << endl;
|
||||
Info<< "not specified" << nl;
|
||||
}
|
||||
|
||||
|
||||
// Using direct reading
|
||||
Info<< nl;
|
||||
if (args.found("label"))
|
||||
{
|
||||
Info<< "-label = " << args.opt<label>("label")
|
||||
<< " or " << args.optionRead<label>("label") // old-compat
|
||||
<< " or " << readLabel(args["label"]) // with function
|
||||
<< nl;
|
||||
}
|
||||
|
||||
if (args.found("scalar"))
|
||||
{
|
||||
Info<< "-scalar = " << args.opt<scalar>("scalar")
|
||||
<< " or " << args.optionRead<scalar>("scalar") // old-compat
|
||||
<< " or " << readScalar(args["scalar"]) // with function
|
||||
<< nl;
|
||||
}
|
||||
|
||||
if (args.found("string"))
|
||||
{
|
||||
Info<< "-string = " << args.opt("string")
|
||||
<< " or " << args.optionRead<scalar>("string") // old-compat
|
||||
<< nl;
|
||||
}
|
||||
|
||||
|
||||
// Arg reading
|
||||
Info<< nl;
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
Info<< "arg[" << argi << "] = " << args.read<string>(argi)
|
||||
<< " or " << args.argRead<label>(argi) // old-compat
|
||||
<< nl;
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
@ -74,9 +74,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
const fileName decompFile = args[1];
|
||||
|
||||
const bool region = args.optionFound("region");
|
||||
const bool allRegions = args.optionFound("allRegions");
|
||||
const bool verbose = args.optionFound("verbose");
|
||||
const bool region = args.found("region");
|
||||
const bool allRegions = args.found("allRegions");
|
||||
const bool verbose = args.found("verbose");
|
||||
|
||||
// Set time from database
|
||||
#include "createTime.H"
|
||||
@ -85,7 +85,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Allow override of decomposeParDict location
|
||||
fileName decompDictFile;
|
||||
args.optionReadIfPresent("decomposeParDict", decompDictFile);
|
||||
args.readIfPresent("decomposeParDict", decompDictFile);
|
||||
|
||||
wordList regionNames;
|
||||
wordList regionDirs;
|
||||
@ -109,7 +109,7 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
word regionName;
|
||||
if (args.optionReadIfPresent("region", regionName))
|
||||
if (args.readIfPresent("region", regionName))
|
||||
{
|
||||
regionNames = wordList(1, regionName);
|
||||
regionDirs = regionNames;
|
||||
|
||||
@ -105,15 +105,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const bool region = args.optionFound("region");
|
||||
const bool allRegions = args.optionFound("allRegions");
|
||||
const bool verbose = args.optionFound("verbose");
|
||||
const bool region = args.found("region");
|
||||
const bool allRegions = args.found("allRegions");
|
||||
const bool verbose = args.found("verbose");
|
||||
|
||||
const label numSubdomains =
|
||||
args.optionLookupOrDefault<label>("domains", 0);
|
||||
args.lookupOrDefault<label>("domains", 0);
|
||||
|
||||
const word methodName =
|
||||
args.optionLookupOrDefault<word>("method", word::null);
|
||||
args.lookupOrDefault<word>("method", word::null);
|
||||
|
||||
|
||||
// Set time from database
|
||||
@ -123,7 +123,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Allow override of decomposeParDict location
|
||||
fileName decompDictFile;
|
||||
args.optionReadIfPresent("decomposeParDict", decompDictFile);
|
||||
args.readIfPresent("decomposeParDict", decompDictFile);
|
||||
|
||||
wordList regionNames;
|
||||
wordList regionDirs;
|
||||
@ -147,7 +147,7 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
word regionName;
|
||||
if (args.optionReadIfPresent("region", regionName))
|
||||
if (args.readIfPresent("region", regionName))
|
||||
{
|
||||
regionNames = wordList(1, regionName);
|
||||
regionDirs = regionNames;
|
||||
|
||||
@ -54,8 +54,8 @@ int main(int argc, char *argv[])
|
||||
argList::addArgument("dict .. dictN");
|
||||
argList args(argc, argv, false, true);
|
||||
|
||||
const bool optInfo = args.optionFound("info");
|
||||
const bool optValue = args.optionFound("value");
|
||||
const bool optInfo = args.found("info");
|
||||
const bool optValue = args.found("value");
|
||||
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
|
||||
@ -77,7 +77,7 @@ int main(int argc, char *argv[])
|
||||
// First handle no parameters
|
||||
if (args.size() == 1)
|
||||
{
|
||||
if (args.optionFound("list"))
|
||||
if (args.found("list"))
|
||||
{
|
||||
fileNameList results = findEtcDirs();
|
||||
printList(results);
|
||||
@ -91,7 +91,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
const bool listAll = (args.optionFound("all") || args.optionFound("list"));
|
||||
const bool listAll = (args.found("all") || args.found("list"));
|
||||
|
||||
int error = 0;
|
||||
|
||||
|
||||
@ -45,11 +45,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const label maxCount = args.optionLookupOrDefault<label>("max", 1000);
|
||||
const label maxCount = args.lookupOrDefault<label>("max", 1000);
|
||||
|
||||
externalFileCoupler coupler;
|
||||
|
||||
if (args.optionFound("slave"))
|
||||
if (args.found("slave"))
|
||||
{
|
||||
const word role = "slave";
|
||||
Info<< "Running as " << role << " max=" << maxCount << endl;
|
||||
|
||||
@ -177,9 +177,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Run default tests, unless only specific tests are requested
|
||||
const bool defaultTests =
|
||||
args.optionFound("default") || args.options().empty();
|
||||
args.found("default") || args.options().empty();
|
||||
|
||||
if (args.optionFound("construct"))
|
||||
if (args.found("construct"))
|
||||
{
|
||||
Info<< "From initializer_list<word> = ";
|
||||
fileName file1
|
||||
@ -231,7 +231,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
// Test various ext() methods
|
||||
if (args.optionFound("ext"))
|
||||
if (args.found("ext"))
|
||||
{
|
||||
Info<<nl << nl << "handling of fileName extension" << nl;
|
||||
|
||||
@ -356,7 +356,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
if (args.optionFound("validate"))
|
||||
if (args.found("validate"))
|
||||
{
|
||||
unsigned nFail = 0;
|
||||
Info<< nl << "Test fileName::validate" << nl;
|
||||
|
||||
@ -75,7 +75,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
fileName pathName;
|
||||
if (args.optionReadIfPresent("case", pathName))
|
||||
if (args.readIfPresent("case", pathName))
|
||||
{
|
||||
Info<< nl
|
||||
<< "-case" << nl
|
||||
@ -95,10 +95,8 @@ int main(int argc, char *argv[])
|
||||
printCleaning(pathName);
|
||||
}
|
||||
|
||||
if (args.optionFound("istream"))
|
||||
if (args.readIfPresent("istream", pathName))
|
||||
{
|
||||
args.optionLookup("istream")() >> pathName;
|
||||
|
||||
Info<< nl
|
||||
<< "-case" << nl
|
||||
<< "path = " << args.path() << nl
|
||||
|
||||
@ -45,7 +45,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
label nReps = 10000;
|
||||
|
||||
const point sample = args.argRead<point>(1);
|
||||
const point sample = args.read<point>(1);
|
||||
|
||||
const polyMesh::cellDecomposition decompMode = polyMesh::CELL_TETS;
|
||||
|
||||
|
||||
@ -106,8 +106,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
const word dictName("fvSolution");
|
||||
|
||||
bool optRewrite = args.optionFound("rewrite");
|
||||
bool optShow = args.optionFound("show");
|
||||
bool optRewrite = args.found("rewrite");
|
||||
bool optShow = args.found("show");
|
||||
|
||||
IOdictionary solutionDict
|
||||
(
|
||||
|
||||
@ -49,7 +49,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
argList args(argc, argv, false, true);
|
||||
|
||||
if (args.optionFound("verbose"))
|
||||
if (args.found("verbose"))
|
||||
{
|
||||
labelRange::debug = 1;
|
||||
}
|
||||
@ -101,8 +101,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
{
|
||||
label start = args.argRead<label>(argI);
|
||||
label size = args.argRead<label>(argI+1);
|
||||
label start = args.read<label>(argI);
|
||||
label size = args.read<label>(argI+1);
|
||||
++argI;
|
||||
|
||||
range.reset(start, size);
|
||||
|
||||
@ -196,7 +196,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
{
|
||||
const label celli = args.optionLookupOrDefault("cell", 0);
|
||||
const label celli = args.lookupOrDefault("cell", 0);
|
||||
|
||||
tensorField mI(momentOfInertia::meshInertia(mesh));
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
const string& srcFile = args[argI];
|
||||
|
||||
if (args.optionFound("ext"))
|
||||
if (args.found("ext"))
|
||||
{
|
||||
if (mvBak(srcFile, args["ext"]))
|
||||
{
|
||||
|
||||
@ -166,8 +166,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
recursive = Switch(args[1]);
|
||||
|
||||
const bool optMesh = args.optionFound("mesh");
|
||||
const bool optSkip = args.optionFound("skip");
|
||||
const bool optMesh = args.found("mesh");
|
||||
const bool optSkip = args.found("skip");
|
||||
const objectRegistry& db = (optMesh ? mesh.thisDb() : runTime);
|
||||
|
||||
Info<<"## start ##" << nl;
|
||||
|
||||
@ -66,7 +66,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
vector rotVector;
|
||||
|
||||
if (args.optionReadIfPresent("rollPitchYaw", rotVector))
|
||||
if (args.readIfPresent("rollPitchYaw", rotVector))
|
||||
{
|
||||
Info<< "Rotate by" << nl
|
||||
<< " roll " << rotVector.x() << nl
|
||||
@ -81,7 +81,7 @@ int main(int argc, char *argv[])
|
||||
Info<< "quaternion " << quat << endl;
|
||||
Info<< "rotation = " << quat.R() << endl;
|
||||
}
|
||||
if (args.optionReadIfPresent("yawPitchRoll", rotVector))
|
||||
if (args.readIfPresent("yawPitchRoll", rotVector))
|
||||
{
|
||||
Info<< "Rotate by" << nl
|
||||
<< " yaw " << rotVector.x() << nl
|
||||
@ -96,11 +96,11 @@ int main(int argc, char *argv[])
|
||||
Info<< "quaternion " << quat << endl;
|
||||
Info<< "rotation = " << quat.R() << endl;
|
||||
}
|
||||
if (args.optionFound("rotate-angle"))
|
||||
if (args.found("rotate-angle"))
|
||||
{
|
||||
const Tuple2<vector, scalar> axisAngle
|
||||
(
|
||||
args.optionLookup("rotate-angle")()
|
||||
args.lookup("rotate-angle")()
|
||||
);
|
||||
|
||||
Info<< "Rotate" << nl
|
||||
|
||||
@ -63,9 +63,9 @@ int main(int argc, char *argv[])
|
||||
args.printUsage();
|
||||
}
|
||||
|
||||
bool useBSpline = args.optionFound("B");
|
||||
bool useCatmullRom = args.optionFound("CMR");
|
||||
label nSeg = args.optionLookupOrDefault<label>("n", 20);
|
||||
bool useBSpline = args.found("B");
|
||||
bool useCatmullRom = args.found("CMR");
|
||||
label nSeg = args.lookupOrDefault<label>("n", 20);
|
||||
|
||||
if (!useCatmullRom && !useBSpline)
|
||||
{
|
||||
|
||||
@ -105,18 +105,12 @@ int main(int argc, char *argv[])
|
||||
args.printUsage();
|
||||
}
|
||||
|
||||
const bool keepEmpty = args.optionFound("empty");
|
||||
const bool keepEmpty = args.found("empty");
|
||||
|
||||
int nopts = 0;
|
||||
for (auto optName : { "any", "slash", "space", "sub", "fixed", "char" })
|
||||
{
|
||||
if (args.optionFound(optName))
|
||||
{
|
||||
++nopts;
|
||||
}
|
||||
}
|
||||
const label nopts =
|
||||
args.count({"any", "slash", "space", "sub", "fixed", "char"});
|
||||
|
||||
if (args.optionFound("any"))
|
||||
if (args.found("any"))
|
||||
{
|
||||
const std::string& str = args["any"];
|
||||
Info<< "split on any chars" << nl
|
||||
@ -135,7 +129,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (args.optionFound("sub"))
|
||||
if (args.found("sub"))
|
||||
{
|
||||
const std::string& str = args["sub"];
|
||||
Info<< "split on substring" << nl
|
||||
@ -154,7 +148,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (args.optionFound("space"))
|
||||
if (args.found("space"))
|
||||
{
|
||||
Info<< "split on space" << nl
|
||||
<< "~~~~~~~~~~~~~~" << nl;
|
||||
@ -171,7 +165,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (args.optionFound("char"))
|
||||
if (args.found("char"))
|
||||
{
|
||||
const char delim = args["char"][0];
|
||||
|
||||
@ -190,9 +184,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (args.optionFound("fixed"))
|
||||
if (args.found("fixed"))
|
||||
{
|
||||
const label width = readLabel(args["fixed"]);
|
||||
const label width = args.opt<label>("fixed");
|
||||
|
||||
Info<< "split on fixed width = " << width << nl
|
||||
<< "~~~~~~~~~~~~~~" << nl;
|
||||
@ -210,7 +204,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Default
|
||||
if (!nopts || args.optionFound("slash"))
|
||||
if (!nopts || args.found("slash"))
|
||||
{
|
||||
const char delim = '/';
|
||||
|
||||
|
||||
@ -128,7 +128,7 @@ int main(int argc, char *argv[])
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
const scalar scaleFactor = args.optionLookupOrDefault<scalar>("scale", -1);
|
||||
const scalar scaleFactor = args.lookupOrDefault<scalar>("scale", -1);
|
||||
|
||||
const word outputFile(args.executable() + ".obj");
|
||||
|
||||
@ -145,18 +145,18 @@ int main(int argc, char *argv[])
|
||||
Info<< endl;
|
||||
|
||||
|
||||
if (args.optionFound("debug2"))
|
||||
if (args.found("debug2"))
|
||||
{
|
||||
surfaceIntersection::debug |= 2;
|
||||
}
|
||||
if (args.optionFound("debug4"))
|
||||
if (args.found("debug4"))
|
||||
{
|
||||
surfaceIntersection::debug |= 4;
|
||||
}
|
||||
const bool optPrint = args.optionFound("print");
|
||||
const bool optPrint = args.found("print");
|
||||
|
||||
dictionary intersectOptions;
|
||||
if (args.optionFound("dict"))
|
||||
if (args.found("dict"))
|
||||
{
|
||||
intersectOptions = IOdictionary
|
||||
(
|
||||
@ -190,12 +190,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
word mergeOp;
|
||||
if (args.optionFound("mergePoints"))
|
||||
if (args.found("mergePoints"))
|
||||
{
|
||||
cuts.mergePoints(args.optionRead<scalar>("mergePoints"));
|
||||
cuts.mergePoints(args.opt<scalar>("mergePoints"));
|
||||
mergeOp = "mergePoints";
|
||||
}
|
||||
else if (args.optionFound("mergeEdges"))
|
||||
else if (args.found("mergeEdges"))
|
||||
{
|
||||
cuts.mergeEdges();
|
||||
mergeOp = "mergeEdges";
|
||||
|
||||
@ -142,8 +142,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const bool optStdout = args.optionFound("stdout");
|
||||
const scalar scaleFactor = args.optionLookupOrDefault("scale", 0.0);
|
||||
const bool optStdout = args.found("stdout");
|
||||
const scalar scaleFactor = args.lookupOrDefault("scale", 0.0);
|
||||
|
||||
const fileName importName = args[1];
|
||||
const fileName exportName = optStdout ? "-stdout" : args[2];
|
||||
@ -157,7 +157,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if
|
||||
(
|
||||
!args.optionFound("triSurface")
|
||||
!args.found("triSurface")
|
||||
&&
|
||||
(
|
||||
!MeshedSurface<face>::canRead(importName, true)
|
||||
@ -172,7 +172,7 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (args.optionFound("triSurface"))
|
||||
if (args.found("triSurface"))
|
||||
{
|
||||
triSurface surf(importName);
|
||||
|
||||
@ -198,14 +198,14 @@ int main(int argc, char *argv[])
|
||||
// surf2.read(is); // FAIL: private method
|
||||
}
|
||||
|
||||
if (args.optionFound("orient"))
|
||||
if (args.found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (args.optionFound("clean"))
|
||||
if (args.found("clean"))
|
||||
{
|
||||
Info<< "Cleaning up surface" << endl;
|
||||
surf.cleanup(true);
|
||||
@ -234,10 +234,10 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
// normally write sorted (looks nicer)
|
||||
surf.write(exportName, !args.optionFound("unsorted"));
|
||||
surf.write(exportName, !args.found("unsorted"));
|
||||
}
|
||||
}
|
||||
else if (args.optionFound("unsorted"))
|
||||
else if (args.found("unsorted"))
|
||||
{
|
||||
UnsortedMeshedSurface<face> surf(importName);
|
||||
|
||||
@ -263,14 +263,14 @@ int main(int argc, char *argv[])
|
||||
// surf2.read(is); // FAIL: private method
|
||||
}
|
||||
|
||||
if (args.optionFound("orient"))
|
||||
if (args.found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (args.optionFound("clean"))
|
||||
if (args.found("clean"))
|
||||
{
|
||||
Info<< "Cleaning up surface" << endl;
|
||||
surf.cleanup(true);
|
||||
@ -301,7 +301,7 @@ int main(int argc, char *argv[])
|
||||
surf.write(exportName);
|
||||
}
|
||||
}
|
||||
else if (args.optionFound("triFace"))
|
||||
else if (args.found("triFace"))
|
||||
{
|
||||
MeshedSurface<triFace> surf(importName);
|
||||
|
||||
@ -327,14 +327,14 @@ int main(int argc, char *argv[])
|
||||
// surf2.read(is); // FAIL: private method
|
||||
}
|
||||
|
||||
if (args.optionFound("orient"))
|
||||
if (args.found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (args.optionFound("clean"))
|
||||
if (args.found("clean"))
|
||||
{
|
||||
Info<< "Cleaning up surface" << endl;
|
||||
surf.cleanup(true);
|
||||
@ -391,14 +391,14 @@ int main(int argc, char *argv[])
|
||||
// surf2.read(is); // FAIL: private method
|
||||
}
|
||||
|
||||
if (args.optionFound("orient"))
|
||||
if (args.found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (args.optionFound("clean"))
|
||||
if (args.found("clean"))
|
||||
{
|
||||
Info<< "Cleaning up surface" << endl;
|
||||
surf.cleanup(true);
|
||||
@ -406,7 +406,7 @@ int main(int argc, char *argv[])
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (args.optionFound("testModify"))
|
||||
if (args.found("testModify"))
|
||||
{
|
||||
Info<< "Use ModifiableMeshedSurface to shift (1, 0, 0)" << endl;
|
||||
Info<< "original" << nl;
|
||||
@ -457,7 +457,7 @@ int main(int argc, char *argv[])
|
||||
surf.write(exportName);
|
||||
}
|
||||
|
||||
if (args.optionFound("surfMesh"))
|
||||
if (args.found("surfMesh"))
|
||||
{
|
||||
Foam::Time runTime
|
||||
(
|
||||
|
||||
@ -51,9 +51,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
argList args(argc, argv, false, true);
|
||||
|
||||
const label repeat = args.optionLookupOrDefault<label>("repeat", 1);
|
||||
const label repeat = args.lookupOrDefault<label>("repeat", 1);
|
||||
|
||||
const bool optVerbose = args.optionFound("verbose");
|
||||
const bool optVerbose = args.found("verbose");
|
||||
|
||||
cpuTime timer;
|
||||
for (label count = 0; count < repeat; ++count)
|
||||
@ -111,7 +111,7 @@ int main(int argc, char *argv[])
|
||||
<< timer.cpuTimeIncrement() << " s\n\n";
|
||||
|
||||
fileName inputFile;
|
||||
if (args.optionReadIfPresent("file", inputFile))
|
||||
if (args.readIfPresent("file", inputFile))
|
||||
{
|
||||
IFstream is(inputFile);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user