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

- easier to detect the implicit grouping
This commit is contained in:
Mark Olesen
2017-05-12 15:37:04 +02:00
parent e5cdee5dd9
commit 71710e0798
5 changed files with 47 additions and 32 deletions

View File

@ -240,7 +240,7 @@ void Foam::vtkPVFoam::updateMeshPartsStatus()
Foam::word Foam::vtkPVFoam::getPartName(const int partId) 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_) if (show && meshPtr_)
{ {
// get the display patches, strip off any suffix // get the display patches, strip off any prefix/suffix
hashedWordList selectedPatches = getSelected hashedWordList selectedPatches = getSelected
( (
reader_->GetPartSelection(), reader_->GetPartSelection(),

View File

@ -192,7 +192,7 @@ void Foam::vtkPVFoam::updateInfoLagrangian
// Add cloud to GUI list // Add cloud to GUI list
arraySelection->AddArray arraySelection->AddArray
( (
(cloudDirs[cloudi] + " - lagrangian").c_str() ("lagrangian/" + cloudDirs[cloudi]).c_str()
); );
++rangeLagrangian_; ++rangeLagrangian_;
} }
@ -246,7 +246,7 @@ void Foam::vtkPVFoam::updateInfoPatches
} }
// Valid patch if nFace > 0 - add patch to GUI list // 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()); arraySelection->AddArray(dpyName.c_str());
++rangePatches_; ++rangePatches_;
@ -262,7 +262,7 @@ void Foam::vtkPVFoam::updateInfoPatches
{ {
enabledEntriesSet.insert enabledEntriesSet.insert
( (
pp.name() + " - patch" "patch/" + pp.name()
); );
} }
} }
@ -285,7 +285,7 @@ void Foam::vtkPVFoam::updateInfoPatches
// Add patch to GUI list // Add patch to GUI list
arraySelection->AddArray arraySelection->AddArray
( (
(pp.name() + " - patch").c_str() ("patch/" + pp.name()).c_str()
); );
++rangePatches_; ++rangePatches_;
} }
@ -360,7 +360,7 @@ void Foam::vtkPVFoam::updateInfoPatches
const auto& groupName = iter.key(); const auto& groupName = iter.key();
const auto& patchIDs = iter.object(); const auto& patchIDs = iter.object();
const string dpyName = groupName + " - group"; const string dpyName = "group/" + groupName;
arraySelection->AddArray(dpyName.c_str()); arraySelection->AddArray(dpyName.c_str());
++rangePatches_; ++rangePatches_;
@ -376,7 +376,7 @@ void Foam::vtkPVFoam::updateInfoPatches
{ {
enabledEntriesSet.insert enabledEntriesSet.insert
( (
names[patchId] + " - patch"; "patch/" + names[patchId]
); );
} }
} }
@ -395,7 +395,7 @@ void Foam::vtkPVFoam::updateInfoPatches
{ {
arraySelection->AddArray arraySelection->AddArray
( (
(names[patchi] + " - patch").c_str() ("patch/" + names[patchi]).c_str()
); );
++rangePatches_; ++rangePatches_;
} }
@ -449,7 +449,7 @@ void Foam::vtkPVFoam::updateInfoZones
{ {
arraySelection->AddArray arraySelection->AddArray
( (
(namesLst[elemI] + " - cellZone").c_str() ("cellZone/" + namesLst[elemI]).c_str()
); );
++rangeCellZones_; ++rangeCellZones_;
} }
@ -472,7 +472,7 @@ void Foam::vtkPVFoam::updateInfoZones
{ {
arraySelection->AddArray arraySelection->AddArray
( (
(namesLst[elemI] + " - faceZone").c_str() ("faceZone/" + namesLst[elemI]).c_str()
); );
++rangeFaceZones_; ++rangeFaceZones_;
} }
@ -495,7 +495,7 @@ void Foam::vtkPVFoam::updateInfoZones
{ {
arraySelection->AddArray arraySelection->AddArray
( (
(namesLst[elemI] + " - pointZone").c_str() ("pointZone/" + namesLst[elemI]).c_str()
); );
++rangePointZones_; ++rangePointZones_;
} }
@ -554,7 +554,7 @@ void Foam::vtkPVFoam::updateInfoSets
( (
arraySelection, arraySelection,
objects, objects,
" - cellSet" "cellSet/"
); );
rangeFaceSets_.reset(arraySelection->GetNumberOfArrays()); rangeFaceSets_.reset(arraySelection->GetNumberOfArrays());
@ -562,7 +562,7 @@ void Foam::vtkPVFoam::updateInfoSets
( (
arraySelection, arraySelection,
objects, objects,
" - faceSet" "faceSet/"
); );
rangePointSets_.reset(arraySelection->GetNumberOfArrays()); rangePointSets_.reset(arraySelection->GetNumberOfArrays());
@ -570,7 +570,7 @@ void Foam::vtkPVFoam::updateInfoSets
( (
arraySelection, arraySelection,
objects, objects,
" - pointSet" "pointSet/"
); );
if (debug) if (debug)

View File

@ -164,7 +164,7 @@ Foam::hashedWordList Foam::foamPvCore::getSelected
{ {
if (select->GetArraySetting(i)) 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)) 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; std::string::size_type beg = str.rfind('/');
while (str[n] && word::valid(str[n])) if (beg == std::string::npos)
{ {
++n; beg = 0;
} }
// don't need to re-check for invalid chars else
return word(str, n, false); {
++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 else
{ {

View File

@ -180,7 +180,7 @@ public:
( (
vtkDataArraySelection* select, vtkDataArraySelection* select,
const IOobjectList& objects, const IOobjectList& objects,
const std::string& suffix = string::null const std::string& prefix = string::null
); );
@ -191,14 +191,16 @@ public:
vtkDataArraySelection* select 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 static hashedWordList getSelected
( (
vtkDataArraySelection* select 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 static hashedWordList getSelected
( (
vtkDataArraySelection* select, vtkDataArraySelection* select,
@ -228,8 +230,9 @@ public:
); );
//- Extract up to the first non-word characters //- Extract the first word characters after a slash
static word getFirstWord(const char* str); static word getFoamName(const std::string& str);
//- Simple memory used debugging information //- Simple memory used debugging information
static void printMemory(); static void printMemory();

View File

@ -60,20 +60,20 @@ Foam::label Foam::foamPvCore::addToSelection
( (
vtkDataArraySelection *select, vtkDataArraySelection *select,
const IOobjectList& objects, const IOobjectList& objects,
const std::string& suffix const std::string& prefix
) )
{ {
const wordList names = objects.sortedNames(Type::typeName); const wordList names = objects.sortedNames(Type::typeName);
forAll(names, i) forAll(names, i)
{ {
if (suffix.empty()) if (prefix.empty())
{ {
select->AddArray(names[i].c_str()); select->AddArray(names[i].c_str());
} }
else else
{ {
select->AddArray((names[i] + suffix).c_str()); select->AddArray((prefix + names[i]).c_str());
} }
} }