ENH: improve internal bookkeeping in paraview readers

- has the selected values directly and use these lookup names to store
  directly into a hash. This replaces several parallel lists of
  decomp information etc and makes it easier.
This commit is contained in:
Mark Olesen
2017-05-14 21:42:59 +02:00
parent 09f0cfd5c7
commit cf5ebd82db
10 changed files with 431 additions and 331 deletions

View File

@ -194,22 +194,22 @@ Foam::hashedWordList Foam::foamPvCore::getSelected
}
Foam::stringList Foam::foamPvCore::getSelectedArrayEntries
Foam::HashSet<Foam::string>
Foam::foamPvCore::getSelectedArrayEntries
(
vtkDataArraySelection* select
)
{
stringList selections(select->GetNumberOfArrays());
label nElem = 0;
const int n = select->GetNumberOfArrays();
HashSet<string> selections(2*n);
forAll(selections, elemI)
for (int i=0; i < n; ++i)
{
if (select->GetArraySetting(elemI))
if (select->GetArraySetting(i))
{
selections[nElem++] = select->GetArrayName(elemI);
selections.insert(select->GetArrayName(i));
}
}
selections.setSize(nElem);
if (debug > 1)
{
@ -221,9 +221,9 @@ Foam::stringList Foam::foamPvCore::getSelectedArrayEntries
}
Info<< " )\nselected(";
forAll(selections, elemI)
for (auto k : selections)
{
Info<< " " << selections[elemI];
Info<< " " << k;
}
Info<< " )\n";
}
@ -232,65 +232,61 @@ Foam::stringList Foam::foamPvCore::getSelectedArrayEntries
}
Foam::stringList Foam::foamPvCore::getSelectedArrayEntries
Foam::HashSet<Foam::string>
Foam::foamPvCore::getSelectedArrayEntries
(
vtkDataArraySelection* select,
const arrayRange& selector
const arrayRange& slice
)
{
stringList selections(selector.size());
label nElem = 0;
const int n = select->GetNumberOfArrays();
HashSet<string> enabled(2*n);
for (auto i : selector)
for (auto i : slice)
{
if (select->GetArraySetting(i))
{
selections[nElem++] = select->GetArrayName(i);
enabled.insert(select->GetArrayName(i));
}
}
selections.setSize(nElem);
if (debug > 1)
{
Info<< "available(";
for (auto i : selector)
for (auto i : slice)
{
Info<< " \"" << select->GetArrayName(i) << "\"";
}
Info<< " )\nselected(";
forAll(selections, elemI)
for (auto k : enabled)
{
Info<< " " << selections[elemI];
Info<< " " << k;
}
Info<< " )\n";
}
return selections;
return enabled;
}
void Foam::foamPvCore::setSelectedArrayEntries
(
vtkDataArraySelection* select,
const stringList& selections
const HashSet<string>& enabled
)
{
const int n = select->GetNumberOfArrays();
// disable everything not explicitly enabled
select->DisableAllArrays();
// Loop through entries, setting values from selectedEntries
// Loop through entries, enabling as required
for (int i=0; i < n; ++i)
{
const string arrayName(select->GetArrayName(i));
forAll(selections, elemI)
const char* arrayName = select->GetArrayName(i);
if (enabled.found(arrayName))
{
if (selections[elemI] == arrayName)
{
select->EnableArray(arrayName.c_str());
break;
}
select->EnableArray(arrayName);
}
}
}

View File

@ -39,6 +39,7 @@ SourceFiles
#include "pointList.H"
#include "wordList.H"
#include "Hash.H"
#include "HashSet.H"
#include "hashedWordList.H"
#include "labelRange.H"
@ -208,25 +209,25 @@ public:
);
//- Retrieve the current selections
static stringList getSelectedArrayEntries
//- Retrieve the currently enabled selections
static HashSet<string> getSelectedArrayEntries
(
vtkDataArraySelection* select
);
//- Retrieve a sub-list of the current selections
static stringList getSelectedArrayEntries
//- Retrieve a sub-list of the currently enabled selections
static HashSet<string> getSelectedArrayEntries
(
vtkDataArraySelection* select,
const arrayRange& selector
const arrayRange& slice
);
//- Set selection(s)
//- Enable the selection(s)
static void setSelectedArrayEntries
(
vtkDataArraySelection* select,
const stringList& selections
const HashSet<string>& enabled
);