]> SALOME platform Git repositories - modules/paravis.git/commitdiff
Salome HOME
[EDF24911] : StaticMesh option in Ensight Reader + Force Static Mesh Plugin. Synchron... V9_9_0b1
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 7 Apr 2022 07:24:35 +0000 (09:24 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 7 Apr 2022 07:24:35 +0000 (09:24 +0200)
28 files changed:
src/Plugins/StaticMesh/plugin/CMakeLists.txt
src/Plugins/StaticMesh/plugin/StaticMeshModule/CMakeLists.txt
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtk.module
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkForceStaticMesh.cxx [new file with mode: 0644]
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkForceStaticMesh.h [new file with mode: 0644]
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkGenericStaticEnSightReader.cxx [new file with mode: 0644]
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkGenericStaticEnSightReader.h [new file with mode: 0644]
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticDataSetSurfaceFilter.cxx
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticDataSetSurfaceFilter.h
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6BinaryReader.cxx
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6BinaryReader.h
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6Reader.cxx
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6Reader.h
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldBinaryReader.cxx
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldBinaryReader.h
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldReader.cxx
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldReader.h
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticMeshObjectFactory.cxx
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticMeshObjectFactory.h
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPUnstructuredGridGhostCellsGenerator.cxx
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPUnstructuredGridGhostCellsGenerator.h
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.cxx
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.h
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkTemporalUGWavelet.cxx
src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkTemporalUGWavelet.h
src/Plugins/StaticMesh/plugin/filters.xml [new file with mode: 0644]
src/Plugins/StaticMesh/plugin/readers.xml [new file with mode: 0644]
src/Plugins/StaticMesh/plugin/sources.xml

index 0fe40a0f700f5e6faef9e14c4cb2ea03d0ffed66..61bf3e3d6c2ec3a7ece47f8c242a27903abf2825 100644 (file)
@@ -21,7 +21,7 @@ paraview_add_plugin(StaticMesh
   VERSION "1.0"
   MODULES StaticMeshModule
   MODULE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/StaticMeshModule/vtk.module"
-  SERVER_MANAGER_XML sources.xml
+  SERVER_MANAGER_XML sources.xml readers.xml filters.xml
 )
 
 install(TARGETS StaticMesh
index 3ea7b1fb3f35d64dd3b60ec3b7d814c09873252b..a835e61213d677fef4275e9872c0b24f09cf4670 100644 (file)
@@ -27,6 +27,8 @@ set(private_classes
 )
 
 set(classes
+  vtkForceStaticMesh
+  vtkGenericStaticEnSightReader
   vtkTemporalUGWavelet
   vtkStaticMeshObjectFactory
 )
index d6165617a106e208795d7361818ea37aa4e1d7f5..fd86d1c544844ef2aae3d964c3d2a5c8b030e0d2 100644 (file)
@@ -5,13 +5,14 @@ DEPENDS
   VTK::CommonDataModel
   VTK::CommonExecutionModel
   VTK::FiltersCore
-  VTK::FiltersModeling
   VTK::FiltersGeometry
-  VTK::FiltersParallelGeometry
+  VTK::FiltersModeling
   VTK::ImagingCore
   VTK::IOCore
   VTK::IOGeometry
   VTK::IOEnSight
+OPTIONAL_DEPENDS
+  VTK::FiltersParallelGeometry
 PRIVATE_DEPENDS
   VTK::CommonMisc
   VTK::CommonSystem
diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkForceStaticMesh.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkForceStaticMesh.cxx
new file mode 100644 (file)
index 0000000..de4ced0
--- /dev/null
@@ -0,0 +1,110 @@
+/*=========================================================================
+
+  Program:   Visualization Toolkit
+  Module:    vtkForceStaticMesh.cxx
+
+  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
+  All rights reserved.
+  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+
+#include "vtkForceStaticMesh.h"
+
+#include <vtkCellData.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+#include <vtkMultiBlockDataSet.h>
+#include <vtkObjectFactory.h>
+#include <vtkPointData.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtksys/SystemTools.hxx>
+
+vtkStandardNewMacro(vtkForceStaticMesh);
+
+//------------------------------------------------------------------------------
+void vtkForceStaticMesh::PrintSelf(ostream& os, vtkIndent indent)
+{
+  this->Superclass::PrintSelf(os, indent);
+  os << indent << "ForceCacheComputation: " << (this->ForceCacheComputation ? "on" : "off") << endl;
+}
+
+//------------------------------------------------------------------------------
+int vtkForceStaticMesh::FillInputPortInformation(int, vtkInformation* info)
+{
+  info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataObject");
+  return 1;
+}
+
+//------------------------------------------------------------------------------
+int vtkForceStaticMesh::RequestData(vtkInformation* vtkNotUsed(request),
+  vtkInformationVector** inputVector, vtkInformationVector* outputVector)
+{
+  vtkUnstructuredGrid* input = vtkUnstructuredGrid::GetData(inputVector[0]);
+  vtkMultiBlockDataSet* inputMB = vtkMultiBlockDataSet::GetData(inputVector[0]);
+
+  // Recover the first block
+  if (inputMB && inputMB->GetNumberOfBlocks() >= 1)
+  {
+    input = vtkUnstructuredGrid::SafeDownCast(inputMB->GetBlock(0));
+  }
+
+  if (!input)
+  {
+    vtkErrorMacro("Input is invalid, it should be either an unstructured grid or a multiblock a unstructured grid in the first block");
+    return 0;
+  }
+
+  if (inputMB && inputMB->GetNumberOfBlocks() > 1)
+  {
+    vtkWarningMacro("Only the first block will be passed");
+  }
+
+  vtkUnstructuredGrid* output = vtkUnstructuredGrid::GetData(outputVector);
+
+  bool validCache = this->CacheInitialized;
+  if (validCache)
+  {
+    if (input->GetNumberOfPoints() != this->Cache->GetNumberOfPoints())
+    {
+      vtkWarningMacro("Cache has been invalidated, the number of points in input changed, from " << this->Cache->GetNumberOfPoints() << " to " << input->GetNumberOfPoints());
+      validCache = false;
+    }
+    if (input->GetNumberOfCells() != this->Cache->GetNumberOfCells())
+    {
+      vtkWarningMacro("Cache has been invalidated, the number of cells in input changed, from " << this->Cache->GetNumberOfCells() << " to " << input->GetNumberOfCells());
+      validCache = false;
+    }
+  }
+
+  if (this->ForceCacheComputation || !validCache)
+  {
+    // Cache is invalid
+    if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+    {
+      vtkWarningMacro("Building static mesh cache");
+    }
+
+    this->Cache->DeepCopy(input);
+    this->CacheInitialized = true;
+  }
+  else
+  {
+    // Cache mesh is up to date, use it to generate data
+    if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+    {
+      vtkWarningMacro("Using static mesh cache");
+    }
+
+    this->Cache->GetPointData()->ShallowCopy(input->GetPointData());
+    this->Cache->GetCellData()->ShallowCopy(input->GetCellData());
+    this->Cache->GetFieldData()->ShallowCopy(input->GetFieldData());
+  }
+
+  output->ShallowCopy(this->Cache);
+  return 1;
+}
diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkForceStaticMesh.h b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkForceStaticMesh.h
new file mode 100644 (file)
index 0000000..112c95b
--- /dev/null
@@ -0,0 +1,67 @@
+/*=========================================================================
+
+  Program:   Visualization Toolkit
+  Module:    vtkForceStaticMesh.h
+
+  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
+  All rights reserved.
+  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+/**
+ * @class vtkForceStaticMesh
+ * @brief Takes in input as a cache the first time it is executed then use it as a static mesh
+ *
+ * The Force Static Mesh filter create a cache the first time it is used using its input. It will then only
+ * update PointData, CellData and FieldData from the input if their dimensions are valid.
+ * This filter operates only on vtkUnstructuredGrid or on vtkMultiBlockDataSet containing a single vtkUnstructuredGrid
+ */
+
+#ifndef vtkForceStaticMesh_h
+#define vtkForceStaticMesh_h
+
+#include <vtkUnstructuredGridAlgorithm.h>
+#include <vtkNew.h>
+
+#include "StaticMeshModuleModule.h"
+
+class vtkUnstructuredGrid;
+
+class STATICMESHMODULE_EXPORT vtkForceStaticMesh : public vtkUnstructuredGridAlgorithm
+{
+public:
+  static vtkForceStaticMesh* New();
+  vtkTypeMacro(vtkForceStaticMesh, vtkUnstructuredGridAlgorithm);
+  void PrintSelf(ostream& os, vtkIndent indent) override;
+
+  //@{
+  /**
+   * When set to true, this will force this filter to recompute its cache.
+   * Default is false.
+   */
+  vtkSetMacro(ForceCacheComputation, vtkTypeBool);
+  vtkGetMacro(ForceCacheComputation, vtkTypeBool);
+  vtkBooleanMacro(ForceCacheComputation, vtkTypeBool);
+  //@}
+
+protected:
+  vtkForceStaticMesh() = default;
+  ~vtkForceStaticMesh() override = default;
+
+  int FillInputPortInformation(int port, vtkInformation* info) override;
+  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
+
+private:
+  vtkForceStaticMesh(const vtkForceStaticMesh&) = delete;
+  void operator=(const vtkForceStaticMesh&) = delete;
+  
+  bool ForceCacheComputation = false;
+  bool CacheInitialized = false;
+  vtkNew<vtkUnstructuredGrid> Cache;
+};
+
+#endif
diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkGenericStaticEnSightReader.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkGenericStaticEnSightReader.cxx
new file mode 100644 (file)
index 0000000..2cf49f3
--- /dev/null
@@ -0,0 +1,74 @@
+/*=========================================================================
+
+  Program:   Visualization Toolkit
+  Module:    vtkGenericStaticEnSightReader.cxx
+
+  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
+  All rights reserved.
+  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+#include "vtkGenericStaticEnSightReader.h"
+#include "vtkObjectFactory.h"
+
+#include "vtkStaticEnSight6BinaryReader.h"
+#include "vtkStaticEnSight6Reader.h"
+#include "vtkStaticEnSightGoldBinaryReader.h"
+#include "vtkStaticEnSightGoldReader.h"
+
+vtkStandardNewMacro(vtkGenericStaticEnSightReader);
+
+//------------------------------------------------------------------------------
+int vtkGenericStaticEnSightReader::RequestInformation(
+  vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
+{
+  int ri = this->Superclass::RequestInformation(request, inputVector, outputVector);
+
+  // 6 binary
+  vtkStaticEnSight6BinaryReader* es6binary =
+    vtkStaticEnSight6BinaryReader::SafeDownCast(this->Reader);
+  if (es6binary)
+  {
+    es6binary->SetUseStaticMesh(this->UseStaticMesh);
+    return ri;
+  }
+
+  // 6
+  vtkStaticEnSight6Reader* es6 = vtkStaticEnSight6Reader::SafeDownCast(this->Reader);
+  if (es6)
+  {
+    es6->SetUseStaticMesh(this->UseStaticMesh);
+    return ri;
+  }
+
+  // Gold binary
+  vtkStaticEnSightGoldBinaryReader* goldBinary =
+    vtkStaticEnSightGoldBinaryReader::SafeDownCast(this->Reader);
+  if (goldBinary)
+  {
+    goldBinary->SetUseStaticMesh(this->UseStaticMesh);
+    return ri;
+  }
+
+  // Gold
+  vtkStaticEnSightGoldReader* gold = vtkStaticEnSightGoldReader::SafeDownCast(this->Reader);
+  if (gold)
+  {
+    gold->SetUseStaticMesh(this->UseStaticMesh);
+    return ri;
+  }
+
+  vtkErrorMacro("Failed to determine static mesh version of the EnSight reader.");
+  return 0;
+}
+
+//------------------------------------------------------------------------------
+void vtkGenericStaticEnSightReader::PrintSelf(ostream& os, vtkIndent indent)
+{
+  this->Superclass::PrintSelf(os, indent);
+  os << "UseStaticMesh: " << this->UseStaticMesh << std::endl;
+}
diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkGenericStaticEnSightReader.h b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkGenericStaticEnSightReader.h
new file mode 100644 (file)
index 0000000..540b80a
--- /dev/null
@@ -0,0 +1,68 @@
+/*=========================================================================
+
+  Program:   Visualization Toolkit
+  Module:    vtkGenericStaticEnSightReader.h
+
+  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
+  All rights reserved.
+  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+/**
+ * @class   vtkGenericStaticEnSightReader
+ * @brief   class to read any type of EnSight files
+ *
+ * The class vtkGenericStaticEnSightReader inherit from the
+ * vtkGenericEnSightReader. In addition to allowing the user to read
+ * various types of EnSight files, it add a boolean to control whether
+ * or not the output mesh should be considered static.
+ *
+ * Keep this boolean to false for non-static EnSight files.
+ */
+
+#ifndef vtkGenericStaticEnSightReader_h
+#define vtkGenericStaticEnSightReader_h
+
+#include <vtkGenericEnSightReader.h>
+#include <vtkSetGet.h>
+
+#include "StaticMeshModuleModule.h"
+
+class STATICMESHMODULE_EXPORT vtkGenericStaticEnSightReader : public vtkGenericEnSightReader
+{
+public:
+  static vtkGenericStaticEnSightReader* New();
+  vtkTypeMacro(vtkGenericStaticEnSightReader, vtkGenericEnSightReader);
+  void PrintSelf(ostream& os, vtkIndent indent) override;
+
+  // @{
+  /**
+   * This boolean control whether or not the output
+   * should be considered a static mesh.
+   */
+  vtkGetMacro(UseStaticMesh, bool);
+  vtkSetMacro(UseStaticMesh, bool);
+  vtkBooleanMacro(UseStaticMesh, bool);
+  // @}
+
+protected:
+  vtkGenericStaticEnSightReader() = default;
+  ~vtkGenericStaticEnSightReader() override = default;
+
+  /**
+   * see vtkDataSetAlgorithm
+   */
+  int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
+
+private:
+  vtkGenericStaticEnSightReader(const vtkGenericStaticEnSightReader&) = delete;
+  void operator=(const vtkGenericStaticEnSightReader&) = delete;
+
+  bool UseStaticMesh = false;
+};
+
+#endif
index 429e890535919daa5101125589d2b48aaa0e4717..43b701f8f0ddba2a913161b9d867b345f0f816e6 100644 (file)
 #include <vtkObjectFactory.h>
 #include <vtkPointData.h>
 #include <vtkUnstructuredGrid.h>
+#include <vtksys/SystemTools.hxx>
 
 vtkStandardNewMacro(vtkStaticDataSetSurfaceFilter);
 
-//----------------------------------------------------------------------------
-vtkStaticDataSetSurfaceFilter::vtkStaticDataSetSurfaceFilter()
-{
-  this->InputMeshTime = 0;
-  this->FilterMTime = 0;
-}
-
-//----------------------------------------------------------------------------
-vtkStaticDataSetSurfaceFilter::~vtkStaticDataSetSurfaceFilter()
-{
-}
-
 //-----------------------------------------------------------------------------
 int vtkStaticDataSetSurfaceFilter::UnstructuredGridExecute(vtkDataSet* input, vtkPolyData* output)
 {
@@ -45,9 +34,14 @@ int vtkStaticDataSetSurfaceFilter::UnstructuredGridExecute(vtkDataSet* input, vt
     return this->Superclass::UnstructuredGridExecute(input, output);
   }
 
-  // Check is cache is still valid
+  // Check if cache is still valid
   if (this->InputMeshTime == inputUG->GetMeshMTime() && this->FilterMTime == this->GetMTime())
   {
+    if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+    {
+      vtkWarningMacro("Using static mesh cache");
+    }
+
     // Use cache as base
     output->ShallowCopy(this->Cache.Get());
 
@@ -70,11 +64,13 @@ int vtkStaticDataSetSurfaceFilter::UnstructuredGridExecute(vtkDataSet* input, vt
     vtkCellData* inCD = input->GetCellData();
 
     // Update output point data
-    vtkIdType* tmpIds = new vtkIdType[origPointArray->GetNumberOfTuples()];
-    memcpy(tmpIds, reinterpret_cast<vtkIdType*>(origPointArray->GetVoidPointer(0)),
-      sizeof(vtkIdType) * origPointArray->GetNumberOfTuples());
     vtkNew<vtkIdList> pointIds;
-    pointIds->SetArray(tmpIds, origPointArray->GetNumberOfTuples());
+    const vtkIdType origPANbTuples = origPointArray->GetNumberOfTuples();
+    pointIds->SetNumberOfIds(origPANbTuples);
+    for (vtkIdType i = 0; i < origPANbTuples; i++)
+    {
+      pointIds->SetId(i, origPointArray->GetTuple1(i));
+    }
 
     // Remove array that have disappeared from input
     for (int iArr = outPD->GetNumberOfArrays() - 1; iArr >= 0; iArr--)
@@ -104,15 +100,18 @@ int vtkStaticDataSetSurfaceFilter::UnstructuredGridExecute(vtkDataSet* input, vt
         outArr->SetNumberOfTuples(output->GetNumberOfPoints());
         inArr->GetTuples(pointIds.Get(), outArr);
         outPD->AddArray(outArr);
+        outArr->Delete();
       }
     }
 
     // Update output cell data
-    tmpIds = new vtkIdType[origCellArray->GetNumberOfTuples()];
-    memcpy(tmpIds, reinterpret_cast<vtkIdType*>(origCellArray->GetVoidPointer(0)),
-      sizeof(vtkIdType) * origCellArray->GetNumberOfTuples());
     vtkNew<vtkIdList> cellIds;
-    cellIds->SetArray(tmpIds, origCellArray->GetNumberOfTuples());
+    const vtkIdType origCANbTuples = origCellArray->GetNumberOfTuples();
+    cellIds->SetNumberOfIds(origCANbTuples);
+    for (vtkIdType i = 0; i < origCANbTuples; i++)
+    {
+      cellIds->SetId(i, origCellArray->GetTuple1(i));
+    }
 
     // Remove array that have disappeared from input
     for (int iArr = outCD->GetNumberOfArrays() - 1; iArr >= 0; iArr--)
@@ -141,8 +140,8 @@ int vtkStaticDataSetSurfaceFilter::UnstructuredGridExecute(vtkDataSet* input, vt
         outArr->SetNumberOfTuples(output->GetNumberOfCells());
         inArr->GetTuples(cellIds.Get(), outArr);
         outCD->AddArray(outArr);
+        outArr->Delete();
       }
-
     }
 
     // Update output field data
@@ -152,6 +151,11 @@ int vtkStaticDataSetSurfaceFilter::UnstructuredGridExecute(vtkDataSet* input, vt
   else
   {
     // Cache is not valid, Execute supercall algorithm
+    if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+    {
+      vtkWarningMacro("Building static mesh cache");
+    }
+
     int ret = this->Superclass::UnstructuredGridExecute(input, output);
 
     // Update the cache with superclass output
index ec885829fe240cb238ba207e35b6faa56d804869..27a16de007f708d9752efeaf5cd3527100640c1f 100644 (file)
@@ -25,7 +25,7 @@
  *
  * @sa
  * vtkStaticMeshObjectFactory
-*/
+ */
 
 #ifndef vtkStaticDataSetSurfaceFilter_h
 #define vtkStaticDataSetSurfaceFilter_h
 #include <vtkDataSetSurfaceFilter.h>
 #include <vtkNew.h>
 
+#include "StaticMeshModuleModule.h"
+
 class vtkPolyData;
 
-class vtkStaticDataSetSurfaceFilter : public vtkDataSetSurfaceFilter
+class STATICMESHMODULE_EXPORT vtkStaticDataSetSurfaceFilter : public vtkDataSetSurfaceFilter
 {
 public:
   static vtkStaticDataSetSurfaceFilter* New();
-  typedef vtkDataSetSurfaceFilter
-    Superclass; // vtkTypeMacro can't be used with a factory built object
+  // vtkTypeMacro can't be used with a factory built object
+  using Superclass = vtkDataSetSurfaceFilter;
   void PrintSelf(ostream& os, vtkIndent indent) override;
 
+  /**
+   * if the input is an unstructured grid and the cache is valid, this
+   * method only updates attributes (points, cells and field data)
+   */
   int UnstructuredGridExecute(vtkDataSet* input, vtkPolyData* output) override;
 
 protected:
-  vtkStaticDataSetSurfaceFilter();
-  ~vtkStaticDataSetSurfaceFilter() override;
-
-  vtkNew<vtkPolyData> Cache;
-  vtkMTimeType InputMeshTime;
-  vtkMTimeType FilterMTime;
+  vtkStaticDataSetSurfaceFilter() = default;
+  ~vtkStaticDataSetSurfaceFilter() override = default;
 
 private:
   // Hide these from the user and the compiler.
   vtkStaticDataSetSurfaceFilter(const vtkStaticDataSetSurfaceFilter&) = delete;
   void operator=(const vtkStaticDataSetSurfaceFilter&) = delete;
+
+  vtkNew<vtkPolyData> Cache;
+  vtkMTimeType InputMeshTime = 0;
+  vtkMTimeType FilterMTime = 0;
 };
 
 #endif
index aef35889d23cc24dc330cefc2d3bdeea50d70e3b..9fa199b6a46d7169eb0105dacc261bbf614ac8ad 100644 (file)
 #include <vtkMultiBlockDataSet.h>
 #include <vtkObjectFactory.h>
 #include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtksys/SystemTools.hxx>
 
 vtkStandardNewMacro(vtkStaticEnSight6BinaryReader);
 
 //----------------------------------------------------------------------------
-int vtkStaticEnSight6BinaryReader::RequestData(
-  vtkInformation *vtkNotUsed(request),
-  vtkInformationVector **vtkNotUsed(inputVector),
-  vtkInformationVector *outputVector)
+int vtkStaticEnSight6BinaryReader::RequestData(vtkInformation* vtkNotUsed(request),
+  vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector)
 {
-  vtkDebugMacro("In execute ");
+  vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::GetData(outputVector);
 
-  vtkInformation *outInfo = outputVector->GetInformationObject(0);
-  vtkMultiBlockDataSet *output = vtkMultiBlockDataSet::SafeDownCast(
-    outInfo->Get(vtkDataObject::DATA_OBJECT()));
-
-  int tsLength =
-    outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
-  double* steps =
-    outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+  vtkInformation* outInfo = outputVector->GetInformationObject(0);
+  int tsLength = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+  double* steps = outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
 
   this->ActualTimeValue = this->TimeValue;
 
   // Check if a particular time was requested by the pipeline.
   // This overrides the ivar.
-  if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength>0)
+  if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength > 0)
   {
     // Get the requested time step. We only support requests of a single time
     // step in this reader right now
-    double requestedTimeStep =
-      outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
+    double requestedTimeStep = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
 
     // find the first time value larger than requested time value
     // this logic could be improved
     int cnt = 0;
-    while (cnt < tsLength-1 && steps[cnt] < requestedTimeStep)
+    while (cnt < tsLength - 1 && steps[cnt] < requestedTimeStep)
     {
       cnt++;
     }
     this->ActualTimeValue = steps[cnt];
   }
 
-  vtkDebugMacro("Executing with: " << this->ActualTimeValue);
-
-  if (this->CacheMTime < this->GetMTime())
+  if (!this->UseStaticMesh || this->CacheMTime < this->GetMTime())
   {
-    int i, timeSet, fileSet, timeStep, timeStepInFile, fileNum;
-    vtkDataArray *times;
-    vtkIdList *numStepsList, *filenameNumbers;
-    float newTime;
-    int numSteps;
-    char* fileName;
-    int filenameNum;
+    if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+    {
+      vtkWarningMacro("Building static mesh cache");
+    }
 
-    if ( ! this->CaseFileRead)
+    if (!this->CaseFileRead)
     {
       vtkErrorMacro("error reading case file");
       return 0;
@@ -86,23 +74,23 @@ int vtkStaticEnSight6BinaryReader::RequestData(
     this->NumberOfGeometryParts = 0;
     if (this->GeometryFileName)
     {
-      timeStep = timeStepInFile = 1;
-      fileNum = 1;
-      fileName = new char[strlen(this->GeometryFileName) + 10];
-      strcpy(fileName, this->GeometryFileName);
+      vtkIdType timeStep = 1;
+      vtkIdType timeStepInFile = 1;
+      int fileNum = 1;
+      std::string fileName(this->GeometryFileName);
+      fileName.resize(fileName.size() + 10);
 
       if (this->UseTimeSets)
       {
-        timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
+        vtkIdType timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
         if (timeSet >= 0)
         {
-          times = this->TimeSets->GetItem(timeSet);
+          vtkDataArray* times = this->TimeSets->GetItem(timeSet);
           this->GeometryTimeValue = times->GetComponent(0, 0);
-          for (i = 1; i < times->GetNumberOfTuples(); i++)
+          for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
           {
-            newTime = times->GetComponent(i, 0);
-            if (newTime <= this->ActualTimeValue &&
-                newTime > this->GeometryTimeValue)
+            double newTime = times->GetComponent(i, 0);
+            if (newTime <= this->ActualTimeValue && newTime > this->GeometryTimeValue)
             {
               this->GeometryTimeValue = newTime;
               timeStep++;
@@ -111,16 +99,14 @@ int vtkStaticEnSight6BinaryReader::RequestData(
           }
           if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
           {
-            int collectionNum = this->TimeSetsWithFilenameNumbers->
-              IsId(this->GeometryTimeSet);
+            int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->GeometryTimeSet);
             if (collectionNum > -1)
             {
-              filenameNumbers =
-                this->TimeSetFileNameNumbers->GetItem(collectionNum);
-              filenameNum = filenameNumbers->GetId(timeStep-1);
-              if (! this->UseFileSets)
+              vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+              int filenameNum = filenameNumbers->GetId(timeStep - 1);
+              if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(fileName, filenameNum);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
@@ -128,16 +114,16 @@ int vtkStaticEnSight6BinaryReader::RequestData(
           // There can only be file sets if there are also time sets.
           if (this->UseFileSets)
           {
-            fileSet = this->FileSets->IsId(this->GeometryFileSet);
-            numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
-                                                   GetItemAsObject(fileSet));
+            vtkIdType fileSet = this->FileSets->IsId(this->GeometryFileSet);
+            vtkIdList* numStepsList =
+              static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
 
             if (timeStep > numStepsList->GetId(0))
             {
-              numSteps = numStepsList->GetId(0);
+              vtkIdType numSteps = numStepsList->GetId(0);
               timeStepInFile -= numSteps;
               fileNum = 2;
-              for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+              for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
               {
                 numSteps += numStepsList->GetId(i);
                 if (timeStep > numSteps)
@@ -149,48 +135,43 @@ int vtkStaticEnSight6BinaryReader::RequestData(
             }
             if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
             {
-              int collectionNum = this->FileSetsWithFilenameNumbers->
-                IsId(this->GeometryFileSet);
+              int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->GeometryFileSet);
               if (collectionNum > -1)
               {
-                filenameNumbers = this->FileSetFileNameNumbers->
-                  GetItem(collectionNum);
-                filenameNum = filenameNumbers->GetId(fileNum-1);
-                this->ReplaceWildcards(fileName, filenameNum);
+                vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum);
+                int filenameNum = filenameNumbers->GetId(fileNum - 1);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
         }
       }
 
-      if (!this->ReadGeometryFile(fileName, timeStepInFile, this->Cache))
+      if (!this->ReadGeometryFile(fileName.data(), timeStepInFile, this->Cache))
       {
         vtkErrorMacro("error reading geometry file");
-        delete [] fileName;
         return 0;
       }
-
-      delete [] fileName;
     }
     if (this->MeasuredFileName)
     {
-      timeStep = timeStepInFile = 1;
-      fileNum = 1;
-      fileName = new char[strlen(this->MeasuredFileName) + 10];
-      strcpy(fileName, this->MeasuredFileName);
+      vtkIdType timeStep = 1;
+      vtkIdType timeStepInFile = 1;
+      int fileNum = 1;
+      std::string fileName(this->MeasuredFileName);
+      fileName.resize(fileName.size() + 10);
 
       if (this->UseTimeSets)
       {
-        timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
+        vtkIdType timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
         if (timeSet >= 0)
         {
-          times = this->TimeSets->GetItem(timeSet);
+          vtkDataArray* times = this->TimeSets->GetItem(timeSet);
           this->MeasuredTimeValue = times->GetComponent(0, 0);
-          for (i = 1; i < times->GetNumberOfTuples(); i++)
+          for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
           {
-            newTime = times->GetComponent(i, 0);
-            if (newTime <= this->ActualTimeValue &&
-                newTime > this->MeasuredTimeValue)
+            double newTime = times->GetComponent(i, 0);
+            if (newTime <= this->ActualTimeValue && newTime > this->MeasuredTimeValue)
             {
               this->MeasuredTimeValue = newTime;
               timeStep++;
@@ -199,16 +180,14 @@ int vtkStaticEnSight6BinaryReader::RequestData(
           }
           if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
           {
-            int collectionNum = this->TimeSetsWithFilenameNumbers->
-              IsId(this->MeasuredTimeSet);
+            int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->MeasuredTimeSet);
             if (collectionNum > -1)
             {
-              filenameNumbers = this->TimeSetFileNameNumbers->
-                GetItem(collectionNum);
-              filenameNum = filenameNumbers->GetId(timeStep-1);
-              if (! this->UseFileSets)
+              vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+              int filenameNum = filenameNumbers->GetId(timeStep - 1);
+              if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(fileName, filenameNum);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
@@ -216,16 +195,16 @@ int vtkStaticEnSight6BinaryReader::RequestData(
           // There can only be file sets if there are also time sets.
           if (this->UseFileSets)
           {
-            fileSet = this->FileSets->IsId(this->MeasuredFileSet);
-            numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
-                                                   GetItemAsObject(fileSet));
+            vtkIdType fileSet = this->FileSets->IsId(this->MeasuredFileSet);
+            vtkIdList* numStepsList =
+              static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
 
             if (timeStep > numStepsList->GetId(0))
             {
-              numSteps = numStepsList->GetId(0);
+              vtkIdType numSteps = numStepsList->GetId(0);
               timeStepInFile -= numSteps;
               fileNum = 2;
-              for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+              for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
               {
                 numSteps += numStepsList->GetId(i);
                 if (timeStep > numSteps)
@@ -237,26 +216,22 @@ int vtkStaticEnSight6BinaryReader::RequestData(
             }
             if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
             {
-              int collectionNum = this->FileSetsWithFilenameNumbers->
-                IsId(this->MeasuredFileSet);
+              int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->MeasuredFileSet);
               if (collectionNum > -1)
               {
-                filenameNumbers = this->FileSetFileNameNumbers->
-                  GetItem(fileSet);
-                filenameNum = filenameNumbers->GetId(fileNum-1);
-                this->ReplaceWildcards(fileName, filenameNum);
+                vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet);
+                int filenameNum = filenameNumbers->GetId(fileNum - 1);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
         }
       }
-      if (!this->ReadMeasuredGeometryFile(fileName, timeStepInFile, this->Cache))
+      if (!this->ReadMeasuredGeometryFile(fileName.data(), timeStepInFile, this->Cache))
       {
         vtkErrorMacro("error reading measured geometry file");
-        delete [] fileName;
         return 0;
       }
-      delete [] fileName;
     }
     this->CacheMTime.Modified();
   }
index eadf17267c3499394560b82e7f5a63a889cfa926..d6573ca4fe314f154a54c88eeea895b0d2559a81 100644 (file)
@@ -31,9 +31,9 @@
  * of the pipeline because (due to the nature of the file format) it is
  * not possible to know ahead of time how many outputs you will have or
  * what types they will be.
- * This reader can only handle static EnSight datasets (both static geometry
- * and variables).
-*/
+ * If UseStaticMesh is true, this reader generates an unstructured grid
+ * with static geometry.
+ */
 
 #ifndef vtkStaticEnSight6BinaryReader_h
 #define vtkStaticEnSight6BinaryReader_h
 #include <vtkEnSight6BinaryReader.h>
 #include <vtkNew.h>
 
+#include "StaticMeshModuleModule.h"
+
 class vtkMultiBlockDataSet;
 
-class vtkStaticEnSight6BinaryReader : public vtkEnSight6BinaryReader
+class STATICMESHMODULE_EXPORT vtkStaticEnSight6BinaryReader : public vtkEnSight6BinaryReader
 {
 public:
-  static vtkStaticEnSight6BinaryReader *New();
+  static vtkStaticEnSight6BinaryReaderNew();
   vtkTypeMacro(vtkStaticEnSight6BinaryReader, vtkEnSight6BinaryReader);
 
+  // @{
+  /**
+   * This boolean control whether or not the output
+   * should be considered a static mesh.
+   */
+  vtkGetMacro(UseStaticMesh, bool);
+  vtkSetMacro(UseStaticMesh, bool);
+  vtkBooleanMacro(UseStaticMesh, bool);
+  // @}
+
 protected:
   vtkStaticEnSight6BinaryReader() = default;
   ~vtkStaticEnSight6BinaryReader() override = default;
 
-  int RequestData(vtkInformation*,
-                  vtkInformationVector**,
-                  vtkInformationVector*) override;
-
-  vtkNew<vtkMultiBlockDataSet> Cache;
-  vtkTimeStamp CacheMTime;
+  /**
+   * see vtkDataSetAlgorithm
+   */
+  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
 
 private:
   vtkStaticEnSight6BinaryReader(const vtkStaticEnSight6BinaryReader&) = delete;
   void operator=(const vtkStaticEnSight6BinaryReader&) = delete;
+
+  bool UseStaticMesh = false;
+  vtkNew<vtkMultiBlockDataSet> Cache;
+  vtkTimeStamp CacheMTime;
 };
 
 #endif
-
index 8ad68cd4f9b17181af3839de6328c74c33cb98d3..7845d3115c71982c4b89a552346a31e9a74209b3 100644 (file)
 #include <vtkMultiBlockDataSet.h>
 #include <vtkObjectFactory.h>
 #include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtksys/SystemTools.hxx>
 
 vtkStandardNewMacro(vtkStaticEnSight6Reader);
 
 //----------------------------------------------------------------------------
-int vtkStaticEnSight6Reader::RequestData(
-  vtkInformation *vtkNotUsed(request),
-  vtkInformationVector **vtkNotUsed(inputVector),
-  vtkInformationVector *outputVector)
+int vtkStaticEnSight6Reader::RequestData(vtkInformation* vtkNotUsed(request),
+  vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector)
 {
-  vtkDebugMacro("In execute ");
+  vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::GetData(outputVector);
 
-  vtkInformation *outInfo = outputVector->GetInformationObject(0);
-  vtkMultiBlockDataSet *output = vtkMultiBlockDataSet::SafeDownCast(
-    outInfo->Get(vtkDataObject::DATA_OBJECT()));
-
-  int tsLength =
-    outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
-  double* steps =
-    outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+  vtkInformation* outInfo = outputVector->GetInformationObject(0);
+  int tsLength = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+  double* steps = outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
 
   this->ActualTimeValue = this->TimeValue;
 
   // Check if a particular time was requested by the pipeline.
   // This overrides the ivar.
-  if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength>0)
+  if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength > 0)
   {
     // Get the requested time step. We only support requests of a single time
     // step in this reader right now
-    double requestedTimeStep =
-      outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
+    double requestedTimeStep = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
 
     // find the first time value larger than requested time value
     // this logic could be improved
     int cnt = 0;
-    while (cnt < tsLength-1 && steps[cnt] < requestedTimeStep)
+    while (cnt < tsLength - 1 && steps[cnt] < requestedTimeStep)
     {
       cnt++;
     }
     this->ActualTimeValue = steps[cnt];
   }
 
-  vtkDebugMacro("Executing with: " << this->ActualTimeValue);
-
-  if (this->CacheMTime < this->GetMTime())
+  if (!this->UseStaticMesh || this->CacheMTime < this->GetMTime())
   {
-    int i, timeSet, fileSet, timeStep, timeStepInFile, fileNum;
-    vtkDataArray *times;
-    vtkIdList *numStepsList, *filenameNumbers;
-    float newTime;
-    int numSteps;
-    char* fileName;
-    int filenameNum;
+    if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+    {
+      vtkWarningMacro("Building static mesh cache");
+    }
 
-    if ( ! this->CaseFileRead)
+    if (!this->CaseFileRead)
     {
       vtkErrorMacro("error reading case file");
       return 0;
@@ -86,23 +74,23 @@ int vtkStaticEnSight6Reader::RequestData(
     this->NumberOfGeometryParts = 0;
     if (this->GeometryFileName)
     {
-      timeStep = timeStepInFile = 1;
-      fileNum = 1;
-      fileName = new char[strlen(this->GeometryFileName) + 10];
-      strcpy(fileName, this->GeometryFileName);
+      vtkIdType timeStep = 1;
+      vtkIdType timeStepInFile = 1;
+      int fileNum = 1;
+      std::string fileName(this->GeometryFileName);
+      fileName.resize(fileName.size() + 10);
 
       if (this->UseTimeSets)
       {
-        timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
+        vtkIdType timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
         if (timeSet >= 0)
         {
-          times = this->TimeSets->GetItem(timeSet);
+          vtkDataArray* times = this->TimeSets->GetItem(timeSet);
           this->GeometryTimeValue = times->GetComponent(0, 0);
-          for (i = 1; i < times->GetNumberOfTuples(); i++)
+          for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
           {
-            newTime = times->GetComponent(i, 0);
-            if (newTime <= this->ActualTimeValue &&
-                newTime > this->GeometryTimeValue)
+            double newTime = times->GetComponent(i, 0);
+            if (newTime <= this->ActualTimeValue && newTime > this->GeometryTimeValue)
             {
               this->GeometryTimeValue = newTime;
               timeStep++;
@@ -111,16 +99,14 @@ int vtkStaticEnSight6Reader::RequestData(
           }
           if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
           {
-            int collectionNum = this->TimeSetsWithFilenameNumbers->
-              IsId(this->GeometryTimeSet);
+            int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->GeometryTimeSet);
             if (collectionNum > -1)
             {
-              filenameNumbers =
-                this->TimeSetFileNameNumbers->GetItem(collectionNum);
-              filenameNum = filenameNumbers->GetId(timeStep-1);
-              if (! this->UseFileSets)
+              vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+              int filenameNum = filenameNumbers->GetId(timeStep - 1);
+              if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(fileName, filenameNum);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
@@ -128,16 +114,16 @@ int vtkStaticEnSight6Reader::RequestData(
           // There can only be file sets if there are also time sets.
           if (this->UseFileSets)
           {
-            fileSet = this->FileSets->IsId(this->GeometryFileSet);
-            numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
-                                                   GetItemAsObject(fileSet));
+            vtkIdType fileSet = this->FileSets->IsId(this->GeometryFileSet);
+            vtkIdList* numStepsList =
+              static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
 
             if (timeStep > numStepsList->GetId(0))
             {
-              numSteps = numStepsList->GetId(0);
+              vtkIdType numSteps = numStepsList->GetId(0);
               timeStepInFile -= numSteps;
               fileNum = 2;
-              for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+              for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
               {
                 numSteps += numStepsList->GetId(i);
                 if (timeStep > numSteps)
@@ -149,48 +135,43 @@ int vtkStaticEnSight6Reader::RequestData(
             }
             if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
             {
-              int collectionNum = this->FileSetsWithFilenameNumbers->
-                IsId(this->GeometryFileSet);
+              int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->GeometryFileSet);
               if (collectionNum > -1)
               {
-                filenameNumbers = this->FileSetFileNameNumbers->
-                  GetItem(collectionNum);
-                filenameNum = filenameNumbers->GetId(fileNum-1);
-                this->ReplaceWildcards(fileName, filenameNum);
+                vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum);
+                int filenameNum = filenameNumbers->GetId(fileNum - 1);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
         }
       }
 
-      if (!this->ReadGeometryFile(fileName, timeStepInFile, this->Cache))
+      if (!this->ReadGeometryFile(fileName.data(), timeStepInFile, this->Cache))
       {
         vtkErrorMacro("error reading geometry file");
-        delete [] fileName;
         return 0;
       }
-
-      delete [] fileName;
     }
     if (this->MeasuredFileName)
     {
-      timeStep = timeStepInFile = 1;
-      fileNum = 1;
-      fileName = new char[strlen(this->MeasuredFileName) + 10];
-      strcpy(fileName, this->MeasuredFileName);
+      vtkIdType timeStep = 1;
+      vtkIdType timeStepInFile = 1;
+      int fileNum = 1;
+      std::string fileName(this->MeasuredFileName);
+      fileName.resize(fileName.size() + 10);
 
       if (this->UseTimeSets)
       {
-        timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
+        vtkIdType timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
         if (timeSet >= 0)
         {
-          times = this->TimeSets->GetItem(timeSet);
+          vtkDataArray* times = this->TimeSets->GetItem(timeSet);
           this->MeasuredTimeValue = times->GetComponent(0, 0);
-          for (i = 1; i < times->GetNumberOfTuples(); i++)
+          for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
           {
-            newTime = times->GetComponent(i, 0);
-            if (newTime <= this->ActualTimeValue &&
-                newTime > this->MeasuredTimeValue)
+            double newTime = times->GetComponent(i, 0);
+            if (newTime <= this->ActualTimeValue && newTime > this->MeasuredTimeValue)
             {
               this->MeasuredTimeValue = newTime;
               timeStep++;
@@ -199,16 +180,14 @@ int vtkStaticEnSight6Reader::RequestData(
           }
           if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
           {
-            int collectionNum = this->TimeSetsWithFilenameNumbers->
-              IsId(this->MeasuredTimeSet);
+            int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->MeasuredTimeSet);
             if (collectionNum > -1)
             {
-              filenameNumbers = this->TimeSetFileNameNumbers->
-                GetItem(collectionNum);
-              filenameNum = filenameNumbers->GetId(timeStep-1);
-              if (! this->UseFileSets)
+              vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+              int filenameNum = filenameNumbers->GetId(timeStep - 1);
+              if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(fileName, filenameNum);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
@@ -216,16 +195,16 @@ int vtkStaticEnSight6Reader::RequestData(
           // There can only be file sets if there are also time sets.
           if (this->UseFileSets)
           {
-            fileSet = this->FileSets->IsId(this->MeasuredFileSet);
-            numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
-                                                   GetItemAsObject(fileSet));
+            vtkIdType fileSet = this->FileSets->IsId(this->MeasuredFileSet);
+            vtkIdList* numStepsList =
+              static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
 
             if (timeStep > numStepsList->GetId(0))
             {
-              numSteps = numStepsList->GetId(0);
+              vtkIdType numSteps = numStepsList->GetId(0);
               timeStepInFile -= numSteps;
               fileNum = 2;
-              for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+              for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
               {
                 numSteps += numStepsList->GetId(i);
                 if (timeStep > numSteps)
@@ -237,26 +216,22 @@ int vtkStaticEnSight6Reader::RequestData(
             }
             if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
             {
-              int collectionNum = this->FileSetsWithFilenameNumbers->
-                IsId(this->MeasuredFileSet);
+              int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->MeasuredFileSet);
               if (collectionNum > -1)
               {
-                filenameNumbers = this->FileSetFileNameNumbers->
-                  GetItem(fileSet);
-                filenameNum = filenameNumbers->GetId(fileNum-1);
-                this->ReplaceWildcards(fileName, filenameNum);
+                vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet);
+                int filenameNum = filenameNumbers->GetId(fileNum - 1);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
         }
       }
-      if (!this->ReadMeasuredGeometryFile(fileName, timeStepInFile, this->Cache))
+      if (!this->ReadMeasuredGeometryFile(fileName.data(), timeStepInFile, this->Cache))
       {
         vtkErrorMacro("error reading measured geometry file");
-        delete [] fileName;
         return 0;
       }
-      delete [] fileName;
     }
     this->CacheMTime.Modified();
   }
index 30fe1484feedbddc1fb30baab8fa543c63a3a334..9b7282d9d6c0ecaa9fdcdd2de31d3755f2664f8c 100644 (file)
@@ -31,9 +31,9 @@
  * of the pipeline because (due to the nature of the file format) it is
  * not possible to know ahead of time how many outputs you will have or
  * what types they will be.
- * This reader can only handle static EnSight datasets (both static geometry
- * and variables).
-*/
+ * If UseStaticMesh is true, this reader generates an unstructured grid
+ * with static geometry.
+ */
 
 #ifndef vtkStaticEnSight6Reader_h
 #define vtkStaticEnSight6Reader_h
 #include <vtkEnSight6Reader.h>
 #include <vtkNew.h>
 
+#include "StaticMeshModuleModule.h"
+
 class vtkMultiBlockDataSet;
 
-class vtkStaticEnSight6Reader : public vtkEnSight6Reader
+class STATICMESHMODULE_EXPORT vtkStaticEnSight6Reader : public vtkEnSight6Reader
 {
 public:
-  static vtkStaticEnSight6Reader *New();
+  static vtkStaticEnSight6ReaderNew();
   vtkTypeMacro(vtkStaticEnSight6Reader, vtkEnSight6Reader);
 
+  // @{
+  /**
+   * This boolean control whether or not the output
+   * should be considered a static mesh.
+   */
+  vtkGetMacro(UseStaticMesh, bool);
+  vtkSetMacro(UseStaticMesh, bool);
+  vtkBooleanMacro(UseStaticMesh, bool);
+  // @}
+
 protected:
   vtkStaticEnSight6Reader() = default;
   ~vtkStaticEnSight6Reader() override = default;
 
-  int RequestData(vtkInformation*,
-                  vtkInformationVector**,
-                  vtkInformationVector*) override;
-
-  vtkNew<vtkMultiBlockDataSet> Cache;
-  vtkTimeStamp CacheMTime;
+  /**
+   * see vtkDataSetAlgorithm
+   */
+  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
 
 private:
   vtkStaticEnSight6Reader(const vtkStaticEnSight6Reader&) = delete;
   void operator=(const vtkStaticEnSight6Reader&) = delete;
+
+  bool UseStaticMesh = false;
+
+  vtkNew<vtkMultiBlockDataSet> Cache;
+  vtkTimeStamp CacheMTime;
 };
 
 #endif
-
index 6d336de800a4d458556bfcdcf74590b9718492e9..f6965b5f98b629ba731e7fb15f82c227a0f2d1e0 100644 (file)
 #include <vtkMultiBlockDataSet.h>
 #include <vtkObjectFactory.h>
 #include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtksys/SystemTools.hxx>
 
 vtkStandardNewMacro(vtkStaticEnSightGoldBinaryReader);
 
 //----------------------------------------------------------------------------
-int vtkStaticEnSightGoldBinaryReader::RequestData(
-  vtkInformation *vtkNotUsed(request),
-  vtkInformationVector **vtkNotUsed(inputVector),
-  vtkInformationVector *outputVector)
+int vtkStaticEnSightGoldBinaryReader::RequestData(vtkInformation* vtkNotUsed(request),
+  vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector)
 {
-  vtkDebugMacro("In execute ");
+  vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::GetData(outputVector);
 
-  vtkInformation *outInfo = outputVector->GetInformationObject(0);
-  vtkMultiBlockDataSet *output = vtkMultiBlockDataSet::SafeDownCast(
-    outInfo->Get(vtkDataObject::DATA_OBJECT()));
-
-  int tsLength =
-    outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
-  double* steps =
-    outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+  vtkInformation* outInfo = outputVector->GetInformationObject(0);
+  int tsLength = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+  double* steps = outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
 
   this->ActualTimeValue = this->TimeValue;
 
   // Check if a particular time was requested by the pipeline.
   // This overrides the ivar.
-  if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength>0)
+  if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength > 0)
   {
     // Get the requested time step. We only support requests of a single time
     // step in this reader right now
-    double requestedTimeStep =
-      outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
+    double requestedTimeStep = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
 
     // find the first time value larger than requested time value
     // this logic could be improved
     int cnt = 0;
-    while (cnt < tsLength-1 && steps[cnt] < requestedTimeStep)
+    while (cnt < tsLength - 1 && steps[cnt] < requestedTimeStep)
     {
       cnt++;
     }
     this->ActualTimeValue = steps[cnt];
   }
 
-  vtkDebugMacro("Executing with: " << this->ActualTimeValue);
-
-  if (this->CacheMTime < this->GetMTime())
+  if (!this->UseStaticMesh || this->CacheMTime < this->GetMTime())
   {
-    int i, timeSet, fileSet, timeStep, timeStepInFile, fileNum;
-    vtkDataArray *times;
-    vtkIdList *numStepsList, *filenameNumbers;
-    float newTime;
-    int numSteps;
-    char* fileName;
-    int filenameNum;
+    if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+    {
+      vtkWarningMacro("Building static mesh cache");
+    }
 
-    if ( ! this->CaseFileRead)
+    if (!this->CaseFileRead)
     {
       vtkErrorMacro("error reading case file");
       return 0;
@@ -86,23 +74,23 @@ int vtkStaticEnSightGoldBinaryReader::RequestData(
     this->NumberOfGeometryParts = 0;
     if (this->GeometryFileName)
     {
-      timeStep = timeStepInFile = 1;
-      fileNum = 1;
-      fileName = new char[strlen(this->GeometryFileName) + 10];
-      strcpy(fileName, this->GeometryFileName);
+      vtkIdType timeStep = 1;
+      vtkIdType timeStepInFile = 1;
+      int fileNum = 1;
+      std::string fileName(this->GeometryFileName);
+      fileName.resize(fileName.size() + 10);
 
       if (this->UseTimeSets)
       {
-        timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
+        vtkIdType timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
         if (timeSet >= 0)
         {
-          times = this->TimeSets->GetItem(timeSet);
+          vtkDataArray* times = this->TimeSets->GetItem(timeSet);
           this->GeometryTimeValue = times->GetComponent(0, 0);
-          for (i = 1; i < times->GetNumberOfTuples(); i++)
+          for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
           {
-            newTime = times->GetComponent(i, 0);
-            if (newTime <= this->ActualTimeValue &&
-                newTime > this->GeometryTimeValue)
+            double newTime = times->GetComponent(i, 0);
+            if (newTime <= this->ActualTimeValue && newTime > this->GeometryTimeValue)
             {
               this->GeometryTimeValue = newTime;
               timeStep++;
@@ -111,16 +99,14 @@ int vtkStaticEnSightGoldBinaryReader::RequestData(
           }
           if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
           {
-            int collectionNum = this->TimeSetsWithFilenameNumbers->
-              IsId(this->GeometryTimeSet);
+            int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->GeometryTimeSet);
             if (collectionNum > -1)
             {
-              filenameNumbers =
-                this->TimeSetFileNameNumbers->GetItem(collectionNum);
-              filenameNum = filenameNumbers->GetId(timeStep-1);
-              if (! this->UseFileSets)
+              vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+              int filenameNum = filenameNumbers->GetId(timeStep - 1);
+              if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(fileName, filenameNum);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
@@ -128,16 +114,16 @@ int vtkStaticEnSightGoldBinaryReader::RequestData(
           // There can only be file sets if there are also time sets.
           if (this->UseFileSets)
           {
-            fileSet = this->FileSets->IsId(this->GeometryFileSet);
-            numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
-                                                   GetItemAsObject(fileSet));
+            vtkIdType fileSet = this->FileSets->IsId(this->GeometryFileSet);
+            vtkIdList* numStepsList =
+              static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
 
             if (timeStep > numStepsList->GetId(0))
             {
-              numSteps = numStepsList->GetId(0);
+              vtkIdType numSteps = numStepsList->GetId(0);
               timeStepInFile -= numSteps;
               fileNum = 2;
-              for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+              for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
               {
                 numSteps += numStepsList->GetId(i);
                 if (timeStep > numSteps)
@@ -149,48 +135,43 @@ int vtkStaticEnSightGoldBinaryReader::RequestData(
             }
             if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
             {
-              int collectionNum = this->FileSetsWithFilenameNumbers->
-                IsId(this->GeometryFileSet);
+              int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->GeometryFileSet);
               if (collectionNum > -1)
               {
-                filenameNumbers = this->FileSetFileNameNumbers->
-                  GetItem(collectionNum);
-                filenameNum = filenameNumbers->GetId(fileNum-1);
-                this->ReplaceWildcards(fileName, filenameNum);
+                vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum);
+                int filenameNum = filenameNumbers->GetId(fileNum - 1);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
         }
       }
 
-      if (!this->ReadGeometryFile(fileName, timeStepInFile, this->Cache))
+      if (!this->ReadGeometryFile(fileName.data(), timeStepInFile, this->Cache))
       {
         vtkErrorMacro("error reading geometry file");
-        delete [] fileName;
         return 0;
       }
-
-      delete [] fileName;
     }
     if (this->MeasuredFileName)
     {
-      timeStep = timeStepInFile = 1;
-      fileNum = 1;
-      fileName = new char[strlen(this->MeasuredFileName) + 10];
-      strcpy(fileName, this->MeasuredFileName);
+      vtkIdType timeStep = 1;
+      vtkIdType timeStepInFile = 1;
+      int fileNum = 1;
+      std::string fileName(this->MeasuredFileName);
+      fileName.resize(fileName.size() + 10);
 
       if (this->UseTimeSets)
       {
-        timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
+        vtkIdType timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
         if (timeSet >= 0)
         {
-          times = this->TimeSets->GetItem(timeSet);
+          vtkDataArray* times = this->TimeSets->GetItem(timeSet);
           this->MeasuredTimeValue = times->GetComponent(0, 0);
-          for (i = 1; i < times->GetNumberOfTuples(); i++)
+          for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
           {
-            newTime = times->GetComponent(i, 0);
-            if (newTime <= this->ActualTimeValue &&
-                newTime > this->MeasuredTimeValue)
+            double newTime = times->GetComponent(i, 0);
+            if (newTime <= this->ActualTimeValue && newTime > this->MeasuredTimeValue)
             {
               this->MeasuredTimeValue = newTime;
               timeStep++;
@@ -199,16 +180,14 @@ int vtkStaticEnSightGoldBinaryReader::RequestData(
           }
           if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
           {
-            int collectionNum = this->TimeSetsWithFilenameNumbers->
-              IsId(this->MeasuredTimeSet);
+            int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->MeasuredTimeSet);
             if (collectionNum > -1)
             {
-              filenameNumbers = this->TimeSetFileNameNumbers->
-                GetItem(collectionNum);
-              filenameNum = filenameNumbers->GetId(timeStep-1);
-              if (! this->UseFileSets)
+              vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+              int filenameNum = filenameNumbers->GetId(timeStep - 1);
+              if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(fileName, filenameNum);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
@@ -216,16 +195,16 @@ int vtkStaticEnSightGoldBinaryReader::RequestData(
           // There can only be file sets if there are also time sets.
           if (this->UseFileSets)
           {
-            fileSet = this->FileSets->IsId(this->MeasuredFileSet);
-            numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
-                                                   GetItemAsObject(fileSet));
+            vtkIdType fileSet = this->FileSets->IsId(this->MeasuredFileSet);
+            vtkIdList* numStepsList =
+              static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
 
             if (timeStep > numStepsList->GetId(0))
             {
-              numSteps = numStepsList->GetId(0);
+              vtkIdType numSteps = numStepsList->GetId(0);
               timeStepInFile -= numSteps;
               fileNum = 2;
-              for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+              for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
               {
                 numSteps += numStepsList->GetId(i);
                 if (timeStep > numSteps)
@@ -237,26 +216,22 @@ int vtkStaticEnSightGoldBinaryReader::RequestData(
             }
             if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
             {
-              int collectionNum = this->FileSetsWithFilenameNumbers->
-                IsId(this->MeasuredFileSet);
+              int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->MeasuredFileSet);
               if (collectionNum > -1)
               {
-                filenameNumbers = this->FileSetFileNameNumbers->
-                  GetItem(fileSet);
-                filenameNum = filenameNumbers->GetId(fileNum-1);
-                this->ReplaceWildcards(fileName, filenameNum);
+                vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet);
+                int filenameNum = filenameNumbers->GetId(fileNum - 1);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
         }
       }
-      if (!this->ReadMeasuredGeometryFile(fileName, timeStepInFile, this->Cache))
+      if (!this->ReadMeasuredGeometryFile(fileName.data(), timeStepInFile, this->Cache))
       {
         vtkErrorMacro("error reading measured geometry file");
-        delete [] fileName;
         return 0;
       }
-      delete [] fileName;
     }
     this->CacheMTime.Modified();
   }
index e246509a29311c849b0c3c2d54c8fcc878bb811a..6ed79c197a6bcb205a4ac8f2797802a345cb2f89 100644 (file)
@@ -31,9 +31,9 @@
  * of the pipeline because (due to the nature of the file format) it is
  * not possible to know ahead of time how many outputs you will have or
  * what types they will be.
- * This reader can only handle static EnSight datasets (both static geometry
- * and variables).
-*/
+ * If UseStaticMesh is true, this reader generates an unstructured grid
+ * with static geometry.
+ */
 
 #ifndef vtkStaticEnSightGoldBinaryReader_h
 #define vtkStaticEnSightGoldBinaryReader_h
 #include <vtkEnSightGoldBinaryReader.h>
 #include <vtkNew.h>
 
+#include "StaticMeshModuleModule.h"
+
 class vtkMultiBlockDataSet;
 
-class vtkStaticEnSightGoldBinaryReader : public vtkEnSightGoldBinaryReader
+class STATICMESHMODULE_EXPORT vtkStaticEnSightGoldBinaryReader : public vtkEnSightGoldBinaryReader
 {
 public:
-  static vtkStaticEnSightGoldBinaryReader *New();
+  static vtkStaticEnSightGoldBinaryReaderNew();
   vtkTypeMacro(vtkStaticEnSightGoldBinaryReader, vtkEnSightGoldBinaryReader);
 
+  // @{
+  /**
+   * This boolean control whether or not the output
+   * should be considered a static mesh.
+   */
+  vtkGetMacro(UseStaticMesh, bool);
+  vtkSetMacro(UseStaticMesh, bool);
+  vtkBooleanMacro(UseStaticMesh, bool);
+  // @}
+
 protected:
   vtkStaticEnSightGoldBinaryReader() = default;
   ~vtkStaticEnSightGoldBinaryReader() override = default;
 
-  int RequestData(vtkInformation*,
-                  vtkInformationVector**,
-                  vtkInformationVector*) override;
-
-  vtkNew<vtkMultiBlockDataSet> Cache;
-  vtkTimeStamp CacheMTime;
+  /**
+   * see vtkDataSetAlgorithm
+   */
+  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
 
 private:
   vtkStaticEnSightGoldBinaryReader(const vtkStaticEnSightGoldBinaryReader&) = delete;
   void operator=(const vtkStaticEnSightGoldBinaryReader&) = delete;
+
+  bool UseStaticMesh = false;
+
+  vtkNew<vtkMultiBlockDataSet> Cache;
+  vtkTimeStamp CacheMTime;
 };
 
 #endif
-
index 11a6215470fa10dbca2e4774bfa175cf9d4a493f..f338f1225fc63e78994d81d650a80f46470018ba 100644 (file)
 #include <vtkMultiBlockDataSet.h>
 #include <vtkObjectFactory.h>
 #include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtksys/SystemTools.hxx>
 
 vtkStandardNewMacro(vtkStaticEnSightGoldReader);
 
 //----------------------------------------------------------------------------
-int vtkStaticEnSightGoldReader::RequestData(
-  vtkInformation *vtkNotUsed(request),
-  vtkInformationVector **vtkNotUsed(inputVector),
-  vtkInformationVector *outputVector)
+int vtkStaticEnSightGoldReader::RequestData(vtkInformation* vtkNotUsed(request),
+  vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector)
 {
-  vtkDebugMacro("In execute ");
+  vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::GetData(outputVector);
 
-  vtkInformation *outInfo = outputVector->GetInformationObject(0);
-  vtkMultiBlockDataSet *output = vtkMultiBlockDataSet::SafeDownCast(
-    outInfo->Get(vtkDataObject::DATA_OBJECT()));
-
-  int tsLength =
-    outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
-  double* steps =
-    outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+  vtkInformation* outInfo = outputVector->GetInformationObject(0);
+  int tsLength = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+  double* steps = outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
 
   this->ActualTimeValue = this->TimeValue;
 
   // Check if a particular time was requested by the pipeline.
   // This overrides the ivar.
-  if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength>0)
+  if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength > 0)
   {
     // Get the requested time step. We only support requests of a single time
     // step in this reader right now
-    double requestedTimeStep =
-      outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
+    double requestedTimeStep = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
 
     // find the first time value larger than requested time value
     // this logic could be improved
     int cnt = 0;
-    while (cnt < tsLength-1 && steps[cnt] < requestedTimeStep)
+    while (cnt < tsLength - 1 && steps[cnt] < requestedTimeStep)
     {
       cnt++;
     }
     this->ActualTimeValue = steps[cnt];
   }
 
-  vtkDebugMacro("Executing with: " << this->ActualTimeValue);
-
-  if (this->CacheMTime < this->GetMTime())
+  if (!this->UseStaticMesh || this->CacheMTime < this->GetMTime())
   {
-    int i, timeSet, fileSet, timeStep, timeStepInFile, fileNum;
-    vtkDataArray *times;
-    vtkIdList *numStepsList, *filenameNumbers;
-    float newTime;
-    int numSteps;
-    char* fileName;
-    int filenameNum;
+    if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+    {
+      vtkWarningMacro("Building static mesh cache");
+    }
 
-    if ( ! this->CaseFileRead)
+    if (!this->CaseFileRead)
     {
       vtkErrorMacro("error reading case file");
       return 0;
@@ -86,23 +74,23 @@ int vtkStaticEnSightGoldReader::RequestData(
     this->NumberOfGeometryParts = 0;
     if (this->GeometryFileName)
     {
-      timeStep = timeStepInFile = 1;
-      fileNum = 1;
-      fileName = new char[strlen(this->GeometryFileName) + 10];
-      strcpy(fileName, this->GeometryFileName);
+      vtkIdType timeStep = 1;
+      vtkIdType timeStepInFile = 1;
+      int fileNum = 1;
+      std::string fileName(this->GeometryFileName);
+      fileName.resize(fileName.size() + 10);
 
       if (this->UseTimeSets)
       {
-        timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
+        vtkIdType timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
         if (timeSet >= 0)
         {
-          times = this->TimeSets->GetItem(timeSet);
+          vtkDataArray* times = this->TimeSets->GetItem(timeSet);
           this->GeometryTimeValue = times->GetComponent(0, 0);
-          for (i = 1; i < times->GetNumberOfTuples(); i++)
+          for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
           {
-            newTime = times->GetComponent(i, 0);
-            if (newTime <= this->ActualTimeValue &&
-                newTime > this->GeometryTimeValue)
+            double newTime = times->GetComponent(i, 0);
+            if (newTime <= this->ActualTimeValue && newTime > this->GeometryTimeValue)
             {
               this->GeometryTimeValue = newTime;
               timeStep++;
@@ -111,16 +99,14 @@ int vtkStaticEnSightGoldReader::RequestData(
           }
           if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
           {
-            int collectionNum = this->TimeSetsWithFilenameNumbers->
-              IsId(this->GeometryTimeSet);
+            int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->GeometryTimeSet);
             if (collectionNum > -1)
             {
-              filenameNumbers =
-                this->TimeSetFileNameNumbers->GetItem(collectionNum);
-              filenameNum = filenameNumbers->GetId(timeStep-1);
-              if (! this->UseFileSets)
+              vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+              int filenameNum = filenameNumbers->GetId(timeStep - 1);
+              if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(fileName, filenameNum);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
@@ -128,16 +114,16 @@ int vtkStaticEnSightGoldReader::RequestData(
           // There can only be file sets if there are also time sets.
           if (this->UseFileSets)
           {
-            fileSet = this->FileSets->IsId(this->GeometryFileSet);
-            numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
-                                                   GetItemAsObject(fileSet));
+            vtkIdType fileSet = this->FileSets->IsId(this->GeometryFileSet);
+            vtkIdList* numStepsList =
+              static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
 
             if (timeStep > numStepsList->GetId(0))
             {
-              numSteps = numStepsList->GetId(0);
+              vtkIdType numSteps = numStepsList->GetId(0);
               timeStepInFile -= numSteps;
               fileNum = 2;
-              for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+              for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
               {
                 numSteps += numStepsList->GetId(i);
                 if (timeStep > numSteps)
@@ -149,48 +135,43 @@ int vtkStaticEnSightGoldReader::RequestData(
             }
             if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
             {
-              int collectionNum = this->FileSetsWithFilenameNumbers->
-                IsId(this->GeometryFileSet);
+              int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->GeometryFileSet);
               if (collectionNum > -1)
               {
-                filenameNumbers = this->FileSetFileNameNumbers->
-                  GetItem(collectionNum);
-                filenameNum = filenameNumbers->GetId(fileNum-1);
-                this->ReplaceWildcards(fileName, filenameNum);
+                vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum);
+                int filenameNum = filenameNumbers->GetId(fileNum - 1);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
         }
       }
 
-      if (!this->ReadGeometryFile(fileName, timeStepInFile, this->Cache))
+      if (!this->ReadGeometryFile(fileName.data(), timeStepInFile, this->Cache))
       {
         vtkErrorMacro("error reading geometry file");
-        delete [] fileName;
         return 0;
       }
-
-      delete [] fileName;
     }
     if (this->MeasuredFileName)
     {
-      timeStep = timeStepInFile = 1;
-      fileNum = 1;
-      fileName = new char[strlen(this->MeasuredFileName) + 10];
-      strcpy(fileName, this->MeasuredFileName);
+      vtkIdType timeStep = 1;
+      vtkIdType timeStepInFile = 1;
+      int fileNum = 1;
+      std::string fileName(this->MeasuredFileName);
+      fileName.resize(fileName.size() + 10);
 
       if (this->UseTimeSets)
       {
-        timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
+        vtkIdType timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
         if (timeSet >= 0)
         {
-          times = this->TimeSets->GetItem(timeSet);
+          vtkDataArray* times = this->TimeSets->GetItem(timeSet);
           this->MeasuredTimeValue = times->GetComponent(0, 0);
-          for (i = 1; i < times->GetNumberOfTuples(); i++)
+          for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
           {
-            newTime = times->GetComponent(i, 0);
-            if (newTime <= this->ActualTimeValue &&
-                newTime > this->MeasuredTimeValue)
+            double newTime = times->GetComponent(i, 0);
+            if (newTime <= this->ActualTimeValue && newTime > this->MeasuredTimeValue)
             {
               this->MeasuredTimeValue = newTime;
               timeStep++;
@@ -199,16 +180,14 @@ int vtkStaticEnSightGoldReader::RequestData(
           }
           if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
           {
-            int collectionNum = this->TimeSetsWithFilenameNumbers->
-              IsId(this->MeasuredTimeSet);
+            int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->MeasuredTimeSet);
             if (collectionNum > -1)
             {
-              filenameNumbers = this->TimeSetFileNameNumbers->
-                GetItem(collectionNum);
-              filenameNum = filenameNumbers->GetId(timeStep-1);
-              if (! this->UseFileSets)
+              vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+              int filenameNum = filenameNumbers->GetId(timeStep - 1);
+              if (!this->UseFileSets)
               {
-                this->ReplaceWildcards(fileName, filenameNum);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
@@ -216,16 +195,16 @@ int vtkStaticEnSightGoldReader::RequestData(
           // There can only be file sets if there are also time sets.
           if (this->UseFileSets)
           {
-            fileSet = this->FileSets->IsId(this->MeasuredFileSet);
-            numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
-                                                   GetItemAsObject(fileSet));
+            vtkIdType fileSet = this->FileSets->IsId(this->MeasuredFileSet);
+            vtkIdList* numStepsList =
+              static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
 
             if (timeStep > numStepsList->GetId(0))
             {
-              numSteps = numStepsList->GetId(0);
+              vtkIdType numSteps = numStepsList->GetId(0);
               timeStepInFile -= numSteps;
               fileNum = 2;
-              for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+              for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
               {
                 numSteps += numStepsList->GetId(i);
                 if (timeStep > numSteps)
@@ -237,26 +216,22 @@ int vtkStaticEnSightGoldReader::RequestData(
             }
             if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
             {
-              int collectionNum = this->FileSetsWithFilenameNumbers->
-                IsId(this->MeasuredFileSet);
+              int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->MeasuredFileSet);
               if (collectionNum > -1)
               {
-                filenameNumbers = this->FileSetFileNameNumbers->
-                  GetItem(fileSet);
-                filenameNum = filenameNumbers->GetId(fileNum-1);
-                this->ReplaceWildcards(fileName, filenameNum);
+                vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet);
+                int filenameNum = filenameNumbers->GetId(fileNum - 1);
+                this->ReplaceWildcards(&fileName[0], filenameNum);
               }
             }
           }
         }
       }
-      if (!this->ReadMeasuredGeometryFile(fileName, timeStepInFile, this->Cache))
+      if (!this->ReadMeasuredGeometryFile(fileName.data(), timeStepInFile, this->Cache))
       {
         vtkErrorMacro("error reading measured geometry file");
-        delete [] fileName;
         return 0;
       }
-      delete [] fileName;
     }
     this->CacheMTime.Modified();
   }
index 2be1a02835d3777c954da04fb17d98ef654794a3..ab2efc843f3c352c5b66c560402817f51eb086ea 100644 (file)
@@ -31,9 +31,9 @@
  * of the pipeline because (due to the nature of the file format) it is
  * not possible to know ahead of time how many outputs you will have or
  * what types they will be.
- * This reader can only handle static EnSight datasets (both static geometry
- * and variables).
-*/
+ * If UseStaticMesh is true, this reader generates an unstructured grid
+ * with static geometry.
+ */
 
 #ifndef vtkStaticEnSightGoldReader_h
 #define vtkStaticEnSightGoldReader_h
 #include <vtkEnSightGoldReader.h>
 #include <vtkNew.h>
 
+#include "StaticMeshModuleModule.h"
+
 class vtkMultiBlockDataSet;
 
-class vtkStaticEnSightGoldReader : public vtkEnSightGoldReader
+class STATICMESHMODULE_EXPORT vtkStaticEnSightGoldReader : public vtkEnSightGoldReader
 {
 public:
-  static vtkStaticEnSightGoldReader *New();
+  static vtkStaticEnSightGoldReaderNew();
   vtkTypeMacro(vtkStaticEnSightGoldReader, vtkEnSightGoldReader);
 
+  // @{
+  /**
+   * This boolean control whether or not the output
+   * should be considered a static mesh.
+   */
+  vtkGetMacro(UseStaticMesh, bool);
+  vtkSetMacro(UseStaticMesh, bool);
+  vtkBooleanMacro(UseStaticMesh, bool);
+  // @}
+
 protected:
   vtkStaticEnSightGoldReader() = default;
   ~vtkStaticEnSightGoldReader() override = default;
 
-  int RequestData(vtkInformation*,
-                  vtkInformationVector**,
-                  vtkInformationVector*) override;
-
-  vtkNew<vtkMultiBlockDataSet> Cache;
-  vtkTimeStamp CacheMTime;
+  /**
+   * see vtkDataSetAlgorithm
+   */
+  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
 
 private:
   vtkStaticEnSightGoldReader(const vtkStaticEnSightGoldReader&) = delete;
   void operator=(const vtkStaticEnSightGoldReader&) = delete;
+
+  bool UseStaticMesh = false;
+
+  vtkNew<vtkMultiBlockDataSet> Cache;
+  vtkTimeStamp CacheMTime;
 };
 
 #endif
-
index 4c6f1e6e4c32599bc7cf6252928b6860baa10323..bb8f91ae3f80cd771e153416e8b73f778ae6aa38 100644 (file)
@@ -1,7 +1,7 @@
 /*=========================================================================
 
   Program:   Visualization Toolkit
-  Module:    vtkStaticDataSetSurfaceFilter.cxx
+  Module:    vtkStaticMeshObjectFactory.cxx
 
   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
   All rights reserved.
@@ -43,22 +43,21 @@ VTK_CREATE_CREATE_FUNCTION(vtkStaticEnSightGoldBinaryReader);
 VTK_CREATE_CREATE_FUNCTION(vtkStaticPUnstructuredGridGhostCellsGenerator);
 #endif
 
+//-----------------------------------------------------------------------------
 vtkStaticMeshObjectFactory::vtkStaticMeshObjectFactory()
 {
-  vtkDebugMacro("Create vtkStaticMeshObjectFactory");
-
   this->RegisterOverride("vtkDataSetSurfaceFilter", "vtkStaticDataSetSurfaceFilter",
     "StaticDataSetSurfaceFilter", 1, vtkObjectFactoryCreatevtkStaticDataSetSurfaceFilter);
   this->RegisterOverride("vtkPlaneCutter", "vtkStaticPlaneCutter", "StaticPlaneCutter", 1,
     vtkObjectFactoryCreatevtkStaticPlaneCutter);
-  this->RegisterOverride("vtkEnSight6BinaryReader", "vtkStaticEnSight6BinaryReader", "StaticEnSight6BinaryReader", 1,
-    vtkObjectFactoryCreatevtkStaticEnSight6BinaryReader);
+  this->RegisterOverride("vtkEnSight6BinaryReader", "vtkStaticEnSight6BinaryReader",
+    "StaticEnSight6BinaryReader", 1, vtkObjectFactoryCreatevtkStaticEnSight6BinaryReader);
   this->RegisterOverride("vtkEnSight6Reader", "vtkStaticEnSight6Reader", "StaticEnSight6Reader", 1,
     vtkObjectFactoryCreatevtkStaticEnSight6Reader);
-  this->RegisterOverride("vtkEnSightGoldReader", "vtkStaticEnSight6BinaryReader", "StaticEnSight6BinaryReader", 1,
-    vtkObjectFactoryCreatevtkStaticEnSightGoldReader);
-  this->RegisterOverride("vtkEnSightGoldBinaryReader", "vtkStaticEnSightGoldBinaryReader", "StaticEnSightGoldBinaryReader", 1,
-    vtkObjectFactoryCreatevtkStaticEnSightGoldBinaryReader);
+  this->RegisterOverride("vtkEnSightGoldReader", "vtkStaticEnSight6BinaryReader",
+    "StaticEnSight6BinaryReader", 1, vtkObjectFactoryCreatevtkStaticEnSightGoldReader);
+  this->RegisterOverride("vtkEnSightGoldBinaryReader", "vtkStaticEnSightGoldBinaryReader",
+    "StaticEnSightGoldBinaryReader", 1, vtkObjectFactoryCreatevtkStaticEnSightGoldBinaryReader);
 
 #ifdef PARAVIEW_USE_MPI
   this->RegisterOverride("vtkPUnstructuredGridGhostCellsGenerator",
@@ -67,26 +66,25 @@ vtkStaticMeshObjectFactory::vtkStaticMeshObjectFactory()
 #endif
 }
 
-vtkStaticMeshObjectFactory::~vtkStaticMeshObjectFactory()
-{
-  vtkDebugMacro("Delete vtkStaticMeshObjectFactory");
-}
-
+//-----------------------------------------------------------------------------
 void vtkStaticMeshObjectFactory::PrintSelf(ostream& os, vtkIndent indent)
 {
-  os << indent << "VTK Static Mesh Extension Factory" << endl;
+  os << indent << this->GetDescription() << endl;
 }
 
+//-----------------------------------------------------------------------------
 const char* vtkStaticMeshObjectFactory::GetVTKSourceVersion()
 {
   return VTK_SOURCE_VERSION;
 }
 
+//-----------------------------------------------------------------------------
 const char* vtkStaticMeshObjectFactory::GetDescription()
 {
   return "VTK Static Mesh Extension Factory";
 }
 
+//-----------------------------------------------------------------------------
 class StaticFactoryInitialize
 {
 public:
@@ -95,21 +93,19 @@ public:
     bool hasStaticPluginFactory = false;
     vtkObjectFactoryCollection* collection = vtkObjectFactory::GetRegisteredFactories();
     collection->InitTraversal();
-    vtkObjectFactory* f = collection->GetNextItem();
-    while (f)
+    vtkObjectFactory* f;
+    while ((f = collection->GetNextItem()))
     {
       if (f->IsA("vtkStaticMeshObjectFactory"))
       {
         hasStaticPluginFactory = true;
         break;
       }
-      f = collection->GetNextItem();
     }
     if (!hasStaticPluginFactory)
     {
-      vtkStaticMeshObjectFactory* instance = vtkStaticMeshObjectFactory::New();
+      vtkNew<vtkStaticMeshObjectFactory> instance;
       vtkObjectFactory::RegisterFactory(instance);
-      instance->Delete();
     }
   }
 
index 316b9fab9a5123d5a8efb604be5b589ad41d0faa..5e06ea6094e18d2a8e67681263b7938d58f91694 100644 (file)
@@ -1,7 +1,7 @@
 /*=========================================================================
 
   Program:   Visualization Toolkit
-  Module:    vtkStaticDataSetSurfaceFilter.h
+  Module:    vtkStaticMeshObjectFactor.h
 
   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
   All rights reserved.
 =========================================================================*/
 /**
  * @class   vtkStaticMeshObjectFactory
- * @brief   Generate static version of dataset and filter for statix mesh plugin
+ * @brief   Generate static version of dataset and filter for static mesh plugin
  *
  * vtkStaticMeshObjectFactory is a vtk object factory, instantiating static version
- * of some dataset and filters.
-*/
+ * of some readers and filters.
+ */
 
 #ifndef vtkStaticMeshObjectFactory_h
 #define vtkStaticMeshObjectFactory_h
 
 #include <vtkObjectFactory.h> // Must be included before singletons
 
-class vtkStaticMeshObjectFactory : public vtkObjectFactory
+#include "StaticMeshModuleModule.h"
+
+class STATICMESHMODULE_EXPORT vtkStaticMeshObjectFactory : public vtkObjectFactory
 {
 public:
   vtkTypeMacro(vtkStaticMeshObjectFactory, vtkObjectFactory);
@@ -48,7 +50,7 @@ public:
 
 protected:
   vtkStaticMeshObjectFactory();
-  ~vtkStaticMeshObjectFactory() override;
+  ~vtkStaticMeshObjectFactory() override = default;
 
 private:
   vtkStaticMeshObjectFactory(const vtkStaticMeshObjectFactory&) = delete;
index b4ab07c9ae7a446c07d8c9998c2d54b52126822a..d1cb9b410e8210f9f3218e8c50eebf99624fba20 100644 (file)
@@ -28,6 +28,7 @@
 #include <vtkTable.h>
 #include <vtkUnsignedCharArray.h>
 #include <vtkUnstructuredGrid.h>
+#include <vtksys/SystemTools.hxx>
 
 static const int SUGGCG_SIZE_EXCHANGE_TAG = 9002;
 static const int SUGGCG_DATA_EXCHANGE_TAG = 9003;
@@ -37,9 +38,6 @@ vtkStandardNewMacro(vtkStaticPUnstructuredGridGhostCellsGenerator);
 //----------------------------------------------------------------------------
 vtkStaticPUnstructuredGridGhostCellsGenerator::vtkStaticPUnstructuredGridGhostCellsGenerator()
 {
-  this->InputMeshTime = 0;
-  this->FilterMTime = 0;
-
   vtkMPIController* controller =
     vtkMPIController::SafeDownCast(vtkMultiProcessController::GetGlobalController());
   if (controller)
@@ -49,35 +47,16 @@ vtkStaticPUnstructuredGridGhostCellsGenerator::vtkStaticPUnstructuredGridGhostCe
     this->GhostPointsToSend.resize(controller->GetNumberOfProcesses());
     this->GhostCellsToReceive.resize(controller->GetNumberOfProcesses());
     this->GhostCellsToSend.resize(controller->GetNumberOfProcesses());
-
-    int nProc = controller->GetNumberOfProcesses();
-
-    for (int i = 0; i < nProc; i++)
-    {
-      this->GhostCellsToReceive[i] = vtkSmartPointer<vtkIdList>::New();
-      this->GhostCellsToSend[i] = vtkSmartPointer<vtkIdList>::New();
-      this->GhostPointsToReceive[i] = vtkSmartPointer<vtkIdList>::New();
-      this->GhostPointsToSend[i] = vtkSmartPointer<vtkIdList>::New();
-    }
   }
 }
 
-//----------------------------------------------------------------------------
-vtkStaticPUnstructuredGridGhostCellsGenerator::~vtkStaticPUnstructuredGridGhostCellsGenerator()
-{
-}
-
 //-----------------------------------------------------------------------------
 int vtkStaticPUnstructuredGridGhostCellsGenerator::RequestData(
   vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
 {
   // get the inputs and outputs
-  vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
-  vtkInformation* outInfo = outputVector->GetInformationObject(0);
-  vtkUnstructuredGridBase* input =
-    vtkUnstructuredGridBase::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
-  vtkUnstructuredGrid* output =
-    vtkUnstructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
+  vtkUnstructuredGridBase* input = vtkUnstructuredGridBase::GetData(inputVector[0]);
+  vtkUnstructuredGrid* output = vtkUnstructuredGrid::GetData(outputVector);
 
   // Recover the static unstructured grid
   vtkUnstructuredGrid* inputUG = vtkUnstructuredGrid::SafeDownCast(input);
@@ -91,6 +70,11 @@ int vtkStaticPUnstructuredGridGhostCellsGenerator::RequestData(
   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"))
+    {
+      vtkWarningMacro("Using static mesh cache");
+    }
+
     // Update the cache data
     this->UpdateCacheData(input);
 
@@ -100,6 +84,12 @@ int vtkStaticPUnstructuredGridGhostCellsGenerator::RequestData(
   }
   else
   {
+    // Cache is outdated, build it.
+    if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+    {
+      vtkWarningMacro("Building static mesh cache");
+    }
+
     // Add Arrays Ids needed
     vtkNew<vtkUnstructuredGrid> tmpInput;
     this->AddIdsArrays(input, tmpInput.Get());
@@ -159,92 +149,92 @@ void vtkStaticPUnstructuredGridGhostCellsGenerator::ProcessGhostIds()
       vtkWarningMacro("Arrays are missing from cache, cache is discarded");
       this->InputMeshTime = 0;
       this->FilterMTime = 0;
+      return;
     }
-    else
+
+    // Compute list of remote ghost point ids
+    // and corresponding local point ids.
+    std::vector<std::vector<vtkIdType> > remoteGhostPoints;
+    remoteGhostPoints.resize(nProc);
+    for (vtkIdType i = 0; i < pointGhostArray->GetNumberOfTuples(); i++)
     {
-      // Compute list of remote ghost point ids
-      // and corresponding local point ids.
-      std::vector<std::vector<vtkIdType> > remoteGhostPoints;
-      remoteGhostPoints.resize(nProc);
-      for (vtkIdType i = 0; i < pointGhostArray->GetNumberOfTuples(); i++)
+      if (pointGhostArray->GetValue(i) != 0)
       {
-        if (pointGhostArray->GetValue(i) != 0)
-        {
-          this->GhostPointsToReceive[pointProcIds->GetValue(i)]->InsertNextId(i);
-          remoteGhostPoints[pointProcIds->GetValue(i)].push_back(pointIds->GetValue(i));
-        }
+        this->GhostPointsToReceive[pointProcIds->GetValue(i)]->InsertNextId(i);
+        remoteGhostPoints[pointProcIds->GetValue(i)].emplace_back(pointIds->GetValue(i));
       }
+    }
 
-      // Compute list of remote ghost cell ids
-      // and corresponding local cell ids.
-      std::vector<std::vector<vtkIdType> > remoteGhostCells;
-      remoteGhostCells.resize(nProc);
-      for (vtkIdType i = 0; i < cellGhostArray->GetNumberOfTuples(); i++)
+    // Compute list of remote ghost cell ids
+    // and corresponding local cell ids.
+    std::vector<std::vector<vtkIdType> > remoteGhostCells;
+    remoteGhostCells.resize(nProc);
+    for (vtkIdType i = 0; i < cellGhostArray->GetNumberOfTuples(); i++)
+    {
+      if (cellGhostArray->GetValue(i) != 0)
       {
-        if (cellGhostArray->GetValue(i) != 0)
-        {
-          this->GhostCellsToReceive[cellProcIds->GetValue(i)]->InsertNextId(i);
-          remoteGhostCells[cellProcIds->GetValue(i)].push_back(cellIds->GetValue(i));
-        }
+        this->GhostCellsToReceive[cellProcIds->GetValue(i)]->InsertNextId(i);
+        remoteGhostCells[cellProcIds->GetValue(i)].emplace_back(cellIds->GetValue(i));
       }
+    }
 
-      // Send requested ghost point ids to their own rank
-      vtkMPICommunicator::Request pointSizeReqs[nProc];
-      vtkMPICommunicator::Request pointIdsReqs[nProc];
-      vtkIdType lengths[nProc];
-      for (int i = 0; i < nProc; i++)
+    // Send requested ghost point ids to their own rank
+    vtkMPICommunicator::Request pointSizeReqs[nProc];
+    vtkMPICommunicator::Request pointIdsReqs[nProc];
+    vtkIdType lengths[nProc];
+    for (int i = 0; i < nProc; i++)
+    {
+      if (i != rank)
       {
-        if (i != rank)
-        {
-          lengths[i] = remoteGhostPoints[i].size();
-          controller->NoBlockSend(&lengths[i], 1, i, SUGGCG_SIZE_EXCHANGE_TAG, pointSizeReqs[i]);
-          controller->NoBlockSend(&remoteGhostPoints[i][0], remoteGhostPoints[i].size(), i,
-            SUGGCG_DATA_EXCHANGE_TAG, pointIdsReqs[i]);
-        }
+        lengths[i] = remoteGhostPoints[i].size();
+        controller->NoBlockSend(&lengths[i], 1, i, SUGGCG_SIZE_EXCHANGE_TAG, pointSizeReqs[i]);
+        controller->NoBlockSend(&remoteGhostPoints[i][0], remoteGhostPoints[i].size(), i,
+          SUGGCG_DATA_EXCHANGE_TAG, pointIdsReqs[i]);
       }
+    }
 
-      // Receive and store requested ghost point ids.
-      for (int i = 0; i < nProc; i++)
+    // Receive and store requested ghost point ids.
+    for (int i = 0; i < nProc; i++)
+    {
+      if (i != rank)
       {
-        if (i != rank)
-        {
-          vtkIdType length;
-          controller->Receive(&length, 1, i, SUGGCG_SIZE_EXCHANGE_TAG);
-          this->GhostPointsToSend[i]->SetNumberOfIds(length);
-          controller->Receive(
-            this->GhostPointsToSend[i]->GetPointer(0), length, i, SUGGCG_DATA_EXCHANGE_TAG);
-        }
+        vtkIdType length;
+        controller->Receive(&length, 1, i, SUGGCG_SIZE_EXCHANGE_TAG);
+        this->GhostPointsToSend[i]->SetNumberOfIds(length);
+        controller->Receive(
+          this->GhostPointsToSend[i]->GetPointer(0), length, i, SUGGCG_DATA_EXCHANGE_TAG);
       }
-      controller->Barrier();
+    }
+    controller->Barrier();
 
-      // Send requested ghost cell ids to their own rank
-      vtkMPICommunicator::Request cellSizeReqs[nProc];
-      vtkMPICommunicator::Request cellIdsReqs[nProc];
-      for (int i = 0; i < nProc; i++)
+    // Send requested ghost cell ids to their own rank
+    vtkMPICommunicator::Request cellSizeReqs[nProc];
+    vtkMPICommunicator::Request cellIdsReqs[nProc];
+    for (int i = 0; i < nProc; i++)
+    {
+      if (i != rank)
       {
-        if (i != rank)
-        {
-          lengths[i] = remoteGhostCells[i].size();
-          controller->NoBlockSend(&lengths[i], 1, i, SUGGCG_SIZE_EXCHANGE_TAG, cellSizeReqs[i]);
-          controller->NoBlockSend(
-            &remoteGhostCells[i][0], lengths[i], i, SUGGCG_DATA_EXCHANGE_TAG, cellIdsReqs[i]);
-        }
+        lengths[i] = remoteGhostCells[i].size();
+        controller->NoBlockSend(&lengths[i], 1, i, SUGGCG_SIZE_EXCHANGE_TAG, cellSizeReqs[i]);
+        controller->NoBlockSend(
+          &remoteGhostCells[i][0], lengths[i], i, SUGGCG_DATA_EXCHANGE_TAG, cellIdsReqs[i]);
       }
-      // Receive and store requested ghost cell ids.
-      for (int i = 0; i < nProc; i++)
+    }
+    // Receive and store requested ghost cell ids.
+    for (int i = 0; i < nProc; i++)
+    {
+      if (i != rank)
       {
-        if (i != rank)
-        {
-          vtkIdType length;
-          controller->Receive(&length, 1, i, SUGGCG_SIZE_EXCHANGE_TAG);
-          this->GhostCellsToSend[i]->SetNumberOfIds(length);
-          controller->Receive(
-            this->GhostCellsToSend[i]->GetPointer(0), length, i, SUGGCG_DATA_EXCHANGE_TAG);
-        }
+        vtkIdType length;
+        controller->Receive(&length, 1, i, SUGGCG_SIZE_EXCHANGE_TAG);
+        this->GhostCellsToSend[i]->SetNumberOfIds(length);
+        controller->Receive(
+          this->GhostCellsToSend[i]->GetPointer(0), length, i, SUGGCG_DATA_EXCHANGE_TAG);
       }
-      controller->Barrier();
     }
-  }
+    controller->Barrier();
+
+  } // end if (controller)
 }
 
 //-----------------------------------------------------------------------------
@@ -264,7 +254,10 @@ void vtkStaticPUnstructuredGridGhostCellsGenerator::AddIdsArrays(
   {
     // Create Ids array
     generateIdScalars->SetInputData(tmpInput);
-    generateIdScalars->SetIdsArrayName("Ids");
+    generateIdScalars->SetPointIds(true);
+    generateIdScalars->SetCellIds(true);
+    generateIdScalars->SetPointIdsArrayName("Ids");
+    generateIdScalars->SetCellIdsArrayName("Ids");
     generateIdScalars->Update();
     tmpInput = generateIdScalars->GetOutput();
   }
@@ -391,7 +384,7 @@ void vtkStaticPUnstructuredGridGhostCellsGenerator::UpdateCacheGhostCellAndPoint
           SUGGCG_DATA_EXCHANGE_TAG, dataReqs[i]);
       }
     }
-    // Foe each rank
+    // For each rank
     for (int i = 0; i < nProc; i++)
     {
       if (i != rank && this->GhostPointsToReceive[i]->GetNumberOfIds() > 0)
index ecfadfec3e2010e1819bbf0017dc91126b9805af..1152d6a3ef80597487142484b3970d1aeca7629d 100644 (file)
  *
  * @sa
  * vtkPUnstructuredGridGhostCellsGenerator
-*/
+ */
 
 #ifndef vtkStaticPUnstructuredGridGhostCellsGenerator_h
 #define vtkStaticPUnstructuredGridGhostCellsGenerator_h
 
-#include <vtkIdList.h>
 #include <vtkNew.h>
 #include <vtkPUnstructuredGridGhostCellsGenerator.h>
-#include <vtkSmartPointer.h>
 
 #include <vector>
 
+#include "StaticMeshModuleModule.h"
+
+class vtkIdList;
 class vtkUnstructuredGrid;
 
-class vtkStaticPUnstructuredGridGhostCellsGenerator : public vtkPUnstructuredGridGhostCellsGenerator
+class STATICMESHMODULE_EXPORT vtkStaticPUnstructuredGridGhostCellsGenerator
+  : public vtkPUnstructuredGridGhostCellsGenerator
 {
 public:
   static vtkStaticPUnstructuredGridGhostCellsGenerator* New();
@@ -52,7 +54,7 @@ public:
 
 protected:
   vtkStaticPUnstructuredGridGhostCellsGenerator();
-  ~vtkStaticPUnstructuredGridGhostCellsGenerator() override;
+  ~vtkStaticPUnstructuredGridGhostCellsGenerator() override = default;
 
   /**
    * Check input for "ProcessId" and "Ids" point and cell array,
@@ -83,20 +85,19 @@ protected:
    */
   virtual void UpdateCacheGhostCellAndPointData(vtkDataSet* input);
 
-  vtkNew<vtkUnstructuredGrid> Cache;
-  vtkMTimeType InputMeshTime;
-  vtkMTimeType FilterMTime;
-
-  std::vector<vtkSmartPointer<vtkIdList> > GhostCellsToReceive;
-  std::vector<vtkSmartPointer<vtkIdList> > GhostCellsToSend;
-  std::vector<vtkSmartPointer<vtkIdList> > GhostPointsToReceive;
-  std::vector<vtkSmartPointer<vtkIdList> > GhostPointsToSend;
-
 private:
-  // Hide these from the user and the compiler.
   vtkStaticPUnstructuredGridGhostCellsGenerator(
     const vtkStaticPUnstructuredGridGhostCellsGenerator&) = delete;
   void operator=(const vtkStaticPUnstructuredGridGhostCellsGenerator&) = delete;
+
+  vtkNew<vtkUnstructuredGrid> Cache;
+  vtkMTimeType InputMeshTime = 0;
+  vtkMTimeType FilterMTime = 0;
+
+  std::vector<vtkNew<vtkIdList> > GhostCellsToReceive;
+  std::vector<vtkNew<vtkIdList> > GhostCellsToSend;
+  std::vector<vtkNew<vtkIdList> > GhostPointsToReceive;
+  std::vector<vtkNew<vtkIdList> > GhostPointsToSend;
 };
 
 #endif
index 393bddcf971d9c185b1849443816e887c20432fb..73d73ebefb524297c8e0faa601548cff6f58d90e 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <vtkCellData.h>
 #include <vtkCompositeDataIterator.h>
+#include <vtkGenericCell.h>
 #include <vtkIdFilter.h>
 #include <vtkIdList.h>
 #include <vtkInformation.h>
 #include <vtkPointData.h>
 #include <vtkPolyData.h>
 #include <vtkUnstructuredGrid.h>
-#include <vtkGenericCell.h>
+#include <vtksys/SystemTools.hxx>
 
 vtkStandardNewMacro(vtkStaticPlaneCutter);
 
 static const char* IdsArrayName = "__vtkSPC_Ids";
 
-//----------------------------------------------------------------------------
-vtkStaticPlaneCutter::vtkStaticPlaneCutter()
-{
-  this->InputMeshTime = 0;
-  this->FilterMTime = 0;
-}
-
-//----------------------------------------------------------------------------
-vtkStaticPlaneCutter::~vtkStaticPlaneCutter()
-{
-  this->ClearWeightsVector();
-}
-
 //-----------------------------------------------------------------------------
 int vtkStaticPlaneCutter::RequestData(
   vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
 {
   // get the inputs and outputs
-  vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
-  vtkInformation* outInfo = outputVector->GetInformationObject(0);
-  vtkUnstructuredGrid* input = vtkUnstructuredGrid::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
-  vtkMultiBlockDataSet* inputMB = vtkMultiBlockDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
-  vtkMultiBlockDataSet* mb =
-    vtkMultiBlockDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
+
+  vtkUnstructuredGrid* input = vtkUnstructuredGrid::GetData(inputVector[0]);
+  vtkMultiBlockDataSet* inputMB = vtkMultiBlockDataSet::GetData(inputVector[0]);
+  vtkMultiBlockDataSet* mb = vtkMultiBlockDataSet::GetData(outputVector);
   if (!mb)
   {
     vtkErrorMacro("Ouput information does not contain expected type of data object");
@@ -79,6 +65,11 @@ int vtkStaticPlaneCutter::RequestData(
   if (this->InputMeshTime == input->GetMeshMTime() && this->FilterMTime == this->GetMTime())
   {
     // Cache mesh is up to date, use it to generate data
+    if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+    {
+      vtkWarningMacro("Using static mesh cache");
+    }
+
     if (this->InterpolateAttributes)
     {
       // Update the cache data
@@ -86,23 +77,28 @@ int vtkStaticPlaneCutter::RequestData(
     }
 
     // Copy the updated cache into the output
-    mb->SetBlock(0, this->Cache.Get());
+    mb->SetBlock(0, this->Cache);
     return 1;
   }
   else
   {
     // Cache is invalid
+    if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+    {
+      vtkWarningMacro("Building static mesh cache");
+    }
+
     // Add needed Arrays
     vtkNew<vtkUnstructuredGrid> tmpInput;
-    this->AddIdsArray(input, tmpInput.Get());
+    this->AddIdsArray(input, tmpInput);
 
     // Create an input vector to pass the completed input to the superclass
     // RequestData method
     vtkNew<vtkInformationVector> tmpInputVec;
     tmpInputVec->Copy(inputVector[0], 1);
     vtkInformation* tmpInInfo = tmpInputVec->GetInformationObject(0);
-    tmpInInfo->Set(vtkDataObject::DATA_OBJECT(), tmpInput.Get());
-    vtkInformationVector* tmpInputVecPt = tmpInputVec.Get();
+    tmpInInfo->Set(vtkDataObject::DATA_OBJECT(), tmpInput);
+    vtkInformationVector* tmpInputVecPt = tmpInputVec;
     int ret = this->Superclass::RequestData(request, &tmpInputVecPt, outputVector);
 
     // Update the cache with superclass output
@@ -131,12 +127,16 @@ void vtkStaticPlaneCutter::AddIdsArray(vtkDataSet* input, vtkDataSet* output)
   vtkNew<vtkIdFilter> generateIdScalars;
 
   // Check for Ids array
-  vtkIdTypeArray *cellIdsTmp = vtkIdTypeArray::SafeDownCast(input->GetCellData()->GetAbstractArray(IdsArrayName));
+  vtkIdTypeArray* cellIdsTmp =
+    vtkIdTypeArray::SafeDownCast(input->GetCellData()->GetAbstractArray(IdsArrayName));
   if (!cellIdsTmp)
   {
     // Create Ids array
     generateIdScalars->SetInputData(tmpInput);
-    generateIdScalars->SetIdsArrayName(IdsArrayName);
+    generateIdScalars->SetPointIds(true);
+    generateIdScalars->SetCellIds(true);
+    generateIdScalars->SetPointIdsArrayName(IdsArrayName);
+    generateIdScalars->SetCellIdsArrayName(IdsArrayName);
     generateIdScalars->FieldDataOn();
     generateIdScalars->Update();
     tmpInput = generateIdScalars->GetOutput();
@@ -160,27 +160,20 @@ void vtkStaticPlaneCutter::RemoveIdsArray(vtkMultiPieceDataSet* output)
   }
 }
 
-//-----------------------------------------------------------------------------
-void vtkStaticPlaneCutter::ClearWeightsVector()
-{
-  for(auto& weightsVector : this->WeightsVectorCompo)
-  {
-    delete[] weightsVector[0].second;
-  }
-  this->WeightsVectorCompo.clear();
-}
-
 //-----------------------------------------------------------------------------
 void vtkStaticPlaneCutter::ComputeIds(vtkUnstructuredGrid* input)
 {
   this->CellToCopyFrom.clear();
   this->CellToCopyTo.clear();
-  this->ClearWeightsVector();
+  this->WeightsVectorCompo.clear();
+
+  const vtkIdType nbPieces = this->Cache->GetNumberOfPieces();
+  this->WeightsVectorCompo.reserve(nbPieces);
 
   // Iterate over each piece of the multipiece output
   vtkNew<vtkGenericCell> tmpCell;
-  vtkSmartPointer<vtkCompositeDataIterator> iter;
-  iter.TakeReference(this->Cache->NewIterator());
+  vtkSmartPointer<vtkCompositeDataIterator> iter =
+    vtkSmartPointer<vtkCompositeDataIterator>::Take(this->Cache->NewIterator());
   iter->SkipEmptyNodesOn();
   for (iter->GoToFirstItem(); !iter->IsDoneWithTraversal(); iter->GoToNextItem())
   {
@@ -190,12 +183,13 @@ void vtkStaticPlaneCutter::ComputeIds(vtkUnstructuredGrid* input)
     {
       // For each piece, recover the Ids of the cells sliced and the corresponding
       // cellId in the slice
-      vtkSmartPointer<vtkIdList> cellIdsFrom = vtkSmartPointer<vtkIdList>::New();
-      vtkSmartPointer<vtkIdList> cellIdsTo = vtkSmartPointer<vtkIdList>::New();
-      this->CellToCopyFrom.push_back(cellIdsFrom);
-      this->CellToCopyTo.push_back(cellIdsTo);
+      this->CellToCopyFrom.emplace_back();
+      this->CellToCopyTo.emplace_back();
+      auto& cellIdsFrom = this->CellToCopyFrom.back();
+      auto& cellIdsTo = this->CellToCopyTo.back();
 
-      vtkIdTypeArray* ids = vtkIdTypeArray::SafeDownCast(slice->GetCellData()->GetArray(IdsArrayName));
+      vtkIdTypeArray* ids =
+        vtkIdTypeArray::SafeDownCast(slice->GetCellData()->GetArray(IdsArrayName));
       assert(ids);
       cellIdsFrom->SetNumberOfIds(ids->GetNumberOfValues());
       cellIdsTo->SetNumberOfIds(ids->GetNumberOfValues());
@@ -208,27 +202,27 @@ void vtkStaticPlaneCutter::ComputeIds(vtkUnstructuredGrid* input)
       {
         slice->BuildLinks();
         vtkIdType maxCellSize = input->GetMaxCellSize();
-        std::vector<std::pair<vtkSmartPointer<vtkIdList>, double*>> weightsVector;
+        std::vector<WeightsVectorElmt> weightsVector;
         weightsVector.resize(sliceNbPoints);
-        double *allWeights = new double[maxCellSize * sliceNbPoints];
         for (vtkIdType i = 0; i < sliceNbPoints; i++)
         {
           vtkNew<vtkIdList> ptIds;
-          double *weights = &allWeights[maxCellSize * i];
-          unsigned short ncells;
-          vtkIdType *cells;
+          weightsVector[i].pointsWeights.resize(maxCellSize);
+          vtkIdType ncells;
+          vtkIdTypecells;
           slice->GetPointCells(i, ncells, cells);
           vtkIdType cellId = cellIdsFrom->GetId(cells[0]);
           assert(cellId < input->GetNumberOfCells());
           input->GetCell(cellId, tmpCell);
           input->GetCellPoints(cellId, ptIds);
           double dist, pcoords[3], x[3], p[3];
-          int subId = 0;
+          int subId;
           slice->GetPoint(i, p);
-          tmpCell->EvaluatePosition(p, x, subId, pcoords, dist, weights);
-          weightsVector[i] = { ptIds, weights };
+          tmpCell->EvaluatePosition(
+            p, x, subId, pcoords, dist, weightsVector[i].pointsWeights.data());
+          weightsVector[i].pointsList = ptIds;
         }
-        this->WeightsVectorCompo.push_back(weightsVector);
+        this->WeightsVectorCompo.emplace_back(std::move(weightsVector));
       }
     }
   }
@@ -249,10 +243,10 @@ void vtkStaticPlaneCutter::UpdateCacheData(vtkDataSet* input)
   vtkCellData* inCD = input->GetCellData();
   vtkPointData* inPD = input->GetPointData();
 
+  int blockId = 0;
   vtkSmartPointer<vtkCompositeDataIterator> iter;
   iter.TakeReference(this->Cache->NewIterator());
   iter->SkipEmptyNodesOn();
-  int blockId = 0;
   for (iter->GoToFirstItem(); !iter->IsDoneWithTraversal(); iter->GoToNextItem())
   {
     vtkPolyData* slice = vtkPolyData::SafeDownCast(iter->GetCurrentDataObject());
@@ -266,7 +260,7 @@ void vtkStaticPlaneCutter::UpdateCacheData(vtkDataSet* input)
         if (arrayToCopyIn)
         {
           // Copy the tuples from the input cell ids to the slice cell ids
-          arrayToCopyIn->InsertTuples(this->CellToCopyTo[blockId].Get(), this->CellToCopyFrom[blockId].Get(),
+          arrayToCopyIn->InsertTuples(this->CellToCopyTo[blockId], this->CellToCopyFrom[blockId],
             inCD->GetAbstractArray(iArr));
         }
       }
@@ -279,7 +273,8 @@ void vtkStaticPlaneCutter::UpdateCacheData(vtkDataSet* input)
         auto& weightsVector = this->WeightsVectorCompo[blockId];
         for (vtkIdType ptIdx = 0; ptIdx < sliceNbPoints; ptIdx++)
         {
-          slicePD->InterpolatePoint(inPD, ptIdx, weightsVector[ptIdx].first, weightsVector[ptIdx].second);
+          slicePD->InterpolatePoint(inPD, ptIdx, weightsVector[ptIdx].pointsList,
+            weightsVector[ptIdx].pointsWeights.data());
         }
       }
 
index ab473e7c8b89eabea851df4f8b72e959999752ee..9f74eb8c182fbb0b74760a59b833e890dc682e5f 100644 (file)
@@ -14,7 +14,7 @@
 =========================================================================*/
 /**
  * @class   vtkStaticPlaneCutter
- * @brief   StaticMesh aware implementation of vtkPlaneCutter vtk vtkUnstructuredGrid
+ * @brief   StaticMesh aware implementation of vtkPlaneCutter for vtkUnstructuredGrid
  *
  * This class specialize vtkPlaneCutter for vtkUnstructuredGrid input.
  * It uses a cache when the associated data chage over time but not the geometry.
  * Contrary to its parent, this class does not interpolate point data,
  * only transmit cell data.
  *
- *
  * @sa
  * vtkPlaneCutter
-*/
+ */
 
 #ifndef vtkStaticPlaneCutter_h
 #define vtkStaticPlaneCutter_h
 
 #include <vector>
 
+#include "StaticMeshModuleModule.h"
+
 class vtkMultiPieceDataSet;
 
-class vtkStaticPlaneCutter : public vtkPlaneCutter
+class STATICMESHMODULE_EXPORT vtkStaticPlaneCutter : public vtkPlaneCutter
 {
 public:
   static vtkStaticPlaneCutter* New();
   typedef vtkPlaneCutter Superclass; // vtkTypeMacro can't be used with a factory built object
-  void PrintSelf(ostream &os, vtkIndent indent) override;
+  void PrintSelf(ostreamos, vtkIndent indent) override;
 
+  /**
+   * see vtkDataSetAlgorithm
+   */
   int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
 
 protected:
-  vtkStaticPlaneCutter();
-  ~vtkStaticPlaneCutter() override;
+  vtkStaticPlaneCutter() = default;
+  ~vtkStaticPlaneCutter() override = default;
 
   /**
    * Check input for Ids cell array, if absent, compute and add them.
@@ -73,19 +77,23 @@ protected:
    */
   void ComputeIds(vtkUnstructuredGrid* input);
 
-  void ClearWeightsVector();
-
-  vtkNew<vtkMultiPieceDataSet> Cache;
-  std::vector<vtkSmartPointer<vtkIdList> > CellToCopyFrom;
-  std::vector<vtkSmartPointer<vtkIdList> > CellToCopyTo;
-  std::vector<std::vector<std::pair<vtkSmartPointer<vtkIdList>, double*>>> WeightsVectorCompo;
-  vtkMTimeType InputMeshTime;
-  vtkMTimeType FilterMTime;
-
 private:
   // Hide these from the user and the compiler.
   vtkStaticPlaneCutter(const vtkStaticPlaneCutter&) = delete;
   void operator=(const vtkStaticPlaneCutter&) = delete;
+
+  struct WeightsVectorElmt
+  {
+    vtkSmartPointer<vtkIdList> pointsList;
+    std::vector<double> pointsWeights;
+  };
+
+  vtkNew<vtkMultiPieceDataSet> Cache;
+  std::vector<vtkNew<vtkIdList> > CellToCopyFrom;
+  std::vector<vtkNew<vtkIdList> > CellToCopyTo;
+  std::vector<std::vector<WeightsVectorElmt> > WeightsVectorCompo;
+  vtkMTimeType InputMeshTime = 0;
+  vtkMTimeType FilterMTime = 0;
 };
 
 #endif
index f1f2a007ac4247a62ea8404f851f82fbb3d61b82..035c064e10fa255f5e86c69cc01c818efa96caa4 100644 (file)
@@ -1,7 +1,7 @@
 /*=========================================================================
 
   Program:   Visualization Toolkit
-  Module:    vtkRTAnalyticSource.cxx
+  Module:    vtkTemporalUGWavelet.cxx
 
   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
   All rights reserved.
 #include <vtkImageData.h>
 #include <vtkInformation.h>
 #include <vtkInformationVector.h>
-#include <vtkMultiProcessController.h>
 #include <vtkNew.h>
 #include <vtkObjectFactory.h>
 #include <vtkPointData.h>
-#include <vtkRTAnalyticSource.h>
 #include <vtkStreamingDemandDrivenPipeline.h>
 #include <vtkUnstructuredGrid.h>
+#include <vtksys/SystemTools.hxx>
 
-vtkStandardNewMacro(vtkTemporalUGWavelet);
-
-// ----------------------------------------------------------------------------
-vtkTemporalUGWavelet::vtkTemporalUGWavelet()
-{
-  this->Cache = vtkUnstructuredGrid::New();
-  this->NumberOfTimeSteps = 10;
-}
+#include <numeric>
 
-// ----------------------------------------------------------------------------
-vtkTemporalUGWavelet::~vtkTemporalUGWavelet()
-{
-  this->Cache->Delete();
-}
+vtkStandardNewMacro(vtkTemporalUGWavelet);
 
 //----------------------------------------------------------------------------
 int vtkTemporalUGWavelet::FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info)
@@ -55,15 +43,15 @@ int vtkTemporalUGWavelet::RequestInformation(
   vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
 {
   vtkInformation* outInfo = outputVector->GetInformationObject(0);
-  double range[2] = { 0, static_cast<double>(this->NumberOfTimeSteps - 1) };
+  double range[2] = { 0., static_cast<double>(this->NumberOfTimeSteps - 1) };
   outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), range, 2);
-  double* outTimes = new double[this->NumberOfTimeSteps];
-  for (int i = 0; i < this->NumberOfTimeSteps; i++)
-  {
-    outTimes[i] = i;
-  }
-  outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), outTimes, this->NumberOfTimeSteps);
+
+  std::vector<double> outTimes(this->NumberOfTimeSteps);
+  std::iota(outTimes.begin(), outTimes.end(), 0);
+  outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), outTimes.data(), outTimes.size());
+
   outInfo->Set(CAN_HANDLE_PIECE_REQUEST(), 1);
+
   return Superclass::RequestInformation(request, inputVector, outputVector);
 }
 
@@ -75,16 +63,21 @@ int vtkTemporalUGWavelet::RequestData(
   vtkUnstructuredGrid* data = vtkUnstructuredGrid::GetData(outInfo);
   if (this->CacheMTime < this->GetMTime())
   {
+    if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+    {
+      vtkWarningMacro("Building static mesh cache");
+    }
+
     // Create an output vector to recover the output image data
     // RequestData method
     vtkNew<vtkInformationVector> tmpOutputVec;
     vtkNew<vtkImageData> image;
     tmpOutputVec->Copy(outputVector, 1);
     vtkInformation* tmpOutInfo = tmpOutputVec->GetInformationObject(0);
-    tmpOutInfo->Set(vtkDataObject::DATA_OBJECT(), image.Get());
+    tmpOutInfo->Set(vtkDataObject::DATA_OBJECT(), image);
 
     // Generate wavelet
-    int ret = this->Superclass::RequestData(request, inputVector, tmpOutputVec.Get());
+    int ret = this->Superclass::RequestData(request, inputVector, tmpOutputVec);
     if (ret == 0)
     {
       return ret;
@@ -92,7 +85,7 @@ int vtkTemporalUGWavelet::RequestData(
 
     // Transform it to unstructured grid
     vtkNew<vtkDataSetTriangleFilter> tetra;
-    tetra->SetInputData(image.Get());
+    tetra->SetInputData(image);
     tetra->Update();
 
     // Create the cache
@@ -110,7 +103,7 @@ int vtkTemporalUGWavelet::RequestData(
   vtkNew<vtkFloatArray> pointArray;
   pointArray->SetName("tPoint");
   pointArray->SetNumberOfValues(nbPoints);
-  data->GetPointData()->AddArray(pointArray.Get());
+  data->GetPointData()->AddArray(pointArray);
   for (vtkIdType i = 0; i < nbPoints; i++)
   {
     pointArray->SetValue(
@@ -122,8 +115,7 @@ int vtkTemporalUGWavelet::RequestData(
   vtkNew<vtkFloatArray> cellArray;
   cellArray->SetName("tCell");
   cellArray->SetNumberOfValues(nbCells);
-  data->GetCellData()->AddArray(cellArray.Get());
-
+  data->GetCellData()->AddArray(cellArray);
   for (vtkIdType i = 0; i < nbCells; i++)
   {
     cellArray->SetValue(i, static_cast<int>(i + t * (nbCells / this->NumberOfTimeSteps)) % nbCells);
index 2758debdfa253a7fd81a79511d695a4c03ac75de..24f7336cba6fc4f58dc0fececdcdab767040d66a 100644 (file)
  *
  * vtkTemporalUGWavelet specialize vtkRTAnalyticSource to create
  * a wavelet converted to vtkUnstructuredGrid, with timesteps.
- * The "tPoint" and "tCell" arrays are the only data actually changing over time
- * make the output a static mesh with data evolving over time.
-*/
+ * The "tPoint" and "tCell" arrays are the only data actually changing
+ * over time, the geometry is generated once and then not modified.
+ */
 
 #ifndef vtkTemporalUGWavelet_h
 #define vtkTemporalUGWavelet_h
 
+#include <vtkNew.h>
 #include <vtkRTAnalyticSource.h>
 
+#include "StaticMeshModuleModule.h"
+
 class vtkUnstructuredGrid;
 
-class vtkTemporalUGWavelet : public vtkRTAnalyticSource
+class STATICMESHMODULE_EXPORT vtkTemporalUGWavelet : public vtkRTAnalyticSource
 {
 public:
   static vtkTemporalUGWavelet* New();
@@ -45,23 +48,26 @@ public:
   //@}
 
 protected:
-  vtkTemporalUGWavelet();
-  ~vtkTemporalUGWavelet();
+  vtkTemporalUGWavelet() = default;
+  ~vtkTemporalUGWavelet() override = default;
 
+  //@{
+  /**
+   * see vtkDataSetAlgorithm
+   */
   int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) override;
-
   int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
     vtkInformationVector* outputVector) override;
-
   int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
-
-  int NumberOfTimeSteps;
-  vtkUnstructuredGrid* Cache;
-  vtkTimeStamp CacheMTime;
+  //@}
 
 private:
   vtkTemporalUGWavelet(const vtkTemporalUGWavelet&) = delete;
   void operator=(const vtkTemporalUGWavelet&) = delete;
+
+  int NumberOfTimeSteps = 10;
+  vtkNew<vtkUnstructuredGrid> Cache;
+  vtkTimeStamp CacheMTime;
 };
 
 #endif
diff --git a/src/Plugins/StaticMesh/plugin/filters.xml b/src/Plugins/StaticMesh/plugin/filters.xml
new file mode 100644 (file)
index 0000000..b9bc14e
--- /dev/null
@@ -0,0 +1,36 @@
+<ServerManagerConfiguration>
+  <ProxyGroup name="filters">
+   <SourceProxy name="ForceStaticMesh" class="vtkForceStaticMesh" label="Force Static Mesh">
+     <Documentation
+        long_help="This filter caches its input the first time it is executed then use it as a static mesh"
+        short_help="Force output to be a static mesh">
+        The Force Static Mesh filter create a cache the first time it is executed using its input. It will then only
+        update PointData, CellData and FieldData from the input as long as their dimensions stay the same.
+        This filter operates only on a vtkUnstructuredGrid input or on the first block of a multiblock input
+        if it is a vtkUnstructuredGrid.
+     </Documentation>
+     <InputProperty command="SetInputConnection"
+                     name="Input">
+        <ProxyGroupDomain name="groups">
+          <Group name="sources" />
+          <Group name="filters" />
+        </ProxyGroupDomain>
+        <DataTypeDomain name="input_type">
+          <DataType value="vtkUnstructuredGrid" />
+          <DataType value="vtkCompositeDataSet" />
+        </DataTypeDomain>
+        <Documentation>This property specifies the input of the filter.</Documentation>
+      </InputProperty>
+      <IntVectorProperty
+        name="ForceCacheComputation"
+        command="SetCacheComputation"
+        default_values="0"
+        panel_visibility="advanced" >
+        <BooleanDomain name="bool" />
+        <Documentation>
+          Set this to true to force this filter to recompute the cache instead of using it.
+        </Documentation>
+      </IntVectorProperty>
+    </SourceProxy>
+  </ProxyGroup>
+</ServerManagerConfiguration>
diff --git a/src/Plugins/StaticMesh/plugin/readers.xml b/src/Plugins/StaticMesh/plugin/readers.xml
new file mode 100644 (file)
index 0000000..a367f06
--- /dev/null
@@ -0,0 +1,103 @@
+<ServerManagerConfiguration>
+  <ProxyGroup name="sources">
+
+    <!-- This proxy is a copy paste of the one in:
+      paraview/VTKExtensions/IOEnSight/Resources/readers_pv_ioensight.xml
+      with an additional entry: the UseStaticMesh boolean.
+    -->
+    <SourceProxy label="EnSight Reader"
+                 name="ensight"
+                 class="vtkGenericStaticEnSightReader">
+      <Documentation long_help="Reads EnSight 6 and Gold files (static version)."
+                     short_help="Read EnSight files (static version).">The
+                     EnSight reader reads files in the format produced by
+                     CEI's EnSight. EnSight 6 and Gold files (both ASCII
+                     and binary) are supported. This version allows to generate
+                     static meshes, on which geometry is considered constant
+                     between time steps. The default extension is .case. The
+                     output of this reader is a multiblock dataset.
+      </Documentation>
+
+      <!-- Additional boolean to control static mesh generation -->
+      <IntVectorProperty
+         name="UseStaticMesh"
+         command="SetUseStaticMesh"
+         label="Use static mesh"
+         number_of_elements="1"
+         default_values="1">
+         <BooleanDomain name="bool"/>
+         <Documentation>
+           Control static output mesh generation. When this option is checked,
+           the first time this reader is executed a mesh will be generated,
+           then only points, cells and fields data will be updated without
+           rereading and recreating the mesh geometry. Keep unchecked for
+           non-static EnSight files.
+         </Documentation>
+      </IntVectorProperty>
+
+      <!-- Original XML -->
+      <StringVectorProperty animateable="0"
+                            command="SetCaseFileName"
+                            name="CaseFileName"
+                            number_of_elements="1">
+        <FileListDomain name="files" />
+        <Documentation>This property specifies the case file name for the
+        EnSight reader.</Documentation>
+      </StringVectorProperty>
+      <DoubleVectorProperty information_only="1"
+                            name="TimestepValues"
+                            repeatable="1">
+        <TimeStepsInformationHelper />
+        <Documentation>Available timestep values.</Documentation>
+      </DoubleVectorProperty>
+      <StringVectorProperty information_only="1"
+                            name="CellArrayInfo">
+        <ArraySelectionInformationHelper attribute_name="Cell" />
+      </StringVectorProperty>
+      <StringVectorProperty command="SetCellArrayStatus"
+                            element_types="2 0"
+                            information_property="CellArrayInfo"
+                            label="Cell Arrays"
+                            name="CellArrayStatus"
+                            number_of_elements="0"
+                            number_of_elements_per_command="2"
+                            repeat_command="1">
+        <ArraySelectionDomain name="array_list">
+          <RequiredProperties>
+            <Property function="ArrayList"
+                      name="CellArrayInfo" />
+          </RequiredProperties>
+        </ArraySelectionDomain>
+        <Documentation>This property lists which cell-centered arrays to
+        read.</Documentation>
+      </StringVectorProperty>
+      <StringVectorProperty information_only="1"
+                            name="PointArrayInfo">
+        <ArraySelectionInformationHelper attribute_name="Point" />
+      </StringVectorProperty>
+      <StringVectorProperty command="SetPointArrayStatus"
+                            element_types="2 0"
+                            information_property="PointArrayInfo"
+                            label="Point Arrays"
+                            name="PointArrayStatus"
+                            number_of_elements="0"
+                            number_of_elements_per_command="2"
+                            repeat_command="1">
+        <ArraySelectionDomain name="array_list">
+          <RequiredProperties>
+            <Property function="ArrayList"
+                      name="PointArrayInfo" />
+          </RequiredProperties>
+        </ArraySelectionDomain>
+        <Documentation>This property lists which point-centered arrays to
+        read.</Documentation>
+      </StringVectorProperty>
+
+      <Hints>
+        <ReaderFactory extensions="case CASE Case"
+                       file_description="EnSight Files" />
+      </Hints>
+    </SourceProxy>
+
+  </ProxyGroup>
+</ServerManagerConfiguration>
index bf089f3bde27c3cfb201eb9a521e3f85aa426e40..1eca2238923696394e0aa83c527b86cdf78599cf 100644 (file)
@@ -1,5 +1,6 @@
 <ServerManagerConfiguration>
   <ProxyGroup name="sources">
+
     <SourceProxy class="vtkTemporalUGWavelet"
                  label="Temporal Unstructured Grid Wavelet"
                  name="TemporalUGWavelet">
@@ -8,9 +9,10 @@
       <Documentation long_help="Create a unstructured grid in up to three dimensions with values varying according to a periodic function as well as temporal varying point and cell data."
                      short_help="Create a temporal unstructured grid containing a wavelet">
                      See Wavelet documentation.
-                     This is a wavelet converted into an unstructured grid.
-                     It contains timesteps yet the mesh is statis over time.
-                     It also contains tPoint and tCell wich are scalar array varying over time.</Documentation>
+                     The output is a wavelet converted into an unstructured grid.
+                     It contains timesteps yet the mesh is static over time.
+                     It also contains "tPoint" and "tCell", wich are scalar arrays varying over time.
+      </Documentation>
       <DoubleVectorProperty information_only="1"
                             name="TimestepValues"
                             repeatable="1">