mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: provide operator[] for accessing argList options.
- operator[] with label -> get args at index - operator[] with word -> get named option
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -90,7 +90,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("flag"))
|
||||
{
|
||||
Info<<"-flag:" << args.option("flag") << endl;
|
||||
Info<<"-flag:" << args["flag"] << endl;
|
||||
}
|
||||
|
||||
if (args.optionReadIfPresent<scalar>("float", xxx))
|
||||
|
||||
@ -58,7 +58,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("ext"))
|
||||
{
|
||||
if (mvBak(srcFile, args.option("ext")))
|
||||
if (mvBak(srcFile, args["ext"]))
|
||||
{
|
||||
ok++;
|
||||
}
|
||||
|
||||
@ -94,11 +94,11 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
for (label count = 0; count < repeat; ++count)
|
||||
{
|
||||
IFstream is(args.option("file"));
|
||||
IFstream is(args["file"]);
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
Info<< "tokenizing file: " << args.option("file") << nl;
|
||||
Info<< "tokenizing file: " << args["file"] << nl;
|
||||
}
|
||||
|
||||
while (is.good())
|
||||
|
||||
@ -101,20 +101,17 @@ int main(int argc, char *argv[])
|
||||
// List of cells to refine
|
||||
//
|
||||
|
||||
bool useSet = args.optionFound("useSet");
|
||||
|
||||
if (useSet)
|
||||
word setName;
|
||||
if (args.optionReadIfPresent("useSet", setName))
|
||||
{
|
||||
word setName(args.option("useSet"));
|
||||
|
||||
Info<< "Subsetting cells to cut based on cellSet" << setName << endl
|
||||
<< endl;
|
||||
Info<< "Subsetting cells to cut based on cellSet"
|
||||
<< setName << nl << endl;
|
||||
|
||||
cellSet cells(mesh, setName);
|
||||
|
||||
Info<< "Read " << cells.size() << " cells from cellSet "
|
||||
<< cells.instance()/cells.local()/cells.name()
|
||||
<< endl << endl;
|
||||
<< nl << endl;
|
||||
|
||||
for
|
||||
(
|
||||
@ -125,8 +122,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
cutCells.erase(iter.key());
|
||||
}
|
||||
Info<< "Removed from cells to cut all the ones not in set " << setName
|
||||
<< endl << endl;
|
||||
Info<< "Removed from cells to cut all the ones not in set "
|
||||
<< setName << nl << endl;
|
||||
}
|
||||
|
||||
// Mark all meshpoints on patch
|
||||
@ -180,9 +177,9 @@ int main(int argc, char *argv[])
|
||||
allCutEdges.shrink();
|
||||
allCutEdgeWeights.shrink();
|
||||
|
||||
Info<< "Cutting:" << endl
|
||||
<< " cells:" << cutCells.size() << endl
|
||||
<< " edges:" << allCutEdges.size() << endl
|
||||
Info<< "Cutting:" << nl
|
||||
<< " cells:" << cutCells.size() << nl
|
||||
<< " edges:" << allCutEdges.size() << nl
|
||||
<< endl;
|
||||
|
||||
// Transfer DynamicLists to straight ones.
|
||||
|
||||
@ -552,7 +552,7 @@ int main(int argc, char *argv[])
|
||||
<< "edge snapping tol : " << edgeTol << nl;
|
||||
if (readSet)
|
||||
{
|
||||
Info<< "candidate cells : cellSet " << args.option("set") << nl;
|
||||
Info<< "candidate cells : cellSet " << args["set"] << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -580,7 +580,7 @@ int main(int argc, char *argv[])
|
||||
if (readSet)
|
||||
{
|
||||
// Read cells to cut from cellSet
|
||||
cellSet cells(mesh, args.option("set"));
|
||||
cellSet cells(mesh, args["set"]);
|
||||
|
||||
cellsToCut = cells;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -68,15 +68,12 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
|
||||
fileName kivaFileName("otape17");
|
||||
if (args.optionFound("file"))
|
||||
{
|
||||
kivaFileName = args.option("file");
|
||||
}
|
||||
args.optionReadIfPresent("file", kivaFileName);
|
||||
|
||||
kivaVersions kivaVersion = kiva3v;
|
||||
if (args.optionFound("version"))
|
||||
{
|
||||
word kivaVersionName = args.option("version");
|
||||
const word kivaVersionName = args["version"];
|
||||
|
||||
if (kivaVersionName == "kiva3")
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -463,7 +463,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (doCellSet)
|
||||
{
|
||||
word setName(args.option("cellSet"));
|
||||
const word setName = args["cellSet"];
|
||||
|
||||
cellSet cells(mesh, setName);
|
||||
|
||||
@ -475,7 +475,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (doFaceSet)
|
||||
{
|
||||
word setName(args.option("faceSet"));
|
||||
const word setName = args["faceSet"];
|
||||
|
||||
faceSet faces(mesh, setName);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -110,7 +110,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("dict"))
|
||||
{
|
||||
fileName dictPath(args.option("dict"));
|
||||
const fileName dictPath = args["dict"];
|
||||
|
||||
meshDictIoPtr.set
|
||||
(
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -835,15 +835,14 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
|
||||
bool writeVTK = !args.optionFound("noVTK");
|
||||
bool loop = args.optionFound("loop");
|
||||
bool batch = args.optionFound("batch");
|
||||
|
||||
const bool writeVTK = !args.optionFound("noVTK");
|
||||
const bool loop = args.optionFound("loop");
|
||||
const bool batch = args.optionFound("batch");
|
||||
|
||||
if (loop && !batch)
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Can only loop when in batch mode."
|
||||
<< "Can only loop in batch mode."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -885,7 +884,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (batch)
|
||||
{
|
||||
fileName batchFile(args.option("batch"));
|
||||
const fileName batchFile = args["batch"];
|
||||
|
||||
Info<< "Reading commands from file " << batchFile << endl;
|
||||
|
||||
|
||||
@ -1326,9 +1326,8 @@ int main(int argc, char *argv[])
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
word blockedFacesName;
|
||||
if (args.optionFound("blockedFaces"))
|
||||
if (args.optionReadIfPresent("blockedFaces", blockedFacesName))
|
||||
{
|
||||
blockedFacesName = args.option("blockedFaces");
|
||||
Info<< "Reading blocked internal faces from faceSet "
|
||||
<< blockedFacesName << nl << endl;
|
||||
}
|
||||
@ -1882,7 +1881,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (insidePoint)
|
||||
{
|
||||
point insidePoint(args.optionLookup("insidePoint")());
|
||||
const point insidePoint = args.optionRead<point>("insidePoint");
|
||||
|
||||
label regionI = -1;
|
||||
|
||||
|
||||
@ -174,7 +174,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("patch"))
|
||||
{
|
||||
word patchName(args.option("patch"));
|
||||
const word patchName = args["patch"];
|
||||
|
||||
patchI = mesh.boundaryMesh().findPatchID(patchName);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -210,7 +210,9 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
const bool doRotateFields = args.optionFound("rotateFields");
|
||||
|
||||
// this is not actually stringent enough:
|
||||
if (args.options().empty())
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
@ -219,18 +221,20 @@ int main(int argc, char *argv[])
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if (args.optionFound("translate"))
|
||||
vector v;
|
||||
if (args.optionReadIfPresent("translate", v))
|
||||
{
|
||||
vector transVector(args.optionLookup("translate")());
|
||||
Info<< "Translating points by " << v << endl;
|
||||
|
||||
Info<< "Translating points by " << transVector << endl;
|
||||
|
||||
points += transVector;
|
||||
points += v;
|
||||
}
|
||||
|
||||
if (args.optionFound("rotate"))
|
||||
{
|
||||
Pair<vector> n1n2(args.optionLookup("rotate")());
|
||||
Pair<vector> n1n2
|
||||
(
|
||||
args.optionLookup("rotate")()
|
||||
);
|
||||
n1n2[0] /= mag(n1n2[0]);
|
||||
n1n2[1] /= mag(n1n2[1]);
|
||||
tensor T = rotationTensor(n1n2[0], n1n2[1]);
|
||||
@ -239,20 +243,17 @@ int main(int argc, char *argv[])
|
||||
|
||||
points = transform(T, points);
|
||||
|
||||
if (args.optionFound("rotateFields"))
|
||||
if (doRotateFields)
|
||||
{
|
||||
rotateFields(args, runTime, T);
|
||||
}
|
||||
}
|
||||
else if (args.optionFound("rollPitchYaw"))
|
||||
else if (args.optionReadIfPresent("rollPitchYaw", v))
|
||||
{
|
||||
vector v(args.optionLookup("rollPitchYaw")());
|
||||
|
||||
Info<< "Rotating points by" << nl
|
||||
<< " roll " << v.x() << nl
|
||||
<< " pitch " << v.y() << nl
|
||||
<< " yaw " << v.z() << endl;
|
||||
|
||||
<< " yaw " << v.z() << nl;
|
||||
|
||||
// Convert to radians
|
||||
v *= pi/180.0;
|
||||
@ -262,20 +263,17 @@ int main(int argc, char *argv[])
|
||||
Info<< "Rotating points by quaternion " << R << endl;
|
||||
points = transform(R, points);
|
||||
|
||||
if (args.optionFound("rotateFields"))
|
||||
if (doRotateFields)
|
||||
{
|
||||
rotateFields(args, runTime, R.R());
|
||||
}
|
||||
}
|
||||
else if (args.optionFound("yawPitchRoll"))
|
||||
else if (args.optionReadIfPresent("yawPitchRoll", v))
|
||||
{
|
||||
vector v(args.optionLookup("yawPitchRoll")());
|
||||
|
||||
Info<< "Rotating points by" << nl
|
||||
<< " yaw " << v.x() << nl
|
||||
<< " pitch " << v.y() << nl
|
||||
<< " roll " << v.z() << endl;
|
||||
|
||||
<< " roll " << v.z() << nl;
|
||||
|
||||
// Convert to radians
|
||||
v *= pi/180.0;
|
||||
@ -291,21 +289,19 @@ int main(int argc, char *argv[])
|
||||
Info<< "Rotating points by quaternion " << R << endl;
|
||||
points = transform(R, points);
|
||||
|
||||
if (args.optionFound("rotateFields"))
|
||||
if (doRotateFields)
|
||||
{
|
||||
rotateFields(args, runTime, R.R());
|
||||
}
|
||||
}
|
||||
|
||||
if (args.optionFound("scale"))
|
||||
if (args.optionReadIfPresent("scale", v))
|
||||
{
|
||||
vector scaleVector(args.optionLookup("scale")());
|
||||
Info<< "Scaling points by " << v << endl;
|
||||
|
||||
Info<< "Scaling points by " << scaleVector << endl;
|
||||
|
||||
points.replace(vector::X, scaleVector.x()*points.component(vector::X));
|
||||
points.replace(vector::Y, scaleVector.y()*points.component(vector::Y));
|
||||
points.replace(vector::Z, scaleVector.z()*points.component(vector::Z));
|
||||
points.replace(vector::X, v.x()*points.component(vector::X));
|
||||
points.replace(vector::Y, v.y()*points.component(vector::Y));
|
||||
points.replace(vector::Z, v.z()*points.component(vector::Z));
|
||||
}
|
||||
|
||||
// Set the precision of the points data to 10
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -66,7 +66,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
fileName dictFileName
|
||||
(
|
||||
args.rootPath()/args.caseName()/args.option("dictionary")
|
||||
args.rootPath()/args.caseName()/args["dictionary"]
|
||||
);
|
||||
|
||||
IFstream dictFile(dictFileName);
|
||||
@ -103,7 +103,7 @@ int main(int argc, char *argv[])
|
||||
true // wildcards
|
||||
);
|
||||
|
||||
for (int i=1; i<entryNames.size(); i++)
|
||||
for (int i=1; i<entryNames.size(); ++i)
|
||||
{
|
||||
if (entPtr->dict().found(entryNames[i]))
|
||||
{
|
||||
@ -118,7 +118,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Cannot find sub-entry " << entryNames[i]
|
||||
<< " in entry " << args.option("entry")
|
||||
<< " in entry " << args["entry"]
|
||||
<< " in dictionary " << dictFileName;
|
||||
FatalError.exit(3);
|
||||
}
|
||||
@ -131,7 +131,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Cannot find entry "
|
||||
<< args.option("entry")
|
||||
<< args["entry"]
|
||||
<< " in dictionary " << dictFileName
|
||||
<< " is not a sub-dictionary";
|
||||
FatalError.exit(4);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -80,7 +80,10 @@ Foam::ensightMesh::ensightMesh
|
||||
|
||||
if (args.optionFound("patches"))
|
||||
{
|
||||
wordList patchNameList(args.optionLookup("patches")());
|
||||
wordList patchNameList
|
||||
(
|
||||
args.optionLookup("patches")()
|
||||
);
|
||||
|
||||
if (patchNameList.empty())
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -215,9 +215,8 @@ int main(int argc, char *argv[])
|
||||
word cellSetName;
|
||||
string vtkName;
|
||||
|
||||
if (args.optionFound("cellSet"))
|
||||
if (args.optionReadIfPresent("cellSet", cellSetName))
|
||||
{
|
||||
cellSetName = args.option("cellSet");
|
||||
vtkName = cellSetName;
|
||||
}
|
||||
else if (Pstream::parRun())
|
||||
@ -738,7 +737,7 @@ int main(int argc, char *argv[])
|
||||
if (args.optionFound("faceSet"))
|
||||
{
|
||||
// Load the faceSet
|
||||
word setName(args.option("faceSet"));
|
||||
const word setName = args["faceSet"];
|
||||
labelList faceLabels(faceSet(mesh, setName).toc());
|
||||
|
||||
// Filename as if patch with same name.
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -329,9 +329,8 @@ int main(int argc, char *argv[])
|
||||
word cellSetName;
|
||||
string vtkName = runTime.caseName();
|
||||
|
||||
if (args.optionFound("cellSet"))
|
||||
if (args.optionReadIfPresent("cellSet", cellSetName))
|
||||
{
|
||||
cellSetName = args.option("cellSet");
|
||||
vtkName = cellSetName;
|
||||
}
|
||||
else if (Pstream::parRun())
|
||||
@ -423,7 +422,7 @@ int main(int argc, char *argv[])
|
||||
if (args.optionFound("faceSet"))
|
||||
{
|
||||
// Load the faceSet
|
||||
faceSet set(mesh, args.option("faceSet"));
|
||||
faceSet set(mesh, args["faceSet"]);
|
||||
|
||||
// Filename as if patch with same name.
|
||||
mkDir(fvPath/set.name());
|
||||
@ -446,7 +445,7 @@ int main(int argc, char *argv[])
|
||||
if (args.optionFound("pointSet"))
|
||||
{
|
||||
// Load the pointSet
|
||||
pointSet set(mesh, args.option("pointSet"));
|
||||
pointSet set(mesh, args["pointSet"]);
|
||||
|
||||
// Filename as if patch with same name.
|
||||
mkDir(fvPath/set.name());
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -59,7 +59,7 @@ namespace Foam
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
args.option("dict"),
|
||||
args["dict"],
|
||||
runTime.system(),
|
||||
runTime,
|
||||
IOobject::MUST_READ
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
label sourceTimeIndex = runTimeSource.timeIndex();
|
||||
if (args.optionFound("sourceTime"))
|
||||
{
|
||||
if (args.option("sourceTime") == "latestTime")
|
||||
if (args["sourceTime"] == "latestTime")
|
||||
{
|
||||
sourceTimeIndex = sourceTimes.size() - 1;
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ int main(int argc, char *argv[])
|
||||
<< nl << endl;
|
||||
|
||||
Info<< "Surface : " << inFileName1<< nl
|
||||
<< "Points : " << args.option("points") << nl
|
||||
<< "Points : " << args["points"] << nl
|
||||
<< "Writing : " << outFileName << nl << endl;
|
||||
}
|
||||
else
|
||||
@ -113,7 +113,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (addPoint)
|
||||
{
|
||||
IFstream pointsFile(args.option("points"));
|
||||
IFstream pointsFile(args["points"]);
|
||||
pointField extraPoints(pointsFile);
|
||||
|
||||
Info<< "Additional Points:" << extraPoints.size() << endl;
|
||||
|
||||
@ -136,7 +136,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("set"))
|
||||
{
|
||||
fileName setName(args.option("set"));
|
||||
const fileName setName = args["set"];
|
||||
|
||||
Info<< "Reading existing feature set from file " << setName << endl;
|
||||
|
||||
@ -151,7 +151,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
set = surfaceFeatures(surf, includedAngle);
|
||||
|
||||
Info<< endl << "Writing initial features" << endl;
|
||||
Info<< nl << "Writing initial features" << endl;
|
||||
set.write("initial.fSet");
|
||||
set.writeObj("initial");
|
||||
}
|
||||
@ -210,7 +210,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("subsetBox"))
|
||||
{
|
||||
treeBoundBox bb(args.optionLookup("subsetBox")());
|
||||
treeBoundBox bb
|
||||
(
|
||||
args.optionLookup("subsetBox")()
|
||||
);
|
||||
|
||||
Info<< "Removing all edges outside bb " << bb << endl;
|
||||
dumpBox(bb, "subsetBox.obj");
|
||||
@ -225,7 +228,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (args.optionFound("deleteBox"))
|
||||
{
|
||||
treeBoundBox bb(args.optionLookup("deleteBox")());
|
||||
treeBoundBox bb
|
||||
(
|
||||
args.optionLookup("deleteBox")()
|
||||
);
|
||||
|
||||
Info<< "Removing all edges inside bb " << bb << endl;
|
||||
dumpBox(bb, "deleteBox.obj");
|
||||
|
||||
@ -153,7 +153,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("dict"))
|
||||
{
|
||||
fileName dictPath(args.option("dict"));
|
||||
const fileName dictPath = args["dict"];
|
||||
|
||||
csDictIoPtr.set
|
||||
(
|
||||
@ -200,7 +200,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("from"))
|
||||
{
|
||||
const word csName(args.option("from"));
|
||||
const word csName = args["from"];
|
||||
|
||||
label csId = csLst.find(csName);
|
||||
if (csId < 0)
|
||||
@ -216,7 +216,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("to"))
|
||||
{
|
||||
const word csName(args.option("to"));
|
||||
const word csName = args["to"];
|
||||
|
||||
label csId = csLst.find(csName);
|
||||
if (csId < 0)
|
||||
|
||||
@ -108,7 +108,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("dict"))
|
||||
{
|
||||
fileName dictPath(args.option("dict"));
|
||||
const fileName dictPath = args["dict"];
|
||||
|
||||
ioPtr.set
|
||||
(
|
||||
@ -155,7 +155,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("from"))
|
||||
{
|
||||
const word csName(args.option("from"));
|
||||
const word csName = args["from"];
|
||||
|
||||
label csId = csLst.find(csName);
|
||||
if (csId < 0)
|
||||
@ -171,7 +171,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("to"))
|
||||
{
|
||||
const word csName(args.option("to"));
|
||||
const word csName = args["to"];
|
||||
|
||||
label csId = csLst.find(csName);
|
||||
if (csId < 0)
|
||||
|
||||
@ -121,7 +121,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("dict"))
|
||||
{
|
||||
fileName dictPath(args.option("dict"));
|
||||
const fileName dictPath = args["dict"];
|
||||
|
||||
ioPtr.set
|
||||
(
|
||||
@ -168,7 +168,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("from"))
|
||||
{
|
||||
const word csName(args.option("from"));
|
||||
const word csName = args["from"];
|
||||
|
||||
label csId = csLst.find(csName);
|
||||
if (csId < 0)
|
||||
@ -184,7 +184,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("to"))
|
||||
{
|
||||
const word csName(args.option("to"));
|
||||
const word csName = args["to"];
|
||||
|
||||
label csId = csLst.find(csName);
|
||||
if (csId < 0)
|
||||
|
||||
@ -85,12 +85,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.optionFound("patches"))
|
||||
{
|
||||
wordList patchNames(args.optionLookup("patches")());
|
||||
const wordList patchNames
|
||||
(
|
||||
args.optionLookup("patches")()
|
||||
);
|
||||
|
||||
forAll(patchNames, patchNameI)
|
||||
{
|
||||
const word& patchName = patchNames[patchNameI];
|
||||
|
||||
label patchI = bMesh.findPatchID(patchName);
|
||||
|
||||
if (patchI == -1)
|
||||
|
||||
@ -116,18 +116,20 @@ int main(int argc, char *argv[])
|
||||
|
||||
pointField points(surf1.points());
|
||||
|
||||
if (args.optionFound("translate"))
|
||||
vector v;
|
||||
if (args.optionReadIfPresent("translate", v))
|
||||
{
|
||||
vector transVector(args.optionLookup("translate")());
|
||||
Info<< "Translating points by " << v << endl;
|
||||
|
||||
Info<< "Translating points by " << transVector << endl;
|
||||
|
||||
points += transVector;
|
||||
points += v;
|
||||
}
|
||||
|
||||
if (args.optionFound("rotate"))
|
||||
{
|
||||
Pair<vector> n1n2(args.optionLookup("rotate")());
|
||||
Pair<vector> n1n2
|
||||
(
|
||||
args.optionLookup("rotate")()
|
||||
);
|
||||
n1n2[0] /= mag(n1n2[0]);
|
||||
n1n2[1] /= mag(n1n2[1]);
|
||||
|
||||
@ -137,15 +139,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
points = transform(T, points);
|
||||
}
|
||||
else if (args.optionFound("rollPitchYaw"))
|
||||
else if (args.optionReadIfPresent("rollPitchYaw", v))
|
||||
{
|
||||
vector v(args.optionLookup("rollPitchYaw")());
|
||||
|
||||
Info<< "Rotating points by" << nl
|
||||
<< " roll " << v.x() << nl
|
||||
<< " pitch " << v.y() << nl
|
||||
<< " yaw " << v.z() << endl;
|
||||
|
||||
<< " yaw " << v.z() << nl;
|
||||
|
||||
// Convert to radians
|
||||
v *= pi/180.0;
|
||||
@ -155,14 +154,12 @@ int main(int argc, char *argv[])
|
||||
Info<< "Rotating points by quaternion " << R << endl;
|
||||
points = transform(R, points);
|
||||
}
|
||||
else if (args.optionFound("yawPitchRoll"))
|
||||
else if (args.optionReadIfPresent("yawPitchRoll", v))
|
||||
{
|
||||
vector v(args.optionLookup("yawPitchRoll")());
|
||||
|
||||
Info<< "Rotating points by" << nl
|
||||
<< " yaw " << v.x() << nl
|
||||
<< " pitch " << v.y() << nl
|
||||
<< " roll " << v.z() << endl;
|
||||
<< " roll " << v.z() << nl;
|
||||
|
||||
|
||||
// Convert to radians
|
||||
@ -180,15 +177,13 @@ int main(int argc, char *argv[])
|
||||
points = transform(R, points);
|
||||
}
|
||||
|
||||
if (args.optionFound("scale"))
|
||||
if (args.optionReadIfPresent("scale", v))
|
||||
{
|
||||
vector scaleVector(args.optionLookup("scale")());
|
||||
Info<< "Scaling points by " << v << endl;
|
||||
|
||||
Info<< "Scaling points by " << scaleVector << endl;
|
||||
|
||||
points.replace(vector::X, scaleVector.x()*points.component(vector::X));
|
||||
points.replace(vector::Y, scaleVector.y()*points.component(vector::Y));
|
||||
points.replace(vector::Z, scaleVector.z()*points.component(vector::Z));
|
||||
points.replace(vector::X, v.x()*points.component(vector::X));
|
||||
points.replace(vector::Y, v.y()*points.component(vector::Y));
|
||||
points.replace(vector::Z, v.z()*points.component(vector::Z));
|
||||
}
|
||||
|
||||
surf1.movePoints(points);
|
||||
|
||||
@ -251,7 +251,7 @@ bool Foam::argList::regroupArgv(int& argc, char**& argv)
|
||||
|
||||
// note: we also re-write directly into args_
|
||||
// and use a second pass to sort out args/options
|
||||
for (int argI = 0; argI < argc; argI++)
|
||||
for (int argI = 0; argI < argc; ++argI)
|
||||
{
|
||||
if (strcmp(argv[argI], "(") == 0)
|
||||
{
|
||||
@ -369,7 +369,7 @@ Foam::argList::argList
|
||||
{
|
||||
// Check if this run is a parallel run by searching for any parallel option
|
||||
// If found call runPar which might filter argv
|
||||
for (int argI = 0; argI < argc; argI++)
|
||||
for (int argI = 0; argI < argc; ++argI)
|
||||
{
|
||||
if (argv[argI][0] == '-')
|
||||
{
|
||||
@ -395,7 +395,7 @@ Foam::argList::argList
|
||||
int nArgs = 1;
|
||||
string argListString = args_[0];
|
||||
|
||||
for (int argI = 1; argI < args_.size(); argI++)
|
||||
for (int argI = 1; argI < args_.size(); ++argI)
|
||||
{
|
||||
argListString += ' ';
|
||||
argListString += args_[argI];
|
||||
|
||||
@ -193,7 +193,7 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Name of executable
|
||||
//- Name of executable without the path
|
||||
inline const word& executable() const;
|
||||
|
||||
//- Return root path
|
||||
@ -211,14 +211,12 @@ public:
|
||||
//- Return arguments
|
||||
inline const stringList& args() const;
|
||||
|
||||
//- Return the argument corresponding to index.
|
||||
inline const string& arg(const label index) const;
|
||||
|
||||
//- Return the number of arguments
|
||||
inline label size() const;
|
||||
|
||||
//- Return the argument corresponding to index.
|
||||
// Index 0 corresponds to the name of the executable.
|
||||
// Index 1 corresponds to the first argument.
|
||||
inline const string& operator[](const label index) const;
|
||||
|
||||
//- Read a value from the argument at index.
|
||||
// Index 0 corresponds to the name of the executable.
|
||||
// Index 1 corresponds to the first argument.
|
||||
@ -282,6 +280,15 @@ public:
|
||||
}
|
||||
|
||||
|
||||
//- Return the argument corresponding to index.
|
||||
// Index 0 corresponds to the name of the executable.
|
||||
// Index 1 corresponds to the first argument.
|
||||
inline const string& operator[](const label index) const;
|
||||
|
||||
//- Return the argument string associated with the named option
|
||||
// @sa option()
|
||||
inline const string& operator[](const word& opt) const;
|
||||
|
||||
// Edit
|
||||
|
||||
//- Add to a bool option to validOptions with usage information
|
||||
|
||||
@ -64,6 +64,12 @@ inline const Foam::stringList& Foam::argList::args() const
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::string& Foam::argList::arg(const label index) const
|
||||
{
|
||||
return args_[index];
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::argList::size() const
|
||||
{
|
||||
return args_.size();
|
||||
@ -78,7 +84,7 @@ inline const Foam::HashTable<Foam::string>& Foam::argList::options() const
|
||||
|
||||
inline const Foam::string& Foam::argList::option(const word& opt) const
|
||||
{
|
||||
return options_.operator[](opt);
|
||||
return options_[opt];
|
||||
}
|
||||
|
||||
|
||||
@ -90,7 +96,7 @@ inline bool Foam::argList::optionFound(const word& opt) const
|
||||
|
||||
inline Foam::IStringStream Foam::argList::optionLookup(const word& opt) const
|
||||
{
|
||||
return IStringStream(option(opt));
|
||||
return IStringStream(options_[opt]);
|
||||
}
|
||||
|
||||
|
||||
@ -127,7 +133,7 @@ namespace Foam
|
||||
inline Foam::string
|
||||
Foam::argList::optionRead<Foam::string>(const word& opt) const
|
||||
{
|
||||
return option(opt);
|
||||
return options_[opt];
|
||||
}
|
||||
|
||||
// Template specialization for word
|
||||
@ -135,7 +141,7 @@ namespace Foam
|
||||
inline Foam::word
|
||||
Foam::argList::optionRead<Foam::word>(const word& opt) const
|
||||
{
|
||||
return option(opt);
|
||||
return options_[opt];
|
||||
}
|
||||
|
||||
// Template specialization for fileName
|
||||
@ -143,7 +149,7 @@ namespace Foam
|
||||
inline Foam::fileName
|
||||
Foam::argList::optionRead<Foam::fileName>(const word& opt) const
|
||||
{
|
||||
return option(opt);
|
||||
return options_[opt];
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,4 +241,10 @@ inline const Foam::string& Foam::argList::operator[](const label index) const
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::string& Foam::argList::operator[](const word& opt) const
|
||||
{
|
||||
return options_[opt];
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -232,14 +232,12 @@ void Foam::calcTypes::addSubtract::preCalc
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if (args.optionFound("field"))
|
||||
if (args.optionReadIfPresent("field", addSubtractFieldName_))
|
||||
{
|
||||
addSubtractFieldName_ = args.option("field");
|
||||
calcType_ = FIELD;
|
||||
}
|
||||
else if (args.optionFound("value"))
|
||||
else if (args.optionReadIfPresent("value", addSubtractValueStr_))
|
||||
{
|
||||
addSubtractValueStr_ = args.option("value");
|
||||
calcType_ = VALUE;
|
||||
}
|
||||
else
|
||||
@ -249,10 +247,7 @@ void Foam::calcTypes::addSubtract::preCalc
|
||||
<< nl << exit(FatalError);
|
||||
}
|
||||
|
||||
if (args.optionFound("resultName"))
|
||||
{
|
||||
resultName_ = args.option("resultName");
|
||||
}
|
||||
args.optionReadIfPresent("resultName", resultName_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user