From 1e9eac11500b814fbb7d268e5e6f8f02e01841bf Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Thu, 4 Apr 2019 07:39:42 +0200 Subject: [PATCH] [bos #16777] [CEA] generateVectors makes SALOME crash --- src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx | 12 ++++++++++++ src/Plugins/MEDReader/IO/vtkGenerateVectors.h | 1 + src/Plugins/MEDReader/IO/vtkMEDReader.cxx | 3 +++ 3 files changed, 16 insertions(+) diff --git a/src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx b/src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx index bb194a7d..510071ac 100644 --- a/src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx +++ b/src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx @@ -22,6 +22,7 @@ #include "vtkDataArrayTemplate.h" #include "vtkDoubleArray.h" #include "vtkInformation.h" +#include "vtkUnstructuredGrid.h" #include "vtkQuadratureSchemeDefinition.h" #include "vtkInformationQuadratureSchemeDefinitionVectorKey.h" #include "MEDUtilities.hxx" @@ -37,6 +38,17 @@ std::string vtkGenerateVectors::SuffixFieldName(const std::string& name) return oss.str(); } +/*! + * This method forces MeshMTime modification. To do so, points are declared as modified. + */ +void vtkGenerateVectors::ChangeMeshTimeToUpdateCache(vtkDataSet *dataset) +{ + vtkUnstructuredGrid *ug(vtkUnstructuredGrid::SafeDownCast(dataset)); + if(!ug) + return ; + ug->GetPoints()->Modified(); +} + void vtkGenerateVectors::Operate(vtkFieldData *fd) { if(!fd) diff --git a/src/Plugins/MEDReader/IO/vtkGenerateVectors.h b/src/Plugins/MEDReader/IO/vtkGenerateVectors.h index 6a069575..e7a45d53 100644 --- a/src/Plugins/MEDReader/IO/vtkGenerateVectors.h +++ b/src/Plugins/MEDReader/IO/vtkGenerateVectors.h @@ -29,6 +29,7 @@ class vtkDoubleArray; class VTK_EXPORT vtkGenerateVectors { public: + static void ChangeMeshTimeToUpdateCache(vtkDataSet *dataset); static void Operate(vtkFieldData *fd); static vtkDoubleArray *Operate2Compo(vtkDoubleArray *oldArr); static vtkDoubleArray *OperateMoreThan3Compo(vtkDoubleArray *oldArr); diff --git a/src/Plugins/MEDReader/IO/vtkMEDReader.cxx b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx index 1309aa92..af8da053 100644 --- a/src/Plugins/MEDReader/IO/vtkMEDReader.cxx +++ b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx @@ -684,6 +684,9 @@ vtkDataSet *vtkMEDReader::RetrieveDataSetAtTime(double reqTS, ExportedTinyInfo * vtkGenerateVectors::Operate(ret->GetPointData()); vtkGenerateVectors::Operate(ret->GetCellData()); vtkGenerateVectors::Operate(ret->GetFieldData()); + // The operations above have potentially created new arrays -> This breaks the optimization of StaticMesh that expects the same field arrays over time. + // To enforce the cache recomputation declare modification of mesh. + vtkGenerateVectors::ChangeMeshTimeToUpdateCache(ret); } return ret; } -- 2.39.2