Commit e332898e authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: avoid raw dictionary lookup in functionObjects (issue #762)

Style changes:
    - use lookupObjectRef instead of using const_cast
    - use tmp::New factory
parent b8d7b8e6
......@@ -484,7 +484,7 @@ Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase
)
:
colours_(colours),
fieldName_(dict.lookup("field")),
fieldName_(dict.get<word>("field")),
colourBy_(cbColour),
colourMap_(cmRainbow),
range_()
......@@ -500,7 +500,7 @@ Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase
}
case cbField:
{
dict.lookup("range") >> range_;
dict.readEntry("range", range_);
if (dict.found("colourMap"))
{
......@@ -508,15 +508,15 @@ Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase
}
const dictionary& sbarDict = dict.subDict("scalarBar");
sbarDict.lookup("visible") >> scalarBar_.visible_;
sbarDict.readEntry("visible", scalarBar_.visible_);
if (scalarBar_.visible_)
{
sbarDict.lookup("vertical") >> scalarBar_.vertical_;
sbarDict.lookup("position") >> scalarBar_.position_;
sbarDict.lookup("title") >> scalarBar_.title_;
sbarDict.lookup("fontSize") >> scalarBar_.fontSize_;
sbarDict.lookup("labelFormat") >> scalarBar_.labelFormat_;
sbarDict.lookup("numberOfLabels") >> scalarBar_.numberOfLabels_;
sbarDict.readEntry("vertical", scalarBar_.vertical_);
sbarDict.readEntry("position", scalarBar_.position_);
sbarDict.readEntry("title", scalarBar_.title_);
sbarDict.readEntry("fontSize", scalarBar_.fontSize_);
sbarDict.readEntry("labelFormat", scalarBar_.labelFormat_);
sbarDict.readEntry("numberOfLabels", scalarBar_.numberOfLabels_);
}
break;
}
......
......@@ -86,7 +86,7 @@ Foam::functionObjects::runTimePostPro::functionObjectBase::functionObjectBase
:
fieldVisualisationBase(dict, colours),
state_(state),
functionObjectName_(dict.lookup("functionObject")),
functionObjectName_(dict.get<word>("functionObject")),
clearObjects_(dict.lookupOrDefault("clearObjects", false))
{}
......
......@@ -65,9 +65,9 @@ Foam::functionObjects::runTimePostPro::functionObjectCloud::functionObjectCloud
:
pointData(parent, dict, colours),
functionObjectBase(parent, dict, colours),
cloudName_(dict.lookup("cloud")),
cloudName_(dict.get<word>("cloud")),
inputFileName_(),
colourFieldName_(dict.lookup("colourField")),
colourFieldName_(dict.get<word>("colourField")),
actor_()
{
actor_ = vtkSmartPointer<vtkActor>::New();
......
......@@ -86,7 +86,7 @@ Foam::functionObjects::runTimePostPro::geometryBase::geometryBase
:
parent_(parent),
name_(dict.dictName()),
visible_(readBool(dict.lookup("visible"))),
visible_(dict.get<bool>("visible")),
renderMode_(rmGouraud),
opacity_(nullptr),
colours_(colours)
......
......@@ -140,8 +140,10 @@ Foam::functionObjects::runTimePostPro::geometrySurface::geometrySurface
)
:
surface(parent, dict, colours),
fileNames_(dict.lookup("files"))
{}
fileNames_()
{
dict.readEntry("files", fileNames_);
}
Foam::functionObjects::runTimePostPro::geometrySurface::geometrySurface
......
......@@ -155,7 +155,7 @@ Foam::functionObjects::runTimePostPro::pathline::pathline
}
case rtTube:
{
dict.lookup("tubeRadius") >> tubeRadius_;
dict.readEntry("tubeRadius", tubeRadius_);
break;
}
case rtVector:
......
......@@ -101,7 +101,7 @@ Foam::functionObjects::runTimePostPro::pointData::pointData
(
representationTypeNames.lookup("representation", dict)
),
maxGlyphLength_(readScalar(dict.lookup("maxGlyphLength"))),
maxGlyphLength_(dict.get<scalar>("maxGlyphLength")),
pointColour_(nullptr)
{
if (dict.found("pointColour"))
......
......@@ -97,9 +97,9 @@ bool Foam::functionObjects::runTimePostProcessing::read(const dictionary& dict)
scene_.read(dict);
const dictionary& outputDict = dict.subDict("output");
outputDict.lookup("name") >> output_.name_;
outputDict.lookup("width") >> output_.width_;
outputDict.lookup("height") >> output_.height_;
outputDict.readEntry("name", output_.name_);
outputDict.readEntry("width", output_.width_);
outputDict.readEntry("height", output_.height_);
readObjects(dict.subOrEmptyDict("points"), points_);
......@@ -117,11 +117,14 @@ bool Foam::functionObjects::runTimePostProcessing::read(const dictionary& dict)
<< exit(FatalIOError);
}
text_.append(new runTimePostPro::text
text_.append
(
*this,
iter().dict(),
scene_.colours())
new runTimePostPro::text
(
*this,
iter().dict(),
scene_.colours()
)
);
}
......
......@@ -44,7 +44,7 @@ void Foam::functionObjects::runTimePostProcessing::readObjects
}
const dictionary& objectDict(iter().dict());
word objectType = objectDict.lookup("type");
const word objectType = objectDict.get<word>("type");
objects.append
(
......
......@@ -87,7 +87,7 @@ void Foam::functionObjects::runTimePostPro::scene::readCamera
cameraUp_ = Function1<vector>::New("up", dict);
dict.readIfPresent("clipBox", clipBox_);
dict.lookup("parallelProjection") >> parallelProjection_;
dict.readEntry("parallelProjection", parallelProjection_);
if (!parallelProjection_)
{
if (dict.found("viewAngle"))
......
......@@ -184,11 +184,11 @@ Foam::functionObjects::runTimePostPro::surface::surface
if (representation_ == rtGlyph)
{
dict.lookup("maxGlyphLength") >> maxGlyphLength_;
dict.readEntry("maxGlyphLength", maxGlyphLength_);
}
else
{
dict.lookup("featureEdges") >> featureEdges_;
dict.readEntry("featureEdges", featureEdges_);
}
}
......
......@@ -44,13 +44,15 @@ Foam::functionObjects::runTimePostPro::text::text
)
:
geometryBase(parent, dict, colours),
string_(dict.lookup("string")),
position_(dict.lookup("position")),
size_(readScalar(dict.lookup("size"))),
string_(dict.get<string>("string")),
position_(),
size_(dict.get<scalar>("size")),
colour_(nullptr),
bold_(readBool(dict.lookup("bold"))),
bold_(dict.get<bool>("bold")),
timeStamp_(dict.lookupOrDefault("timeStamp", false))
{
dict.readEntry("position", position_);
if (dict.found("colour"))
{
colour_.reset(Function1<vector>::New("colour", dict).ptr());
......
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