From: Anthony Geay Date: Thu, 13 Oct 2022 14:33:19 +0000 (+0200) Subject: StaticMeshPlugin porting for PV5.11 X-Git-Tag: V9_10_0a1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a732b7ee3405f180272709971c59dba17b46231a;p=modules%2Fparavis.git StaticMeshPlugin porting for PV5.11 --- diff --git a/src/Plugins/CMakeLists.txt b/src/Plugins/CMakeLists.txt index 73d5bf8f..9cfe8fe1 100644 --- a/src/Plugins/CMakeLists.txt +++ b/src/Plugins/CMakeLists.txt @@ -29,7 +29,7 @@ SET(_subdirs ArrayRenamer JSONReader DevelopedSurface - #StaticMesh + StaticMesh GaussToCell VoroGauss ) diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticDataSetSurfaceFilter.h b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticDataSetSurfaceFilter.h index 27a16de0..20eab9a3 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticDataSetSurfaceFilter.h +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticDataSetSurfaceFilter.h @@ -30,19 +30,19 @@ #ifndef vtkStaticDataSetSurfaceFilter_h #define vtkStaticDataSetSurfaceFilter_h -#include +#include #include #include "StaticMeshModuleModule.h" class vtkPolyData; -class STATICMESHMODULE_EXPORT vtkStaticDataSetSurfaceFilter : public vtkDataSetSurfaceFilter +class STATICMESHMODULE_EXPORT vtkStaticDataSetSurfaceFilter : public vtkGeometryFilter { public: static vtkStaticDataSetSurfaceFilter* New(); // vtkTypeMacro can't be used with a factory built object - using Superclass = vtkDataSetSurfaceFilter; + using Superclass = vtkGeometryFilter; void PrintSelf(ostream& os, vtkIndent indent) override; /** diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6BinaryReader.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6BinaryReader.cxx index 9fa199b6..677df958 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6BinaryReader.cxx +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6BinaryReader.cxx @@ -106,7 +106,7 @@ int vtkStaticEnSight6BinaryReader::RequestData(vtkInformation* vtkNotUsed(reques int filenameNum = filenameNumbers->GetId(timeStep - 1); if (!this->UseFileSets) { - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } @@ -140,7 +140,7 @@ int vtkStaticEnSight6BinaryReader::RequestData(vtkInformation* vtkNotUsed(reques { vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum); int filenameNum = filenameNumbers->GetId(fileNum - 1); - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } @@ -187,7 +187,7 @@ int vtkStaticEnSight6BinaryReader::RequestData(vtkInformation* vtkNotUsed(reques int filenameNum = filenameNumbers->GetId(timeStep - 1); if (!this->UseFileSets) { - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } @@ -221,7 +221,7 @@ int vtkStaticEnSight6BinaryReader::RequestData(vtkInformation* vtkNotUsed(reques { vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet); int filenameNum = filenameNumbers->GetId(fileNum - 1); - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6Reader.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6Reader.cxx index 7845d311..76054db8 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6Reader.cxx +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSight6Reader.cxx @@ -106,7 +106,7 @@ int vtkStaticEnSight6Reader::RequestData(vtkInformation* vtkNotUsed(request), int filenameNum = filenameNumbers->GetId(timeStep - 1); if (!this->UseFileSets) { - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } @@ -140,7 +140,7 @@ int vtkStaticEnSight6Reader::RequestData(vtkInformation* vtkNotUsed(request), { vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum); int filenameNum = filenameNumbers->GetId(fileNum - 1); - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } @@ -187,7 +187,7 @@ int vtkStaticEnSight6Reader::RequestData(vtkInformation* vtkNotUsed(request), int filenameNum = filenameNumbers->GetId(timeStep - 1); if (!this->UseFileSets) { - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } @@ -221,7 +221,7 @@ int vtkStaticEnSight6Reader::RequestData(vtkInformation* vtkNotUsed(request), { vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet); int filenameNum = filenameNumbers->GetId(fileNum - 1); - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldBinaryReader.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldBinaryReader.cxx index f6965b5f..ed9d60d6 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldBinaryReader.cxx +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldBinaryReader.cxx @@ -106,7 +106,7 @@ int vtkStaticEnSightGoldBinaryReader::RequestData(vtkInformation* vtkNotUsed(req int filenameNum = filenameNumbers->GetId(timeStep - 1); if (!this->UseFileSets) { - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } @@ -140,7 +140,7 @@ int vtkStaticEnSightGoldBinaryReader::RequestData(vtkInformation* vtkNotUsed(req { vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum); int filenameNum = filenameNumbers->GetId(fileNum - 1); - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } @@ -187,7 +187,7 @@ int vtkStaticEnSightGoldBinaryReader::RequestData(vtkInformation* vtkNotUsed(req int filenameNum = filenameNumbers->GetId(timeStep - 1); if (!this->UseFileSets) { - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } @@ -221,7 +221,7 @@ int vtkStaticEnSightGoldBinaryReader::RequestData(vtkInformation* vtkNotUsed(req { vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet); int filenameNum = filenameNumbers->GetId(fileNum - 1); - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldReader.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldReader.cxx index f338f122..35377b79 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldReader.cxx +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticEnSightGoldReader.cxx @@ -106,7 +106,7 @@ int vtkStaticEnSightGoldReader::RequestData(vtkInformation* vtkNotUsed(request), int filenameNum = filenameNumbers->GetId(timeStep - 1); if (!this->UseFileSets) { - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } @@ -140,7 +140,7 @@ int vtkStaticEnSightGoldReader::RequestData(vtkInformation* vtkNotUsed(request), { vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum); int filenameNum = filenameNumbers->GetId(fileNum - 1); - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } @@ -187,7 +187,7 @@ int vtkStaticEnSightGoldReader::RequestData(vtkInformation* vtkNotUsed(request), int filenameNum = filenameNumbers->GetId(timeStep - 1); if (!this->UseFileSets) { - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } @@ -221,7 +221,7 @@ int vtkStaticEnSightGoldReader::RequestData(vtkInformation* vtkNotUsed(request), { vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet); int filenameNum = filenameNumbers->GetId(fileNum - 1); - this->ReplaceWildcards(&fileName[0], filenameNum); + this->ReplaceWildcardsHelper(&fileName[0], filenameNum); } } } diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticMeshObjectFactory.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticMeshObjectFactory.cxx index bb8f91ae..deaace7a 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticMeshObjectFactory.cxx +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticMeshObjectFactory.cxx @@ -46,7 +46,7 @@ VTK_CREATE_CREATE_FUNCTION(vtkStaticPUnstructuredGridGhostCellsGenerator); //----------------------------------------------------------------------------- vtkStaticMeshObjectFactory::vtkStaticMeshObjectFactory() { - this->RegisterOverride("vtkDataSetSurfaceFilter", "vtkStaticDataSetSurfaceFilter", + this->RegisterOverride("vtkGeometryFilter", "vtkStaticDataSetSurfaceFilter", "StaticDataSetSurfaceFilter", 1, vtkObjectFactoryCreatevtkStaticDataSetSurfaceFilter); this->RegisterOverride("vtkPlaneCutter", "vtkStaticPlaneCutter", "StaticPlaneCutter", 1, vtkObjectFactoryCreatevtkStaticPlaneCutter); diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPUnstructuredGridGhostCellsGenerator.h b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPUnstructuredGridGhostCellsGenerator.h index 1152d6a3..bfcc3669 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPUnstructuredGridGhostCellsGenerator.h +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPUnstructuredGridGhostCellsGenerator.h @@ -16,7 +16,7 @@ * @class vtkStaticPUnstructuredGridGhostCellsGenerator * @brief StaticMesh aware GhostCellGenerator implementation * - * This class specialize vtkPUnstructuredGridGhostCellGenerator + * This class specialize vtkGhostCellsGenerator * This class improves it by making it static mesh aware. * The first time this filter is executed it will store its output * in a cache as well as a list of ghost and point ids to request from other rank @@ -25,28 +25,29 @@ * allowing to update the output without needing to recompute everything * * @sa - * vtkPUnstructuredGridGhostCellsGenerator + * vtkGhostCellsGenerator */ #ifndef vtkStaticPUnstructuredGridGhostCellsGenerator_h #define vtkStaticPUnstructuredGridGhostCellsGenerator_h #include -#include +#include #include #include "StaticMeshModuleModule.h" class vtkIdList; +class vtkDataSet; class vtkUnstructuredGrid; class STATICMESHMODULE_EXPORT vtkStaticPUnstructuredGridGhostCellsGenerator - : public vtkPUnstructuredGridGhostCellsGenerator + : public vtkGhostCellsGenerator { public: static vtkStaticPUnstructuredGridGhostCellsGenerator* New(); - typedef vtkPUnstructuredGridGhostCellsGenerator + typedef vtkGhostCellsGenerator Superclass; // vtkTypeMacro can't be used with a factory built object void PrintSelf(ostream& os, vtkIndent indent) override; diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.cxx b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.cxx index 73d73ebe..12c20d97 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.cxx +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -38,31 +39,43 @@ int vtkStaticPlaneCutter::RequestData( vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector) { // get the inputs and outputs - - vtkUnstructuredGrid* input = vtkUnstructuredGrid::GetData(inputVector[0]); - vtkMultiBlockDataSet* inputMB = vtkMultiBlockDataSet::GetData(inputVector[0]); - vtkMultiBlockDataSet* mb = vtkMultiBlockDataSet::GetData(outputVector); - if (!mb) + auto inputDO = vtkDataObject::GetData(inputVector[0], 0); + auto outputDO = vtkDataObject::GetData(outputVector, 0); + if (inputDO == nullptr) { - vtkErrorMacro("Ouput information does not contain expected type of data object"); + vtkErrorMacro("Input is nullptr."); return 0; } - // Recover the first and only block so this works with single block mb + vtkUnstructuredGrid* inputUG = vtkUnstructuredGrid::SafeDownCast(inputDO); + vtkMultiBlockDataSet* inputMB = vtkMultiBlockDataSet::SafeDownCast(inputDO); + vtkPartitionedDataSetCollection* inputPDC = + vtkPartitionedDataSetCollection::SafeDownCast(inputDO); + vtkPartitionedDataSet* inputPD = vtkPartitionedDataSet::SafeDownCast(inputDO); + + // Recover the first and only block/partition so this works with single block composite if (inputMB && inputMB->GetNumberOfBlocks() == 1) { - input = vtkUnstructuredGrid::SafeDownCast(inputMB->GetBlock(0)); + inputUG = vtkUnstructuredGrid::SafeDownCast(inputMB->GetBlock(0)); + } + if (inputPDC && inputPDC->GetNumberOfPartitionedDataSets() == 1) + { + inputPD = vtkPartitionedDataSet::SafeDownCast(inputPDC->GetPartitionedDataSet(0)); + } + if (inputPD && inputPD->GetNumberOfPartitions() == 1) + { + inputUG = vtkUnstructuredGrid::SafeDownCast(inputPD->GetPartition(0)); } // Recover the static unstructured grid - if (!input) + if (!inputUG) { // For any other type of input, fall back to superclass implementation return this->Superclass::RequestData(request, inputVector, outputVector); } // Check cache validity - if (this->InputMeshTime == input->GetMeshMTime() && this->FilterMTime == this->GetMTime()) + if (this->InputMeshTime == inputUG->GetMeshMTime() && this->FilterMTime == this->GetMTime()) { // Cache mesh is up to date, use it to generate data if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH")) @@ -73,11 +86,12 @@ int vtkStaticPlaneCutter::RequestData( if (this->InterpolateAttributes) { // Update the cache data - this->UpdateCacheData(input); + this->UpdateCacheData(inputUG); } // Copy the updated cache into the output - mb->SetBlock(0, this->Cache); + this->SetOutputFromCache(outputDO); + this->RemoveIdsArray(outputDO); return 1; } else @@ -90,7 +104,7 @@ int vtkStaticPlaneCutter::RequestData( // Add needed Arrays vtkNew tmpInput; - this->AddIdsArray(input, tmpInput); + this->AddIdsArray(inputUG, tmpInput); // Create an input vector to pass the completed input to the superclass // RequestData method @@ -102,20 +116,14 @@ int vtkStaticPlaneCutter::RequestData( int ret = this->Superclass::RequestData(request, &tmpInputVecPt, outputVector); // Update the cache with superclass output - vtkMultiPieceDataSet* output = vtkMultiPieceDataSet::SafeDownCast(mb->GetBlock(0)); - if (!output) - { - vtkErrorMacro("Output is not of expected type"); - return 0; - } - - this->Cache->ShallowCopy(output); - this->InputMeshTime = input->GetMeshMTime(); + this->Cache->ShallowCopy(outputDO); + assert(this->Cache); + this->InputMeshTime = inputUG->GetMeshMTime(); this->FilterMTime = this->GetMTime(); // Compute the ids to be passed from the input to the cache - this->ComputeIds(input); - this->RemoveIdsArray(this->Cache); + this->ComputeIds(inputUG); + this->RemoveIdsArray(outputDO); return ret; } } @@ -145,19 +153,31 @@ void vtkStaticPlaneCutter::AddIdsArray(vtkDataSet* input, vtkDataSet* output) } //----------------------------------------------------------------------------- -void vtkStaticPlaneCutter::RemoveIdsArray(vtkMultiPieceDataSet* output) +void vtkStaticPlaneCutter::RemoveIdsArray(vtkDataObject* output) { - vtkSmartPointer iter; - iter.TakeReference(output->NewIterator()); - iter->SkipEmptyNodesOn(); - for (iter->GoToFirstItem(); !iter->IsDoneWithTraversal(); iter->GoToNextItem()) + + if (auto pd = vtkPolyData::SafeDownCast(output)) { - vtkPolyData* slice = vtkPolyData::SafeDownCast(iter->GetCurrentDataObject()); - if (slice) + pd->GetCellData()->RemoveArray(IdsArrayName); + } + else if (auto outputMP = vtkMultiPieceDataSet::SafeDownCast(output)) + { + vtkSmartPointer iter; + iter.TakeReference(outputMP->NewIterator()); + iter->SkipEmptyNodesOn(); + for (iter->GoToFirstItem(); !iter->IsDoneWithTraversal(); iter->GoToNextItem()) { - slice->GetCellData()->RemoveArray(IdsArrayName); + vtkPolyData* slice = vtkPolyData::SafeDownCast(iter->GetCurrentDataObject()); + if (slice) + { + slice->GetCellData()->RemoveArray(IdsArrayName); + } } } + else + { + std::cerr << "Unhandled object type: " << output->GetClassName() << std::endl; + } } //----------------------------------------------------------------------------- @@ -293,3 +313,23 @@ void vtkStaticPlaneCutter::PrintSelf(ostream& os, vtkIndent indent) os << indent << "Input Mesh Time: " << this->InputMeshTime << endl; os << indent << "Filter mTime: " << this->FilterMTime << endl; } + +//---------------------------------------------------------------------------- +void vtkStaticPlaneCutter::SetOutputFromCache(vtkDataObject* output) +{ + if (auto pd = vtkPolyData::SafeDownCast(output)) + { + assert(this->Cache->GetNumberOfPieces() == 1); + auto p0 = vtkPolyData::SafeDownCast(this->Cache->GetPartition(0)); + assert(p0); + pd->ShallowCopy(p0); + } + else if (auto mb = vtkMultiPieceDataSet::SafeDownCast(output)) + { + mb->ShallowCopy(this->Cache); + } + else + { + vtkErrorMacro("Unhandled output type: " << output->GetClassName()); + } +} diff --git a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.h b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.h index ba836c44..5dc34977 100644 --- a/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.h +++ b/src/Plugins/StaticMesh/plugin/StaticMeshModule/vtkStaticPlaneCutter.h @@ -34,12 +34,12 @@ #include #include #include -#include #include #include "StaticMeshModuleModule.h" +class vtkUnstructuredGrid; class vtkMultiPieceDataSet; class STATICMESHMODULE_EXPORT vtkStaticPlaneCutter : public vtkPlaneCutter @@ -66,7 +66,7 @@ protected: /** * Remove an Ids cell array in all polydata pieces of output */ - static void RemoveIdsArray(vtkMultiPieceDataSet* output); + static void RemoveIdsArray(vtkDataObject* output); /** * Update cache point, cell and field data using input @@ -78,6 +78,11 @@ protected: */ void ComputeIds(vtkUnstructuredGrid* input); + /** + * Fill the output using the Cache, depending on its type + */ + void SetOutputFromCache(vtkDataObject* output); + private: // Hide these from the user and the compiler. vtkStaticPlaneCutter(const vtkStaticPlaneCutter&) = delete;