Merge topic 'enSightPointCacheFix'

a9a798e98f review: deep copy in temporal cache + refactor
fb8b3ca98f add(test): non regression test EnSight6 + TemporalCache interaction
93c33b98df add(changelog): document change in EnSight reader
49a228c0f9 improve(TempCache): make temporal cache use recursive copy for CDS
c7122c5faf fix(ensight): renew internal ensight point cache to avoid shadowing

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9552
HTGUnlimitedGradien
Julien Fausty 2 months ago committed by Kitware Robot
commit 7d195d990d
  1. 9
      Documentation/release/dev/fix-PointCacheEnSight.md
  2. 9
      Filters/Hybrid/vtkTemporalDataSetCache.cxx
  3. 1
      IO/EnSight/Testing/CMakeLists.txt
  4. 1
      IO/EnSight/Testing/Python/CMakeLists.txt
  5. 41
      IO/EnSight/Testing/Python/EnSight6TemporalGeometryChange.py
  6. 30
      IO/EnSight/vtkEnSight6BinaryReader.cxx
  7. 5
      IO/EnSight/vtkEnSight6BinaryReader.h
  8. 32
      IO/EnSight/vtkEnSight6Reader.cxx
  9. 5
      IO/EnSight/vtkEnSight6Reader.h
  10. 1
      Testing/Data/EnSight/.EnsightData_temporalCache/streamlines___format0000_GEO00001.sha512
  11. 1
      Testing/Data/EnSight/.EnsightData_temporalCache/streamlines___format0000_GEO00002.sha512
  12. 1
      Testing/Data/EnSight/.EnsightData_temporalCache/streamlines___format0000_GEO00003.sha512
  13. 1
      Testing/Data/EnSight/.EnsightData_temporalCache/streamlines___format0000_GlobalPointID00001.sha512
  14. 1
      Testing/Data/EnSight/.EnsightData_temporalCache/streamlines___format0000_GlobalPointID00002.sha512
  15. 1
      Testing/Data/EnSight/.EnsightData_temporalCache/streamlines___format0000_GlobalPointID00003.sha512
  16. 1
      Testing/Data/EnSight/temporalCache.case.sha512

@ -0,0 +1,9 @@
# Make temporal cache deep copy by default
Previously, the `vtkTemporalDataSetCache` filter had trouble dealing with changes to data upstream
of the pipeline. For example, the EnSight 6 readers' point caches were always reallocated in place.
This interferes with things that might store pointers to certain data downstream (like the temporal
cache).
This fix makes the temporal cache deep copy data by default. It also makes the EnSight6 readers more
robust by renewing the internal point cache every time the points are read from the file.

@ -503,14 +503,7 @@ void vtkTemporalDataSetCache::ReplaceCacheItem(
}
else
{
if (this->GetCacheInMemkind())
{
cachedData->DeepCopy(input);
}
else
{
cachedData->ShallowCopy(input);
}
cachedData->DeepCopy(input);
}
this->Cache[inTime] = std::pair<unsigned long, vtkDataObject*>(outputUpdateTime, cachedData);
}

@ -4,6 +4,7 @@ if (VTK_WRAP_PYTHON)
Data/EnSight/UndefAndPartial/,REGEX:.*
Data/EnSight/UndefAndPartialAscii/,REGEX:.*
Data/EnSight/particles/,REGEX:.*
Data/EnSight/.EnsightData_temporalCache/,REGEX:.*
)
add_subdirectory(Python)

@ -2,6 +2,7 @@ vtk_add_test_python(
EnSight6Elements.py
EnSight6ElementsBin.py
EnSight6OfficeBin.py
EnSight6TemporalGeometryChange.py,NO_VALID
EnSightBlow1ASCII.py
EnSightBlow1Bin.py
EnSightBlow2ASCII.py

@ -0,0 +1,41 @@
#!/usr/bin/env python
import vtk
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# create a rendering window and renderer
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
reader = vtk.vtkGenericEnSightReader()
reader.SetCaseFileName("" + str(VTK_DATA_ROOT) + "/Data/EnSight/temporalCache.case")
tCache = vtk.vtkTemporalDataSetCache()
tCache.SetInputConnection(reader.GetOutputPort())
tCache.SetCacheSize(3)
# populate cache
tCache.UpdateTimeStep(0.0000)
tCache.UpdateTimeStep(0.010002)
tCache.UpdateTimeStep(0.020032)
# read through cache again
tCache.UpdateTimeStep(0.0000)
tCache.UpdateTimeStep(0.010002) # used to crash here
sphere = vtk.vtkSphereSource()
sphere.SetRadius(0.001)
mapper = vtk.vtkGlyph3DMapper()
mapper.SetInputConnection(tCache.GetOutputPort())
mapper.SetSourceConnection(sphere.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
ren1.AddActor(actor)
ren1.ResetCamera()
iren.Initialize()
renWin.Render()
# Leaks without this line
reader.SetDefaultExecutivePrototype(None)

@ -57,7 +57,7 @@ vtkStandardNewMacro(vtkEnSight6BinaryReader);
vtkEnSight6BinaryReader::vtkEnSight6BinaryReader()
{
this->NumberOfUnstructuredPoints = 0;
this->UnstructuredPoints = vtkPoints::New();
this->UnstructuredPoints = nullptr;
this->UnstructuredNodeIds = nullptr;
this->BinaryIFile = nullptr;
@ -70,13 +70,7 @@ vtkEnSight6BinaryReader::vtkEnSight6BinaryReader()
//------------------------------------------------------------------------------
vtkEnSight6BinaryReader::~vtkEnSight6BinaryReader()
{
if (this->UnstructuredNodeIds)
{
this->UnstructuredNodeIds->Delete();
this->UnstructuredNodeIds = nullptr;
}
this->UnstructuredPoints->Delete();
this->UnstructuredPoints = nullptr;
this->CleanUpCache();
if (this->BinaryIFile)
{
@ -194,6 +188,8 @@ int vtkEnSight6BinaryReader::ReadGeometryFile(
this->ReadLine(line);
this->ReadLine(line);
this->CleanUpCache();
// Read the node id and element id lines.
this->ReadLine(line); // node id *
sscanf(line, " %*s %*s %s", subLine);
@ -231,6 +227,7 @@ int vtkEnSight6BinaryReader::ReadGeometryFile(
return 0;
}
this->UnstructuredPoints = vtkPoints::New();
this->UnstructuredPoints->SetNumberOfPoints(this->NumberOfUnstructuredPoints);
if (pointIdsListed)
@ -2851,4 +2848,21 @@ void vtkEnSight6BinaryReader::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
//------------------------------------------------------------------------------
void vtkEnSight6BinaryReader::CleanUpCache()
{
if (this->UnstructuredPoints)
{
this->NumberOfUnstructuredPoints = 0;
this->UnstructuredPoints->Delete();
this->UnstructuredPoints = nullptr;
}
if (this->UnstructuredNodeIds)
{
this->UnstructuredNodeIds->Delete();
this->UnstructuredNodeIds = nullptr;
}
}
VTK_ABI_NAMESPACE_END

@ -177,6 +177,11 @@ protected:
int SkipUnstructuredGrid(char line[256]);
///@}
/**
* Clean up the internal cached data
*/
virtual void CleanUpCache();
// global list of points for the unstructured parts of the model
int NumberOfUnstructuredPoints;
vtkPoints* UnstructuredPoints;

@ -40,20 +40,14 @@ vtkStandardNewMacro(vtkEnSight6Reader);
vtkEnSight6Reader::vtkEnSight6Reader()
{
this->NumberOfUnstructuredPoints = 0;
this->UnstructuredPoints = vtkPoints::New();
this->UnstructuredPoints = nullptr;
this->UnstructuredNodeIds = nullptr;
}
//------------------------------------------------------------------------------
vtkEnSight6Reader::~vtkEnSight6Reader()
{
if (this->UnstructuredNodeIds)
{
this->UnstructuredNodeIds->Delete();
this->UnstructuredNodeIds = nullptr;
}
this->UnstructuredPoints->Delete();
this->UnstructuredPoints = nullptr;
this->CleanUpCache();
}
//------------------------------------------------------------------------------
@ -244,6 +238,8 @@ int vtkEnSight6Reader::ReadGeometryFile(
// ReadNextDataLine because the description line could be blank.
this->ReadLine(line);
this->CleanUpCache();
// Read the node id and element id lines.
this->ReadLine(line);
sscanf(line, " %*s %*s %s", subLine);
@ -265,8 +261,11 @@ int vtkEnSight6Reader::ReadGeometryFile(
this->ReadNextDataLine(line); // "coordinates"
this->ReadNextDataLine(line);
this->NumberOfUnstructuredPoints = atoi(line);
this->UnstructuredPoints = vtkPoints::New();
this->UnstructuredPoints->Allocate(this->NumberOfUnstructuredPoints);
int* tmpIds = new int[this->NumberOfUnstructuredPoints];
int maxId = 0;
@ -2195,4 +2194,21 @@ void vtkEnSight6Reader::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
//------------------------------------------------------------------------------
void vtkEnSight6Reader::CleanUpCache()
{
if (this->UnstructuredPoints)
{
this->NumberOfUnstructuredPoints = 0;
this->UnstructuredPoints->Delete();
this->UnstructuredPoints = nullptr;
}
if (this->UnstructuredNodeIds)
{
this->UnstructuredNodeIds->Delete();
this->UnstructuredNodeIds = nullptr;
}
}
VTK_ABI_NAMESPACE_END

@ -140,6 +140,11 @@ protected:
int CreateStructuredGridOutput(
int partId, char line[256], const char* name, vtkMultiBlockDataSet* output) override;
/**
* Clean up the internal cached data
*/
virtual void CleanUpCache();
// global list of points for the unstructured parts of the model
int NumberOfUnstructuredPoints;
vtkPoints* UnstructuredPoints;

@ -0,0 +1 @@
ba78de025f5bdb2ba5b9b36f93455dd578a15d00dffe3080f983a86a7a5d5889a6554f83c740b95f223b411846928643d808e9576268d0f6c8698266848051c8

@ -0,0 +1 @@
577608f42947f98410e6eae9e2698734bbfde827dad3fc208a63b72570eaca16ad16f03c25d5a066e0f7ce7f3a231088e690ead77aabe939f1b801c31d129e45

@ -0,0 +1 @@
8d60c9f1c159409cea1b10b276818d40af016b4bba08aed24eb6d6c64b6d9efde7015dabb36d60fb4ced062dec8438a3395bbf2c86dea380b271a5c7964aac85

@ -0,0 +1 @@
5ea6d6f376967214fe27e85d84a5a6a5b8e479bf6ffe234ced0330569801d002f90ee4ca0b079c524fac95565ebb1bd2abd2009f55491b1c7a239ccbe1a09cb8

@ -0,0 +1 @@
76188151611dce13fc6140e41cda7ce503bed34a132d7b27b0244d86daa0247b6a13f4f042d406cff3c02fc97c0496836111751b28afde3c793057da84abd58c

@ -0,0 +1 @@
94c46636af765c1481cedf583436517e2229436a32842c17de0d050450135c5e3440d014401b8bd2a8bdf694a246a5c312c13277b5ae90d5d42ca489a3390eab

@ -0,0 +1 @@
049701c01d8426c313bb4e6d6ecd2610d0a8b210fdd1c6ddf6a0b00c436a4ddf2f2b46dd58199e9c57d2b364f8cbbc64f178de9e7997f4152dbf7a4e44efdaac
Loading…
Cancel
Save