ENH: Added helper function to create appropriate graph name from string

This commit is contained in:
andy
2013-01-28 16:43:17 +00:00
parent f84900fbff
commit 12e55d7d97
2 changed files with 22 additions and 4 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -41,6 +41,17 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::word Foam::graph::wordify(const Foam::string& sname)
{
string wname = sname;
wname.replace(' ', '_');
wname.replace('(', '_');
wname.replace(')', "");
return word(wname);
}
void Foam::graph::readCurves(Istream& is)
{
List<xy> xyData(is);
@ -54,7 +65,11 @@ void Foam::graph::readCurves(Istream& is)
y[i] = xyData[i].y_;
}
insert(yName_, new curve(yName_, curve::curveStyle::CONTINUOUS, y));
insert
(
wordify(yName_),
new curve(wordify(yName_), curve::curveStyle::CONTINUOUS, y)
);
}
@ -89,7 +104,7 @@ Foam::graph::graph
yName_(yName),
x_(x)
{
insert(yName, new curve(yName, curve::curveStyle::CONTINUOUS, y));
insert(wordify(yName), new curve(yName, curve::curveStyle::CONTINUOUS, y));
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -263,6 +263,9 @@ public:
const word& format
) const;
//- Helper function to convert string name into appropriate word
static word wordify(const string& sname);
// Friend operators