Commit 71710e07 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: use prefix when displaying group,patch names for paraview selection

- easier to detect the implicit grouping
parent e5cdee5d
......@@ -240,7 +240,7 @@ void Foam::vtkPVFoam::updateMeshPartsStatus()
Foam::word Foam::vtkPVFoam::getPartName(const int partId)
{
return getFirstWord(reader_->GetPartArrayName(partId));
return getFoamName(reader_->GetPartArrayName(partId));
}
......@@ -649,7 +649,7 @@ void Foam::vtkPVFoam::renderPatchNames
if (show && meshPtr_)
{
// get the display patches, strip off any suffix
// get the display patches, strip off any prefix/suffix
hashedWordList selectedPatches = getSelected
(
reader_->GetPartSelection(),
......
......@@ -192,7 +192,7 @@ void Foam::vtkPVFoam::updateInfoLagrangian
// Add cloud to GUI list
arraySelection->AddArray
(
(cloudDirs[cloudi] + " - lagrangian").c_str()
("lagrangian/" + cloudDirs[cloudi]).c_str()
);
++rangeLagrangian_;
}
......@@ -246,7 +246,7 @@ void Foam::vtkPVFoam::updateInfoPatches
}
// Valid patch if nFace > 0 - add patch to GUI list
const string dpyName = groupName + " - group";
const string dpyName = "group/" + groupName;
arraySelection->AddArray(dpyName.c_str());
++rangePatches_;
......@@ -262,7 +262,7 @@ void Foam::vtkPVFoam::updateInfoPatches
{
enabledEntriesSet.insert
(
pp.name() + " - patch"
"patch/" + pp.name()
);
}
}
......@@ -285,7 +285,7 @@ void Foam::vtkPVFoam::updateInfoPatches
// Add patch to GUI list
arraySelection->AddArray
(
(pp.name() + " - patch").c_str()
("patch/" + pp.name()).c_str()
);
++rangePatches_;
}
......@@ -360,7 +360,7 @@ void Foam::vtkPVFoam::updateInfoPatches
const auto& groupName = iter.key();
const auto& patchIDs = iter.object();
const string dpyName = groupName + " - group";
const string dpyName = "group/" + groupName;
arraySelection->AddArray(dpyName.c_str());
++rangePatches_;
......@@ -376,7 +376,7 @@ void Foam::vtkPVFoam::updateInfoPatches
{
enabledEntriesSet.insert
(
names[patchId] + " - patch";
"patch/" + names[patchId]
);
}
}
......@@ -395,7 +395,7 @@ void Foam::vtkPVFoam::updateInfoPatches
{
arraySelection->AddArray
(
(names[patchi] + " - patch").c_str()
("patch/" + names[patchi]).c_str()
);
++rangePatches_;
}
......@@ -449,7 +449,7 @@ void Foam::vtkPVFoam::updateInfoZones
{
arraySelection->AddArray
(
(namesLst[elemI] + " - cellZone").c_str()
("cellZone/" + namesLst[elemI]).c_str()
);
++rangeCellZones_;
}
......@@ -472,7 +472,7 @@ void Foam::vtkPVFoam::updateInfoZones
{
arraySelection->AddArray
(
(namesLst[elemI] + " - faceZone").c_str()
("faceZone/" + namesLst[elemI]).c_str()
);
++rangeFaceZones_;
}
......@@ -495,7 +495,7 @@ void Foam::vtkPVFoam::updateInfoZones
{
arraySelection->AddArray
(
(namesLst[elemI] + " - pointZone").c_str()
("pointZone/" + namesLst[elemI]).c_str()
);
++rangePointZones_;
}
......@@ -554,7 +554,7 @@ void Foam::vtkPVFoam::updateInfoSets
(
arraySelection,
objects,
" - cellSet"
"cellSet/"
);
rangeFaceSets_.reset(arraySelection->GetNumberOfArrays());
......@@ -562,7 +562,7 @@ void Foam::vtkPVFoam::updateInfoSets
(
arraySelection,
objects,
" - faceSet"
"faceSet/"
);
rangePointSets_.reset(arraySelection->GetNumberOfArrays());
......@@ -570,7 +570,7 @@ void Foam::vtkPVFoam::updateInfoSets
(
arraySelection,
objects,
" - pointSet"
"pointSet/"
);
if (debug)
......
......@@ -164,7 +164,7 @@ Foam::hashedWordList Foam::foamPvCore::getSelected
{
if (select->GetArraySetting(i))
{
selected.append(getFirstWord(select->GetArrayName(i)));
selected.append(getFoamName(select->GetArrayName(i)));
}
}
......@@ -185,7 +185,7 @@ Foam::hashedWordList Foam::foamPvCore::getSelected
{
if (select->GetArraySetting(i))
{
selected.append(getFirstWord(select->GetArrayName(i)));
selected.append(getFoamName(select->GetArrayName(i)));
}
}
......@@ -295,17 +295,29 @@ void Foam::foamPvCore::setSelectedArrayEntries
}
Foam::word Foam::foamPvCore::getFirstWord(const char* str)
Foam::word Foam::foamPvCore::getFoamName(const std::string& str)
{
if (str)
if (str.size())
{
label n = 0;
while (str[n] && word::valid(str[n]))
std::string::size_type beg = str.rfind('/');
if (beg == std::string::npos)
{
++n;
beg = 0;
}
// don't need to re-check for invalid chars
return word(str, n, false);
else
{
++beg;
}
std::string::size_type end = beg;
while (str[end] && word::valid(str[end]))
{
++end;
}
// Already checked for valid/invalid chars
return word(str.substr(beg, beg+end), false);
}
else
{
......
......@@ -180,7 +180,7 @@ public:
(
vtkDataArraySelection* select,
const IOobjectList& objects,
const std::string& suffix = string::null
const std::string& prefix = string::null
);
......@@ -191,14 +191,16 @@ public:
vtkDataArraySelection* select
);
//- Retrieve the current selections as a wordHashSet
//- Retrieve the current selections as a hashedWordList,
// while stripping off any prefix or suffix
static hashedWordList getSelected
(
vtkDataArraySelection* select
);
//- Retrieve a sub-list of the current selections
//- Retrieve a sub-list of the current selections as a hashedWordList,
// while stripping off any prefix or suffix
static hashedWordList getSelected
(
vtkDataArraySelection* select,
......@@ -228,8 +230,9 @@ public:
);
//- Extract up to the first non-word characters
static word getFirstWord(const char* str);
//- Extract the first word characters after a slash
static word getFoamName(const std::string& str);
//- Simple memory used debugging information
static void printMemory();
......
......@@ -60,20 +60,20 @@ Foam::label Foam::foamPvCore::addToSelection
(
vtkDataArraySelection *select,
const IOobjectList& objects,
const std::string& suffix
const std::string& prefix
)
{
const wordList names = objects.sortedNames(Type::typeName);
forAll(names, i)
{
if (suffix.empty())
if (prefix.empty())
{
select->AddArray(names[i].c_str());
}
else
{
select->AddArray((names[i] + suffix).c_str());
select->AddArray((prefix + names[i]).c_str());
}
}
......
Supports Markdown
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