From: Anthony Geay Date: Thu, 7 Apr 2022 07:24:35 +0000 (+0200) Subject: [EDF24911] : StaticMesh option in Ensight Reader + Force Static Mesh Plugin. Synchron... X-Git-Tag: V9_9_0b1^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d725e568696c84e8bb64200b105872f5b480bba8;p=modules%2Fparavis.git [EDF24911] : StaticMesh option in Ensight Reader + Force Static Mesh Plugin. Synchronize with https://gitlab.kitware.com/paraview/staticmeshplugin --- diff --git a/src/Plugins/StaticMesh/plugin/CMakeLists.txt b/src/Plugins/StaticMesh/plugin/CMakeLists.txt index 0fe40a0f..61bf3e3d 100644 --- a/src/Plugins/StaticMesh/plugin/CMakeLists.txt +++ b/src/Plugins/StaticMesh/plugin/CMakeLists.txt @@ -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 diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/CMakeLists.txt b/src/Plugins/StaticMesh/plugin/StaticMeshModule/CMakeLists.txt index 3ea7b1fb..a835e612 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/CMakeLists.txt +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/CMakeLists.txt @@ -27,6 +27,8 @@ set(private_classes ) set(classes + vtkForceStaticMesh + vtkGenericStaticEnSightReader vtkTemporalUGWavelet vtkStaticMeshObjectFactory ) diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtk.module b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtk.module index d6165617..fd86d1c5 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtk.module +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtk.module @@ -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 index 00000000..de4ced05 --- /dev/null +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkForceStaticMesh.cxx @@ -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 +#include +#include +#include +#include +#include +#include +#include + +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 index 00000000..112c95b7 --- /dev/null +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkForceStaticMesh.h @@ -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 +#include + +#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 Cache; +}; + +#endif diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkGenericStaticEnSightReader.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkGenericStaticEnSightReader.cxx new file mode 100644 index 00000000..2cf49f36 --- /dev/null +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkGenericStaticEnSightReader.cxx @@ -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 index 00000000..540b80ad --- /dev/null +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkGenericStaticEnSightReader.h @@ -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 +#include + +#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 diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticDataSetSurfaceFilter.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticDataSetSurfaceFilter.cxx index 429e8905..43b701f8 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticDataSetSurfaceFilter.cxx +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticDataSetSurfaceFilter.cxx @@ -20,21 +20,10 @@ #include #include #include +#include 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(origPointArray->GetVoidPointer(0)), - sizeof(vtkIdType) * origPointArray->GetNumberOfTuples()); vtkNew 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(origCellArray->GetVoidPointer(0)), - sizeof(vtkIdType) * origCellArray->GetNumberOfTuples()); vtkNew 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 diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticDataSetSurfaceFilter.h b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticDataSetSurfaceFilter.h index ec885829..27a16de0 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticDataSetSurfaceFilter.h +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticDataSetSurfaceFilter.h @@ -25,7 +25,7 @@ * * @sa * vtkStaticMeshObjectFactory -*/ + */ #ifndef vtkStaticDataSetSurfaceFilter_h #define vtkStaticDataSetSurfaceFilter_h @@ -33,30 +33,36 @@ #include #include +#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 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 Cache; + vtkMTimeType InputMeshTime = 0; + vtkMTimeType FilterMTime = 0; }; #endif diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6BinaryReader.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6BinaryReader.cxx index aef35889..9fa199b6 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6BinaryReader.cxx +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6BinaryReader.cxx @@ -23,60 +23,48 @@ #include #include #include +#include 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(this->FileSetNumberOfSteps-> - GetItemAsObject(fileSet)); + vtkIdType fileSet = this->FileSets->IsId(this->GeometryFileSet); + vtkIdList* numStepsList = + static_cast(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(this->FileSetNumberOfSteps-> - GetItemAsObject(fileSet)); + vtkIdType fileSet = this->FileSets->IsId(this->MeasuredFileSet); + vtkIdList* numStepsList = + static_cast(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(); } diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6BinaryReader.h b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6BinaryReader.h index eadf1726..d6573ca4 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6BinaryReader.h +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6BinaryReader.h @@ -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 @@ -41,29 +41,42 @@ #include #include +#include "StaticMeshModuleModule.h" + class vtkMultiBlockDataSet; -class vtkStaticEnSight6BinaryReader : public vtkEnSight6BinaryReader +class STATICMESHMODULE_EXPORT vtkStaticEnSight6BinaryReader : public vtkEnSight6BinaryReader { public: - static vtkStaticEnSight6BinaryReader *New(); + static vtkStaticEnSight6BinaryReader* New(); 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 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 Cache; + vtkTimeStamp CacheMTime; }; #endif - diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6Reader.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6Reader.cxx index 8ad68cd4..7845d311 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6Reader.cxx +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6Reader.cxx @@ -23,60 +23,48 @@ #include #include #include +#include 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(this->FileSetNumberOfSteps-> - GetItemAsObject(fileSet)); + vtkIdType fileSet = this->FileSets->IsId(this->GeometryFileSet); + vtkIdList* numStepsList = + static_cast(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(this->FileSetNumberOfSteps-> - GetItemAsObject(fileSet)); + vtkIdType fileSet = this->FileSets->IsId(this->MeasuredFileSet); + vtkIdList* numStepsList = + static_cast(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(); } diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6Reader.h b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6Reader.h index 30fe1484..9b7282d9 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6Reader.h +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6Reader.h @@ -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 @@ -41,29 +41,43 @@ #include #include +#include "StaticMeshModuleModule.h" + class vtkMultiBlockDataSet; -class vtkStaticEnSight6Reader : public vtkEnSight6Reader +class STATICMESHMODULE_EXPORT vtkStaticEnSight6Reader : public vtkEnSight6Reader { public: - static vtkStaticEnSight6Reader *New(); + static vtkStaticEnSight6Reader* New(); 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 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 Cache; + vtkTimeStamp CacheMTime; }; #endif - diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldBinaryReader.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldBinaryReader.cxx index 6d336de8..f6965b5f 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldBinaryReader.cxx +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldBinaryReader.cxx @@ -23,60 +23,48 @@ #include #include #include +#include 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(this->FileSetNumberOfSteps-> - GetItemAsObject(fileSet)); + vtkIdType fileSet = this->FileSets->IsId(this->GeometryFileSet); + vtkIdList* numStepsList = + static_cast(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(this->FileSetNumberOfSteps-> - GetItemAsObject(fileSet)); + vtkIdType fileSet = this->FileSets->IsId(this->MeasuredFileSet); + vtkIdList* numStepsList = + static_cast(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(); } diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldBinaryReader.h b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldBinaryReader.h index e246509a..6ed79c19 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldBinaryReader.h +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldBinaryReader.h @@ -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 @@ -41,29 +41,43 @@ #include #include +#include "StaticMeshModuleModule.h" + class vtkMultiBlockDataSet; -class vtkStaticEnSightGoldBinaryReader : public vtkEnSightGoldBinaryReader +class STATICMESHMODULE_EXPORT vtkStaticEnSightGoldBinaryReader : public vtkEnSightGoldBinaryReader { public: - static vtkStaticEnSightGoldBinaryReader *New(); + static vtkStaticEnSightGoldBinaryReader* New(); 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 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 Cache; + vtkTimeStamp CacheMTime; }; #endif - diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldReader.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldReader.cxx index 11a62154..f338f122 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldReader.cxx +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldReader.cxx @@ -23,60 +23,48 @@ #include #include #include +#include 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(this->FileSetNumberOfSteps-> - GetItemAsObject(fileSet)); + vtkIdType fileSet = this->FileSets->IsId(this->GeometryFileSet); + vtkIdList* numStepsList = + static_cast(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(this->FileSetNumberOfSteps-> - GetItemAsObject(fileSet)); + vtkIdType fileSet = this->FileSets->IsId(this->MeasuredFileSet); + vtkIdList* numStepsList = + static_cast(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(); } diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldReader.h b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldReader.h index 2be1a028..ab2efc84 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldReader.h +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldReader.h @@ -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 @@ -41,29 +41,43 @@ #include #include +#include "StaticMeshModuleModule.h" + class vtkMultiBlockDataSet; -class vtkStaticEnSightGoldReader : public vtkEnSightGoldReader +class STATICMESHMODULE_EXPORT vtkStaticEnSightGoldReader : public vtkEnSightGoldReader { public: - static vtkStaticEnSightGoldReader *New(); + static vtkStaticEnSightGoldReader* New(); 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 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 Cache; + vtkTimeStamp CacheMTime; }; #endif - diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticMeshObjectFactory.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticMeshObjectFactory.cxx index 4c6f1e6e..bb8f91ae 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticMeshObjectFactory.cxx +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticMeshObjectFactory.cxx @@ -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 instance; vtkObjectFactory::RegisterFactory(instance); - instance->Delete(); } } diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticMeshObjectFactory.h b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticMeshObjectFactory.h index 316b9fab..5e06ea60 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticMeshObjectFactory.h +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticMeshObjectFactory.h @@ -1,7 +1,7 @@ /*========================================================================= Program: Visualization Toolkit - Module: vtkStaticDataSetSurfaceFilter.h + Module: vtkStaticMeshObjectFactor.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. @@ -14,18 +14,20 @@ =========================================================================*/ /** * @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 // 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; diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPUnstructuredGridGhostCellsGenerator.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPUnstructuredGridGhostCellsGenerator.cxx index b4ab07c9..d1cb9b41 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPUnstructuredGridGhostCellsGenerator.cxx +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPUnstructuredGridGhostCellsGenerator.cxx @@ -28,6 +28,7 @@ #include #include #include +#include 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::New(); - this->GhostCellsToSend[i] = vtkSmartPointer::New(); - this->GhostPointsToReceive[i] = vtkSmartPointer::New(); - this->GhostPointsToSend[i] = vtkSmartPointer::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 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 > 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 > 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 > 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 > 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) diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPUnstructuredGridGhostCellsGenerator.h b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPUnstructuredGridGhostCellsGenerator.h index ecfadfec..1152d6a3 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPUnstructuredGridGhostCellsGenerator.h +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPUnstructuredGridGhostCellsGenerator.h @@ -26,21 +26,23 @@ * * @sa * vtkPUnstructuredGridGhostCellsGenerator -*/ + */ #ifndef vtkStaticPUnstructuredGridGhostCellsGenerator_h #define vtkStaticPUnstructuredGridGhostCellsGenerator_h -#include #include #include -#include #include +#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 Cache; - vtkMTimeType InputMeshTime; - vtkMTimeType FilterMTime; - - std::vector > GhostCellsToReceive; - std::vector > GhostCellsToSend; - std::vector > GhostPointsToReceive; - std::vector > GhostPointsToSend; - private: - // Hide these from the user and the compiler. vtkStaticPUnstructuredGridGhostCellsGenerator( const vtkStaticPUnstructuredGridGhostCellsGenerator&) = delete; void operator=(const vtkStaticPUnstructuredGridGhostCellsGenerator&) = delete; + + vtkNew Cache; + vtkMTimeType InputMeshTime = 0; + vtkMTimeType FilterMTime = 0; + + std::vector > GhostCellsToReceive; + std::vector > GhostCellsToSend; + std::vector > GhostPointsToReceive; + std::vector > GhostPointsToSend; }; #endif diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.cxx index 393bddcf..73d73ebe 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.cxx +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.cxx @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -26,36 +27,21 @@ #include #include #include -#include +#include 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 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 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 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 tmpCell; - vtkSmartPointer iter; - iter.TakeReference(this->Cache->NewIterator()); + vtkSmartPointer iter = + vtkSmartPointer::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 cellIdsFrom = vtkSmartPointer::New(); - vtkSmartPointer cellIdsTo = vtkSmartPointer::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, double*>> weightsVector; + std::vector weightsVector; weightsVector.resize(sliceNbPoints); - double *allWeights = new double[maxCellSize * sliceNbPoints]; for (vtkIdType i = 0; i < sliceNbPoints; i++) { vtkNew ptIds; - double *weights = &allWeights[maxCellSize * i]; - unsigned short ncells; - vtkIdType *cells; + weightsVector[i].pointsWeights.resize(maxCellSize); + vtkIdType ncells; + vtkIdType* cells; 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 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()); } } diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.h b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.h index ab473e7c..9f74eb8c 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.h +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.h @@ -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. @@ -23,10 +23,9 @@ * Contrary to its parent, this class does not interpolate point data, * only transmit cell data. * - * * @sa * vtkPlaneCutter -*/ + */ #ifndef vtkStaticPlaneCutter_h #define vtkStaticPlaneCutter_h @@ -38,20 +37,25 @@ #include +#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(ostream& os, 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 Cache; - std::vector > CellToCopyFrom; - std::vector > CellToCopyTo; - std::vector, 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 pointsList; + std::vector pointsWeights; + }; + + vtkNew Cache; + std::vector > CellToCopyFrom; + std::vector > CellToCopyTo; + std::vector > WeightsVectorCompo; + vtkMTimeType InputMeshTime = 0; + vtkMTimeType FilterMTime = 0; }; #endif diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkTemporalUGWavelet.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkTemporalUGWavelet.cxx index f1f2a007..035c064e 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkTemporalUGWavelet.cxx +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkTemporalUGWavelet.cxx @@ -1,7 +1,7 @@ /*========================================================================= Program: Visualization Toolkit - Module: vtkRTAnalyticSource.cxx + Module: vtkTemporalUGWavelet.cxx Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. @@ -20,28 +20,16 @@ #include #include #include -#include #include #include #include -#include #include #include +#include -vtkStandardNewMacro(vtkTemporalUGWavelet); - -// ---------------------------------------------------------------------------- -vtkTemporalUGWavelet::vtkTemporalUGWavelet() -{ - this->Cache = vtkUnstructuredGrid::New(); - this->NumberOfTimeSteps = 10; -} +#include -// ---------------------------------------------------------------------------- -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(this->NumberOfTimeSteps - 1) }; + double range[2] = { 0., static_cast(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 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 tmpOutputVec; vtkNew 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 tetra; - tetra->SetInputData(image.Get()); + tetra->SetInputData(image); tetra->Update(); // Create the cache @@ -110,7 +103,7 @@ int vtkTemporalUGWavelet::RequestData( vtkNew 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 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(i + t * (nbCells / this->NumberOfTimeSteps)) % nbCells); diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkTemporalUGWavelet.h b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkTemporalUGWavelet.h index 2758debd..24f7336c 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkTemporalUGWavelet.h +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkTemporalUGWavelet.h @@ -18,18 +18,21 @@ * * 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 #include +#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 Cache; + vtkTimeStamp CacheMTime; }; #endif diff --git a/src/Plugins/StaticMesh/plugin/filters.xml b/src/Plugins/StaticMesh/plugin/filters.xml new file mode 100644 index 00000000..b9bc14ee --- /dev/null +++ b/src/Plugins/StaticMesh/plugin/filters.xml @@ -0,0 +1,36 @@ + + + + + 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. + + + + + + + + + + + This property specifies the input of the filter. + + + + + Set this to true to force this filter to recompute the cache instead of using it. + + + + + diff --git a/src/Plugins/StaticMesh/plugin/readers.xml b/src/Plugins/StaticMesh/plugin/readers.xml new file mode 100644 index 00000000..a367f066 --- /dev/null +++ b/src/Plugins/StaticMesh/plugin/readers.xml @@ -0,0 +1,103 @@ + + + + + + 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. + + + + + + + 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. + + + + + + + This property specifies the case file name for the + EnSight reader. + + + + Available timestep values. + + + + + + + + + + + This property lists which cell-centered arrays to + read. + + + + + + + + + + + This property lists which point-centered arrays to + read. + + + + + + + + + diff --git a/src/Plugins/StaticMesh/plugin/sources.xml b/src/Plugins/StaticMesh/plugin/sources.xml index bf089f3b..1eca2238 100644 --- a/src/Plugins/StaticMesh/plugin/sources.xml +++ b/src/Plugins/StaticMesh/plugin/sources.xml @@ -1,5 +1,6 @@ + @@ -8,9 +9,10 @@ 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. + 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. +