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

STYLE: modernize argList usage

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