Commit 37f772b2 authored by Mark Olesen's avatar Mark Olesen

STYLE: modernize argList usage

parent c2df77e7
......@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
argList::validArgs.append("output surface file");
argList args(argc, argv);
fileName inFileName(args.args()[1]);
fileName outFileName(args.args()[2]);
fileName inFileName(args[1]);
fileName outFileName(args[2]);
if (inFileName.ext() != "flma")
{
......
......@@ -105,12 +105,12 @@ int main(int argc, char *argv[])
argList::validArgs.append("input surface file");
argList::validArgs.append("output surface file");
argList::validOptions.insert("exportSubsets", "");
argList::validOptions.insert("exportFeatureEdges", "");
argList::addBoolOption("exportSubsets");
argList::addBoolOption("exportFeatureEdges");
argList args(argc, argv);
fileName inFileName(args.args()[1]);
fileName outFileName(args.args()[2]);
const fileName inFileName(args[1]);
const fileName outFileName(args[2]);
fileName outFileNoExt = outFileName.lessExt();
fileName outExtension = outFileName.ext();
......@@ -125,7 +125,7 @@ int main(int argc, char *argv[])
origSurf.writeSurface(outFileName);
// export surface subsets as separate surface meshes
if (args.options().found("exportSubsets"))
if (args.optionFound("exportSubsets"))
{
DynList<label> subsetIDs;
origSurf.facetSubsetIndices(subsetIDs);
......@@ -150,7 +150,7 @@ int main(int argc, char *argv[])
}
}
if (args.options().found("exportFeatureEdges"))
if (args.optionFound("exportFeatureEdges"))
{
fileName fName = outFileNoExt+"_featureEdges";
fName += ".vtk";
......
......@@ -333,8 +333,8 @@ int main(int argc, char *argv[])
argList args(argc, argv);
// Process commandline arguments
fileName inFileName(args.args()[1]);
fileName outPrefix(args.args()[2]);
fileName inFileName(args[1]);
fileName outPrefix(args[2]);
// Read original surface
triSurf origSurf(inFileName);
......
......@@ -44,7 +44,7 @@ int main(int argc, char *argv[])
argList::validArgs.append("input surface file");
argList args(argc, argv);
const fileName inFileName(args.args()[1]);
const fileName inFileName(args[1]);
triSurf surf(inFileName);
......
......@@ -47,8 +47,8 @@ int main(int argc, char *argv[])
argList::validArgs.append("patch/subset name");
argList args(argc, argv);
const fileName inFileName(args.args()[1]);
const fileName outFileName(args.args()[2]);
const fileName inFileName(args[1]);
const fileName outFileName(args[2]);
if (outFileName == inFileName)
{
......@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
}
wordList patches(1);
patches[0] = args.args()[3];
patches[0] = args[3];
triSurf originalSurface(inFileName);
......
......@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
argList args(argc, argv);
fileName inFileName(args.args()[1]);
fileName outFileName(args.args()[2]);
fileName inFileName(args[1]);
fileName outFileName(args[2]);
// read the input surface
triSurf origSurf(inFileName);
......
......@@ -53,12 +53,13 @@ void generateLayer
{
const dictionary& bndLayers = meshDict.subDict("boundaryLayers");
if (bndLayers.found("nLayers"))
label nLayers;
if (bndLayers.readIfPresent("nLayers", nLayers))
{
const label nLayers = readLabel(bndLayers.lookup("nLayers"));
if (nLayers > 0)
{
bl.addLayerForAllPatches();
}
}
else if (bndLayers.found("patchBoundaryLayers"))
{
......@@ -106,7 +107,7 @@ void layerRefinement(polyMeshGen& mesh, const dictionary& meshDict)
int main(int argc, char *argv[])
{
argList::validOptions.insert("2DLayers", "bool");
argList::addBoolOption("2DLayers");
# include "setRootCase.H"
# include "createTime.H"
......@@ -127,9 +128,7 @@ int main(int argc, char *argv[])
polyMeshGen pmg(runTime);
pmg.read();
bool is2DLayer(false);
if (args.options().found("2DLayers"))
is2DLayer = true;
const bool is2DLayer = args.optionFound("2DLayers");
// generate the initial boundary layer
generateLayer(pmg, meshDict, is2DLayer);
......
......@@ -50,8 +50,8 @@ int main(int argc, char *argv[])
argList args(argc, argv);
fileName inFileName(args.args()[1]);
fileName importFileName(args.args()[2]);
fileName inFileName(args[1]);
fileName importFileName(args[2]);
triSurf originalSurface(inFileName);
......
......@@ -39,64 +39,48 @@ int main(int argc, char *argv[])
{
argList::validArgs.clear();
argList::validOptions.insert("nLoops", "int");
argList::validOptions.insert("nIterations", "int");
argList::validOptions.insert("nSurfaceIterations", "int");
argList::validOptions.insert("qualityThreshold", "scalar");
argList::validOptions.insert("constrainedCellsSet", "word");
argList::addOption("nLoops", "int");
argList::addOption("nIterations", "int");
argList::addOption("nSurfaceIterations", "int");
argList::addOption("qualityThreshold", "scalar");
argList::addOption("constrainedCellsSet", "word");
# include "setRootCase.H"
# include "createTime.H"
// read the settings
// Defaults
label nIterations(50);
label nLoops(10);
label nSurfaceIterations(2);
scalar qualityThreshold(0.1);
if (args.options().found("nLoops"))
{
nLoops = readLabel(args["nLoops"]);
}
else
{
Info<< "Default number of loops is 10" << endl;
}
// Read the settings
if (args.options().found("nIterations"))
{
nIterations = readLabel(args["nIterations"]);
}
else
if (!args.optionReadIfPresent("nLoops", nLoops))
{
Info<< "Default number of iterations is 50" << endl;
Info<< "Default number of loops is "
<< nLoops << endl;
}
if (args.options().found("nSurfaceIterations"))
if (!args.optionReadIfPresent("nIterations", nIterations))
{
nSurfaceIterations = readLabel(args["nSurfaceIterations"]);
}
else
{
Info<< "Default number of surface iterations is 2" << endl;
Info<< "Default number of iterations is "
<< nIterations << endl;
}
if (args.options().found("qualityThreshold"))
if (!args.optionReadIfPresent("nSurfaceIterations", nSurfaceIterations))
{
qualityThreshold = readScalar(args["qualityThreshold"]);
Info<< "Default number of surface iterations is "
<< nSurfaceIterations << endl;
}
else
if (!args.optionReadIfPresent("qualityThreshold", qualityThreshold))
{
Info<< "Using default quality threshold 0.1" << endl;
}
word constrainedCellSet;
if (args.options().found("constrainedCellsSet"))
{
constrainedCellSet = args.options()["constrainedCellsSet"];
}
else
if (!args.optionReadIfPresent("constrainedCellSet", constrainedCellSet))
{
Info<< "No constraints applied on the smoothing procedure" << endl;
}
......
......@@ -300,31 +300,26 @@ int main(int argc, char *argv[])
argList::validArgs.append("input surface file");
argList::validArgs.append("new patch");
argList::validOptions.insert("patchNames", "list of names");
argList::validOptions.insert("patchIds", "list of patchIds");
argList::validOptions.insert("patchIdRange", "(start end)");
argList::validOptions.insert("output", "file name (default overwrite)");
argList::validOptions.insert("keep", "");
argList::addOption("patchNames", "list of names");
argList::addOption("patchIds", "list of patchIds");
argList::addOption("patchIdRange", "(start end)");
argList::addOption("output", "file name (default overwrite)");
argList::addBoolOption("keep");
argList args(argc, argv);
// Process commandline arguments
fileName inFileName(args.args()[1]);
fileName inFileName(args[1]);
word newPatchName(args.args()[2]);
word newPatchName(args[2]);
fileName outFileName(inFileName);
if (args.options().found("output"))
if (args.optionFound("output"))
{
outFileName = args.options()["output"];
outFileName = args["output"];
}
bool keepPatches = false;
if (args.options().found("keep"))
{
keepPatches = true;
}
const bool keepPatches = args.optionFound("keep");
// Read original surface
triSurf origSurf(inFileName);
......@@ -334,13 +329,13 @@ int main(int argc, char *argv[])
if (args.options().found("patchNames"))
{
if (args.options().found("patchIds"))
if (args.optionFound("patchIds"))
{
FatalError() << "Cannot specify both patch names and ids"
<< Foam::abort(FatalError);
}
IStringStream is(args.options()["patchNames"]);
IStringStream is(args["patchNames"]);
wordList patchNames(is);
getPatchIds
......@@ -351,17 +346,16 @@ int main(int argc, char *argv[])
);
}
if (args.options().found("patchIds"))
if (args.optionFound("patchIds"))
{
IStringStream is(args.options()["patchIds"]);
IStringStream is(args["patchIds"]);
patchIds.append(labelList(is));
}
if (args.options().found("patchIdRange"))
if (args.optionFound("patchIdRange"))
{
IStringStream is(args.options()["patchIdRange"]);
IStringStream is(args["patchIdRange"]);
Pair<label> idRange(is);
for (label id = idRange.first(); id <= idRange.second(); id++)
......
......@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
argList::validArgs.append("output surface file");
argList args(argc, argv);
fileName inFileName(args.args()[1]);
fileName outFileName(args.args()[2]);
fileName inFileName(args[1]);
fileName outFileName(args[2]);
if (outFileName.ext() != "fms")
Warning << "The subsets cann only be saved in the .fms format" << endl;
......
......@@ -46,9 +46,9 @@ int main(int argc, char *argv[])
argList args(argc, argv);
fileName inFileName(args.args()[1]);
fileName outFileName(args.args()[2]);
word patchName(args.args()[3]);
fileName inFileName(args[1]);
fileName outFileName(args[2]);
word patchName(args[3]);
// read the input surface
triSurf origSurf(inFileName);
......
......@@ -125,8 +125,8 @@ int main(int argc, char *argv[])
argList::validArgs.append("subset");
argList args(argc, argv);
fileName inFileName(args.args()[1]);
word subsetName(args.args()[2]);
fileName inFileName(args[1]);
word subsetName(args[2]);
triSurf* origSurfPtr = new triSurf(inFileName);
......
......@@ -49,11 +49,11 @@ int main(int argc, char *argv[])
argList::validArgs.clear();
argList::validArgs.append("input surface file");
argList::validArgs.append("output surface file");
argList::validOptions.insert("angle", "scalar");
argList::addOption("angle", "scalar");
argList args(argc, argv);
fileName inFileName(args.args()[1]);
fileName outFileName(args.args()[2]);
const fileName inFileName(args[1]);
const fileName outFileName(args[2]);
if (outFileName == inFileName)
{
......@@ -64,12 +64,7 @@ int main(int argc, char *argv[])
}
scalar tol(45.0);
if (args.options().found("angle"))
{
const scalar ang = readScalar(args["angle"]);
tol = ang;
}
else
if (!args.optionReadIfPresent("angle", tol))
{
Info<< "Using 45 deg as default angle!" << endl;
}
......
......@@ -56,8 +56,8 @@ int main(int argc, char *argv[])
argList args(argc, argv);
fileName inFileName(args.args()[1]);
fileName outFileName(args.args()[2]);
fileName inFileName(args[1]);
fileName outFileName(args[2]);
if (outFileName == inFileName)
{
......@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
for (label i = 3; i < 9; ++i)
{
std::stringstream ss;
ss << args.args()[i];
ss << args[i];
scalar s;
ss >> s;
......
......@@ -43,10 +43,12 @@ int main(int argc, char *argv[])
argList::validArgs.append("input surface file");
argList args(argc, argv);
const fileName inFileName(args.args()[1]);
const fileName inFileName(args[1]);
if (inFileName.ext() == "fms")
{
FatalError << "trying to convert a fms file to itself"
<< exit(FatalError);
}
fileName outFileName(inFileName.lessExt()+".fms");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment