From 0054b9f4536bfa026fb4a6f2dfa82b578fb4512e Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Mon, 4 Nov 2019 18:29:29 +0100
Subject: [PATCH] ENH: use wordHashSet instead of hashedWordList in PV readers

- we don't need the GUI sort order of the values.
---
 src/paraview-plugins/foamPv/foamPvCore.C      | 20 +++++++-------
 src/paraview-plugins/foamPv/foamPvCore.H      | 15 +++++------
 src/paraview-plugins/vtkPVFoam/vtkPVFoam.C    |  9 +++----
 .../vtkPVFoam/vtkPVFoamFields.C               | 26 ++++++++++++++-----
 4 files changed, 40 insertions(+), 30 deletions(-)

diff --git a/src/paraview-plugins/foamPv/foamPvCore.C b/src/paraview-plugins/foamPv/foamPvCore.C
index 97f5438..fce9a9a 100644
--- a/src/paraview-plugins/foamPv/foamPvCore.C
+++ b/src/paraview-plugins/foamPv/foamPvCore.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2017 OpenCFD Ltd.
+    Copyright (C) 2017-2019 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -128,44 +128,44 @@ void Foam::foamPvCore::addToBlock
 }
 
 
-Foam::hashedWordList Foam::foamPvCore::getSelected
+Foam::wordHashSet Foam::foamPvCore::getSelected
 (
     vtkDataArraySelection* select
 )
 {
     const int n = select->GetNumberOfArrays();
-    DynamicList<word> selected(n);
+    wordHashSet selected(2*n);
 
     for (int i=0; i < n; ++i)
     {
         if (select->GetArraySetting(i))
         {
-            selected.append(getFoamName(select->GetArrayName(i)));
+            selected.set(getFoamName(select->GetArrayName(i)));
         }
     }
 
-    return hashedWordList(selected, true);
+    return selected;
 }
 
 
-Foam::hashedWordList Foam::foamPvCore::getSelected
+Foam::wordHashSet Foam::foamPvCore::getSelected
 (
     vtkDataArraySelection* select,
-    const arrayRange& selector
+    const labelRange& selector
 )
 {
     const int n = select->GetNumberOfArrays();
-    DynamicList<word> selected(n);
+    wordHashSet selected(2*n);
 
     for (auto i : selector)
     {
         if (select->GetArraySetting(i))
         {
-            selected.append(getFoamName(select->GetArrayName(i)));
+            selected.set(getFoamName(select->GetArrayName(i)));
         }
     }
 
-    return hashedWordList(selected, true);
+    return selected;
 }
 
 
diff --git a/src/paraview-plugins/foamPv/foamPvCore.H b/src/paraview-plugins/foamPv/foamPvCore.H
index dc1c82f..faad9ec 100644
--- a/src/paraview-plugins/foamPv/foamPvCore.H
+++ b/src/paraview-plugins/foamPv/foamPvCore.H
@@ -44,7 +44,6 @@ SourceFiles
 #include "Hash.H"
 #include "HashSet.H"
 #include "Map.H"
-#include "hashedWordList.H"
 #include "labelRange.H"
 
 // * * * * * * * * * * * * * Forward Declarations  * * * * * * * * * * * * * //
@@ -250,20 +249,20 @@ public:
     );
 
 
-    //- Retrieve the current selections as a hashedWordList,
-    //  while stripping off any prefix or suffix
-    static hashedWordList getSelected
+    //- Retrieve the current selections as a wordHashSet,
+    //- while stripping off any prefix or suffix
+    static wordHashSet getSelected
     (
         vtkDataArraySelection* select
     );
 
 
-    //- Retrieve a sub-list of the current selections as a hashedWordList,
-    //  while stripping off any prefix or suffix
-    static hashedWordList getSelected
+    //- Retrieve sub-list of the current selections as a wordHashSet,
+    //- while stripping off any prefix or suffix
+    static wordHashSet getSelected
     (
         vtkDataArraySelection* select,
-        const arrayRange& selector
+        const labelRange& selector
     );
 
 
diff --git a/src/paraview-plugins/vtkPVFoam/vtkPVFoam.C b/src/paraview-plugins/vtkPVFoam/vtkPVFoam.C
index f5caec0..c5c648c 100644
--- a/src/paraview-plugins/vtkPVFoam/vtkPVFoam.C
+++ b/src/paraview-plugins/vtkPVFoam/vtkPVFoam.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2017 OpenCFD Ltd.
+    Copyright (C) 2017-2019 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -789,11 +789,10 @@ void Foam::vtkPVFoam::renderPatchNames
 
     if (show && volMeshPtr_)
     {
-        // get the display patches, strip off any prefix/suffix
-        hashedWordList selectedPatches = getSelected
+        // Get the display patches, strip off any prefix/suffix
+        wordHashSet selectedPatches
         (
-            reader_->GetPartSelection(),
-            rangePatches_
+            getSelected(reader_->GetPartSelection(), rangePatches_)
         );
 
         if (selectedPatches.empty())
diff --git a/src/paraview-plugins/vtkPVFoam/vtkPVFoamFields.C b/src/paraview-plugins/vtkPVFoam/vtkPVFoamFields.C
index 238953c..348e062 100644
--- a/src/paraview-plugins/vtkPVFoam/vtkPVFoamFields.C
+++ b/src/paraview-plugins/vtkPVFoam/vtkPVFoamFields.C
@@ -49,9 +49,12 @@ void Foam::vtkPVFoam::convertVolFields()
     const fvMesh& mesh = *volMeshPtr_;
 
     const bool interpFields = reader_->GetInterpolateVolFields();
-    hashedWordList selectedFields = getSelected
+    wordHashSet selectedFields
     (
-        reader_->GetVolFieldSelection()
+        getSelected
+        (
+            reader_->GetVolFieldSelection()
+        )
     );
 
     if (selectedFields.empty())
@@ -124,9 +127,12 @@ void Foam::vtkPVFoam::convertPointFields()
 {
     const fvMesh& mesh = *volMeshPtr_;
 
-    hashedWordList selectedFields = getSelected
+    wordHashSet selectedFields
     (
-        reader_->GetPointFieldSelection()
+        getSelected
+        (
+            reader_->GetPointFieldSelection()
+        )
     );
 
     if (selectedFields.empty())
@@ -184,7 +190,10 @@ void Foam::vtkPVFoam::convertAreaFields()
 
     vtkDataArraySelection* select = reader_->GetVolFieldSelection();
 
-    hashedWordList selectedFields = getSelected(select);
+    wordHashSet selectedFields
+    (
+        getSelected(select)
+    );
 
     if (selectedFields.empty())
     {
@@ -233,9 +242,12 @@ void Foam::vtkPVFoam::convertLagrangianFields()
 
     const fvMesh& mesh = *volMeshPtr_;
 
-    hashedWordList selectedFields = getSelected
+    wordHashSet selectedFields
     (
-        reader_->GetLagrangianFieldSelection()
+        getSelected
+        (
+            reader_->GetLagrangianFieldSelection()
+        )
     );
 
     if (selectedFields.empty())
-- 
GitLab