Salome HOME
StaticMeshPlugin porting for PV5.11
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 13 Oct 2022 14:33:19 +0000 (16:33 +0200)
committerAnthony GEAY <anthony.geay@edf.fr>
Fri, 14 Oct 2022 06:32:00 +0000 (08:32 +0200)
src/Plugins/CMakeLists.txt
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticDataSetSurfaceFilter.h
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6BinaryReader.cxx
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6Reader.cxx
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldBinaryReader.cxx
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldReader.cxx
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticMeshObjectFactory.cxx
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPUnstructuredGridGhostCellsGenerator.h
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.cxx
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.h

index 73d5bf8fa59a83678dad60a5610d34dcb5ad06b0..9cfe8fe16d328e0ae16959174d89d43d216a8938 100644 (file)
@@ -29,7 +29,7 @@ SET(_subdirs
   ArrayRenamer
   JSONReader
   DevelopedSurface
-  #StaticMesh
+  StaticMesh
   GaussToCell
   VoroGauss
   )
index 27a16de007f708d9752efeaf5cd3527100640c1f..20eab9a32db3a8eb76b770efe074057b53f1e432 100644 (file)
 #ifndef vtkStaticDataSetSurfaceFilter_h
 #define vtkStaticDataSetSurfaceFilter_h
 
-#include <vtkDataSetSurfaceFilter.h>
+#include <vtkGeometryFilter.h>
 #include <vtkNew.h>
 
 #include "StaticMeshModuleModule.h"
 
 class vtkPolyData;
 
-class STATICMESHMODULE_EXPORT vtkStaticDataSetSurfaceFilter : public vtkDataSetSurfaceFilter
+class STATICMESHMODULE_EXPORT vtkStaticDataSetSurfaceFilter : public vtkGeometryFilter
 {
 public:
   static vtkStaticDataSetSurfaceFilter* New();
   // vtkTypeMacro can't be used with a factory built object
-  using Superclass = vtkDataSetSurfaceFilter;
+  using Superclass = vtkGeometryFilter;
   void PrintSelf(ostream& os, vtkIndent indent) override;
 
   /**
index 9fa199b6a46d7169eb0105dacc261bbf614ac8ad..677df958137d1ec7ebfb74dff07fff702b5306d1 100644 (file)
@@ -106,7 +106,7 @@ int vtkStaticEnSight6BinaryReader::RequestData(vtkInformation* vtkNotUsed(reques
               int filenameNum = filenameNumbers->GetId(timeStep - 1);
               if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
@@ -140,7 +140,7 @@ int vtkStaticEnSight6BinaryReader::RequestData(vtkInformation* vtkNotUsed(reques
               {
                 vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum);
                 int filenameNum = filenameNumbers->GetId(fileNum - 1);
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
@@ -187,7 +187,7 @@ int vtkStaticEnSight6BinaryReader::RequestData(vtkInformation* vtkNotUsed(reques
               int filenameNum = filenameNumbers->GetId(timeStep - 1);
               if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
@@ -221,7 +221,7 @@ int vtkStaticEnSight6BinaryReader::RequestData(vtkInformation* vtkNotUsed(reques
               {
                 vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet);
                 int filenameNum = filenameNumbers->GetId(fileNum - 1);
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
index 7845d3115c71982c4b89a552346a31e9a74209b3..76054db89e922ee5c3864b1493bad593fdfc8213 100644 (file)
@@ -106,7 +106,7 @@ int vtkStaticEnSight6Reader::RequestData(vtkInformation* vtkNotUsed(request),
               int filenameNum = filenameNumbers->GetId(timeStep - 1);
               if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
@@ -140,7 +140,7 @@ int vtkStaticEnSight6Reader::RequestData(vtkInformation* vtkNotUsed(request),
               {
                 vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum);
                 int filenameNum = filenameNumbers->GetId(fileNum - 1);
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
@@ -187,7 +187,7 @@ int vtkStaticEnSight6Reader::RequestData(vtkInformation* vtkNotUsed(request),
               int filenameNum = filenameNumbers->GetId(timeStep - 1);
               if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
@@ -221,7 +221,7 @@ int vtkStaticEnSight6Reader::RequestData(vtkInformation* vtkNotUsed(request),
               {
                 vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet);
                 int filenameNum = filenameNumbers->GetId(fileNum - 1);
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
index f6965b5f98b629ba731e7fb15f82c227a0f2d1e0..ed9d60d65c1e1d239bbf84176b98d12f0306b56e 100644 (file)
@@ -106,7 +106,7 @@ int vtkStaticEnSightGoldBinaryReader::RequestData(vtkInformation* vtkNotUsed(req
               int filenameNum = filenameNumbers->GetId(timeStep - 1);
               if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
@@ -140,7 +140,7 @@ int vtkStaticEnSightGoldBinaryReader::RequestData(vtkInformation* vtkNotUsed(req
               {
                 vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum);
                 int filenameNum = filenameNumbers->GetId(fileNum - 1);
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
@@ -187,7 +187,7 @@ int vtkStaticEnSightGoldBinaryReader::RequestData(vtkInformation* vtkNotUsed(req
               int filenameNum = filenameNumbers->GetId(timeStep - 1);
               if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
@@ -221,7 +221,7 @@ int vtkStaticEnSightGoldBinaryReader::RequestData(vtkInformation* vtkNotUsed(req
               {
                 vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet);
                 int filenameNum = filenameNumbers->GetId(fileNum - 1);
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
index f338f1225fc63e78994d81d650a80f46470018ba..35377b794625074c455abfb0b454bc60a0d9a601 100644 (file)
@@ -106,7 +106,7 @@ int vtkStaticEnSightGoldReader::RequestData(vtkInformation* vtkNotUsed(request),
               int filenameNum = filenameNumbers->GetId(timeStep - 1);
               if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
@@ -140,7 +140,7 @@ int vtkStaticEnSightGoldReader::RequestData(vtkInformation* vtkNotUsed(request),
               {
                 vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum);
                 int filenameNum = filenameNumbers->GetId(fileNum - 1);
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
@@ -187,7 +187,7 @@ int vtkStaticEnSightGoldReader::RequestData(vtkInformation* vtkNotUsed(request),
               int filenameNum = filenameNumbers->GetId(timeStep - 1);
               if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
@@ -221,7 +221,7 @@ int vtkStaticEnSightGoldReader::RequestData(vtkInformation* vtkNotUsed(request),
               {
                 vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet);
                 int filenameNum = filenameNumbers->GetId(fileNum - 1);
-                this->ReplaceWildcards(&fileName[0], filenameNum);
+                this->ReplaceWildcardsHelper(&fileName[0], filenameNum);
               }
             }
           }
index bb8f91ae3f80cd771e153416e8b73f778ae6aa38..deaace7a1c38ba4f70df39fcdfd4d1a2caec7999 100644 (file)
@@ -46,7 +46,7 @@ VTK_CREATE_CREATE_FUNCTION(vtkStaticPUnstructuredGridGhostCellsGenerator);
 //-----------------------------------------------------------------------------
 vtkStaticMeshObjectFactory::vtkStaticMeshObjectFactory()
 {
-  this->RegisterOverride("vtkDataSetSurfaceFilter", "vtkStaticDataSetSurfaceFilter",
+  this->RegisterOverride("vtkGeometryFilter", "vtkStaticDataSetSurfaceFilter",
     "StaticDataSetSurfaceFilter", 1, vtkObjectFactoryCreatevtkStaticDataSetSurfaceFilter);
   this->RegisterOverride("vtkPlaneCutter", "vtkStaticPlaneCutter", "StaticPlaneCutter", 1,
     vtkObjectFactoryCreatevtkStaticPlaneCutter);
index 1152d6a3ef80597487142484b3970d1aeca7629d..bfcc3669193a588e2228ee487fb58bb2b88d2597 100644 (file)
@@ -16,7 +16,7 @@
  * @class   vtkStaticPUnstructuredGridGhostCellsGenerator
  * @brief   StaticMesh aware GhostCellGenerator implementation
  *
- * This class specialize vtkPUnstructuredGridGhostCellGenerator
+ * This class specialize vtkGhostCellsGenerator
  * This class improves it by making it static mesh aware.
  * The first time this filter is executed it will store its output
  * in a cache as well as a list of ghost and point ids to request from other rank
  * allowing to update the output without needing to recompute everything
  *
  * @sa
- * vtkPUnstructuredGridGhostCellsGenerator
+ * vtkGhostCellsGenerator
  */
 
 #ifndef vtkStaticPUnstructuredGridGhostCellsGenerator_h
 #define vtkStaticPUnstructuredGridGhostCellsGenerator_h
 
 #include <vtkNew.h>
-#include <vtkPUnstructuredGridGhostCellsGenerator.h>
+#include <vtkGhostCellsGenerator.h>
 
 #include <vector>
 
 #include "StaticMeshModuleModule.h"
 
 class vtkIdList;
+class vtkDataSet;
 class vtkUnstructuredGrid;
 
 class STATICMESHMODULE_EXPORT vtkStaticPUnstructuredGridGhostCellsGenerator
-  : public vtkPUnstructuredGridGhostCellsGenerator
+  : public vtkGhostCellsGenerator
 {
 public:
   static vtkStaticPUnstructuredGridGhostCellsGenerator* New();
-  typedef vtkPUnstructuredGridGhostCellsGenerator
+  typedef vtkGhostCellsGenerator
     Superclass; // vtkTypeMacro can't be used with a factory built object
   void PrintSelf(ostream& os, vtkIndent indent) override;
 
index 73d73ebefb524297c8e0faa601548cff6f58d90e..12c20d975754e04642d623115d8ecaebf3308aa7 100644 (file)
@@ -24,6 +24,7 @@
 #include <vtkMultiBlockDataSet.h>
 #include <vtkMultiPieceDataSet.h>
 #include <vtkObjectFactory.h>
+#include <vtkPartitionedDataSetCollection.h>
 #include <vtkPointData.h>
 #include <vtkPolyData.h>
 #include <vtkUnstructuredGrid.h>
@@ -38,31 +39,43 @@ int vtkStaticPlaneCutter::RequestData(
   vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
 {
   // get the inputs and outputs
-
-  vtkUnstructuredGrid* input = vtkUnstructuredGrid::GetData(inputVector[0]);
-  vtkMultiBlockDataSet* inputMB = vtkMultiBlockDataSet::GetData(inputVector[0]);
-  vtkMultiBlockDataSet* mb = vtkMultiBlockDataSet::GetData(outputVector);
-  if (!mb)
+  auto inputDO = vtkDataObject::GetData(inputVector[0], 0);
+  auto outputDO = vtkDataObject::GetData(outputVector, 0);
+  if (inputDO == nullptr)
   {
-    vtkErrorMacro("Ouput information does not contain expected type of data object");
+    vtkErrorMacro("Input is nullptr.");
     return 0;
   }
 
-  // Recover the first and only block so this works with single block mb
+  vtkUnstructuredGrid* inputUG = vtkUnstructuredGrid::SafeDownCast(inputDO);
+  vtkMultiBlockDataSet* inputMB = vtkMultiBlockDataSet::SafeDownCast(inputDO);
+  vtkPartitionedDataSetCollection* inputPDC =
+    vtkPartitionedDataSetCollection::SafeDownCast(inputDO);
+  vtkPartitionedDataSet* inputPD = vtkPartitionedDataSet::SafeDownCast(inputDO);
+
+  // Recover the first and only block/partition so this works with single block composite
   if (inputMB && inputMB->GetNumberOfBlocks() == 1)
   {
-    input = vtkUnstructuredGrid::SafeDownCast(inputMB->GetBlock(0));
+    inputUG = vtkUnstructuredGrid::SafeDownCast(inputMB->GetBlock(0));
+  }
+  if (inputPDC && inputPDC->GetNumberOfPartitionedDataSets() == 1)
+  {
+    inputPD = vtkPartitionedDataSet::SafeDownCast(inputPDC->GetPartitionedDataSet(0));
+  }
+  if (inputPD && inputPD->GetNumberOfPartitions() == 1)
+  {
+    inputUG = vtkUnstructuredGrid::SafeDownCast(inputPD->GetPartition(0));
   }
 
   // Recover the static unstructured grid
-  if (!input)
+  if (!inputUG)
   {
     // For any other type of input, fall back to superclass implementation
     return this->Superclass::RequestData(request, inputVector, outputVector);
   }
 
   // Check cache validity
-  if (this->InputMeshTime == input->GetMeshMTime() && this->FilterMTime == this->GetMTime())
+  if (this->InputMeshTime == inputUG->GetMeshMTime() && this->FilterMTime == this->GetMTime())
   {
     // Cache mesh is up to date, use it to generate data
     if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
@@ -73,11 +86,12 @@ int vtkStaticPlaneCutter::RequestData(
     if (this->InterpolateAttributes)
     {
       // Update the cache data
-      this->UpdateCacheData(input);
+      this->UpdateCacheData(inputUG);
     }
 
     // Copy the updated cache into the output
-    mb->SetBlock(0, this->Cache);
+    this->SetOutputFromCache(outputDO);
+    this->RemoveIdsArray(outputDO);
     return 1;
   }
   else
@@ -90,7 +104,7 @@ int vtkStaticPlaneCutter::RequestData(
 
     // Add needed Arrays
     vtkNew<vtkUnstructuredGrid> tmpInput;
-    this->AddIdsArray(input, tmpInput);
+    this->AddIdsArray(inputUG, tmpInput);
 
     // Create an input vector to pass the completed input to the superclass
     // RequestData method
@@ -102,20 +116,14 @@ int vtkStaticPlaneCutter::RequestData(
     int ret = this->Superclass::RequestData(request, &tmpInputVecPt, outputVector);
 
     // Update the cache with superclass output
-    vtkMultiPieceDataSet* output = vtkMultiPieceDataSet::SafeDownCast(mb->GetBlock(0));
-    if (!output)
-    {
-      vtkErrorMacro("Output is not of expected type");
-      return 0;
-    }
-
-    this->Cache->ShallowCopy(output);
-    this->InputMeshTime = input->GetMeshMTime();
+    this->Cache->ShallowCopy(outputDO);
+    assert(this->Cache);
+    this->InputMeshTime = inputUG->GetMeshMTime();
     this->FilterMTime = this->GetMTime();
 
     // Compute the ids to be passed from the input to the cache
-    this->ComputeIds(input);
-    this->RemoveIdsArray(this->Cache);
+    this->ComputeIds(inputUG);
+    this->RemoveIdsArray(outputDO);
     return ret;
   }
 }
@@ -145,19 +153,31 @@ void vtkStaticPlaneCutter::AddIdsArray(vtkDataSet* input, vtkDataSet* output)
 }
 
 //-----------------------------------------------------------------------------
-void vtkStaticPlaneCutter::RemoveIdsArray(vtkMultiPieceDataSet* output)
+void vtkStaticPlaneCutter::RemoveIdsArray(vtkDataObject* output)
 {
-  vtkSmartPointer<vtkCompositeDataIterator> iter;
-  iter.TakeReference(output->NewIterator());
-  iter->SkipEmptyNodesOn();
-  for (iter->GoToFirstItem(); !iter->IsDoneWithTraversal(); iter->GoToNextItem())
+
+  if (auto pd = vtkPolyData::SafeDownCast(output))
   {
-    vtkPolyData* slice = vtkPolyData::SafeDownCast(iter->GetCurrentDataObject());
-    if (slice)
+    pd->GetCellData()->RemoveArray(IdsArrayName);
+  }
+  else if (auto outputMP = vtkMultiPieceDataSet::SafeDownCast(output))
+  {
+    vtkSmartPointer<vtkCompositeDataIterator> iter;
+    iter.TakeReference(outputMP->NewIterator());
+    iter->SkipEmptyNodesOn();
+    for (iter->GoToFirstItem(); !iter->IsDoneWithTraversal(); iter->GoToNextItem())
     {
-      slice->GetCellData()->RemoveArray(IdsArrayName);
+      vtkPolyData* slice = vtkPolyData::SafeDownCast(iter->GetCurrentDataObject());
+      if (slice)
+      {
+        slice->GetCellData()->RemoveArray(IdsArrayName);
+      }
     }
   }
+  else
+  {
+    std::cerr << "Unhandled object type: " << output->GetClassName() << std::endl;
+  }
 }
 
 //-----------------------------------------------------------------------------
@@ -293,3 +313,23 @@ void vtkStaticPlaneCutter::PrintSelf(ostream& os, vtkIndent indent)
   os << indent << "Input Mesh Time: " << this->InputMeshTime << endl;
   os << indent << "Filter mTime: " << this->FilterMTime << endl;
 }
+
+//----------------------------------------------------------------------------
+void vtkStaticPlaneCutter::SetOutputFromCache(vtkDataObject* output)
+{
+  if (auto pd = vtkPolyData::SafeDownCast(output))
+  {
+    assert(this->Cache->GetNumberOfPieces() == 1);
+    auto p0 = vtkPolyData::SafeDownCast(this->Cache->GetPartition(0));
+    assert(p0);
+    pd->ShallowCopy(p0);
+  }
+  else if (auto mb = vtkMultiPieceDataSet::SafeDownCast(output))
+  {
+    mb->ShallowCopy(this->Cache);
+  }
+  else
+  {
+    vtkErrorMacro("Unhandled output type: " << output->GetClassName());
+  }
+}
index ba836c440fe3b005ab11200d0adaba27a2f41d83..5dc349775826316b636b02e60612a76f87d8b43a 100644 (file)
 #include <vtkNew.h>
 #include <vtkPlaneCutter.h>
 #include <vtkSmartPointer.h>
-#include <vtkUnstructuredGrid.h>
 
 #include <vector>
 
 #include "StaticMeshModuleModule.h"
 
+class vtkUnstructuredGrid;
 class vtkMultiPieceDataSet;
 
 class STATICMESHMODULE_EXPORT vtkStaticPlaneCutter : public vtkPlaneCutter
@@ -66,7 +66,7 @@ protected:
   /**
    * Remove an Ids cell array in all polydata pieces of output
    */
-  static void RemoveIdsArray(vtkMultiPieceDataSet* output);
+  static void RemoveIdsArray(vtkDataObject* output);
 
   /**
    * Update cache point, cell and field data using input
@@ -78,6 +78,11 @@ protected:
    */
   void ComputeIds(vtkUnstructuredGrid* input);
 
+  /**
+   * Fill the output using the Cache, depending on its type
+   */
+   void SetOutputFromCache(vtkDataObject* output);
+
 private:
   // Hide these from the user and the compiler.
   vtkStaticPlaneCutter(const vtkStaticPlaneCutter&) = delete;