From eb3b0379c3327a988e6ee830d32811080fd9bf21 Mon Sep 17 00:00:00 2001
From: Yvan Fournier <yvan.fournier@edf.fr>
Date: Sun, 13 Sep 2015 15:34:46 +0200
Subject: [PATCH] Fix for bug 0010637 (EnSight symmetric tensor components XZ
 and YZ are interchanged).

---
 .../Default/vtkPEnSightGoldBinaryReader.cxx             |  6 +++---
 .../VTKExtensions/Default/vtkPEnSightGoldReader.cxx     | 17 +++++++++++------
 VTK                                                     |  2 +-
 3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/ParaViewCore/VTKExtensions/Default/vtkPEnSightGoldBinaryReader.cxx b/ParaViewCore/VTKExtensions/Default/vtkPEnSightGoldBinaryReader.cxx
index 2781071..8d60782 100644
--- a/ParaViewCore/VTKExtensions/Default/vtkPEnSightGoldBinaryReader.cxx
+++ b/ParaViewCore/VTKExtensions/Default/vtkPEnSightGoldBinaryReader.cxx
@@ -1893,8 +1893,8 @@ int vtkPEnSightGoldBinaryReader::ReadTensorsPerNode(
       this->ReadFloatArray(comp2, numPts);
       this->ReadFloatArray(comp3, numPts);
       this->ReadFloatArray(comp4, numPts);
-      this->ReadFloatArray(comp5, numPts);
       this->ReadFloatArray(comp6, numPts);
+      this->ReadFloatArray(comp5, numPts);
       for (i = 0; i < numPts; i++)
         {
         tuple[0] = comp1[i];
@@ -2607,8 +2607,8 @@ int vtkPEnSightGoldBinaryReader::ReadTensorsPerElement(
         this->ReadFloatArray(comp2, numCells);
         this->ReadFloatArray(comp3, numCells);
         this->ReadFloatArray(comp4, numCells);
-        this->ReadFloatArray(comp5, numCells);
         this->ReadFloatArray(comp6, numCells);
+        this->ReadFloatArray(comp5, numCells);
         for (i = 0; i < numCells; i++)
           {
           tuple[0] = comp1[i];
@@ -2662,8 +2662,8 @@ int vtkPEnSightGoldBinaryReader::ReadTensorsPerElement(
           this->ReadFloatArray(comp2, numCellsPerElement);
           this->ReadFloatArray(comp3, numCellsPerElement);
           this->ReadFloatArray(comp4, numCellsPerElement);
-          this->ReadFloatArray(comp5, numCellsPerElement);
           this->ReadFloatArray(comp6, numCellsPerElement);
+          this->ReadFloatArray(comp5, numCellsPerElement);
           for (i = 0; i < numCellsPerElement; i++)
             {
             tuple[0] = comp1[i];
diff --git a/ParaViewCore/VTKExtensions/Default/vtkPEnSightGoldReader.cxx b/ParaViewCore/VTKExtensions/Default/vtkPEnSightGoldReader.cxx
index 302340d..0d6b019 100644
--- a/ParaViewCore/VTKExtensions/Default/vtkPEnSightGoldReader.cxx
+++ b/ParaViewCore/VTKExtensions/Default/vtkPEnSightGoldReader.cxx
@@ -841,6 +841,7 @@ int vtkPEnSightGoldReader::ReadTensorsPerNode(const char* fileName, const char*
                                                int timeStep, vtkMultiBlockDataSet *compositeOutput)
 {
   char line[256];
+  int symmTensorOrder[6] = {0, 1, 2, 3, 5, 4};
   int partId, realId, numPts, i, j;
   vtkFloatArray *tensors;
   vtkDataSet *output;
@@ -946,7 +947,8 @@ int vtkPEnSightGoldReader::ReadTensorsPerNode(const char* fileName, const char*
           //tensors->InsertComponent(j, i, atof(line));
           // Same behaviour as Vector Per Node variables: we inject data as component,
           // and not as tuple.
-          this->InsertVariableComponent(tensors, j, i, &val, realId, 0, SCALAR_PER_NODE);
+          this->InsertVariableComponent(tensors, j, symmTensorOrder[i],
+                                        &val, realId, 0, SCALAR_PER_NODE);
           }
         }
       tensors->SetName(description);
@@ -1344,11 +1346,12 @@ int vtkPEnSightGoldReader::ReadVectorsPerElement(const char* fileName,
 
 //----------------------------------------------------------------------------
 int vtkPEnSightGoldReader::ReadTensorsPerElement(const char* fileName,
-                                                  const char* description,
-                                                  int timeStep,
-                                                  vtkMultiBlockDataSet *compositeOutput)
+                                                 const char* description,
+                                                 int timeStep,
+                                                 vtkMultiBlockDataSet *compositeOutput)
 {
   char line[256];
+  int symmTensorOrder[6] = {0, 1, 2, 3, 5, 4};
   int partId, realId, numCells, numCellsPerElement, i, j, idx;
   vtkFloatArray *tensors;
   int lineRead, elementType;
@@ -1458,7 +1461,8 @@ int vtkPEnSightGoldReader::ReadTensorsPerElement(const char* fileName,
             this->ReadNextDataLine(line);
             value = atof(line);
             //tensors->InsertComponent(j, i, value);
-            this->InsertVariableComponent(tensors,j,i,&value,realId,0,SCALAR_PER_ELEMENT);
+            this->InsertVariableComponent(tensors,j,symmTensorOrder[i],
+                                          &value,realId,0,SCALAR_PER_ELEMENT);
             }
           }
         lineRead = this->ReadNextDataLine(line);
@@ -1488,7 +1492,8 @@ int vtkPEnSightGoldReader::ReadTensorsPerElement(const char* fileName,
               value = atof(line);
               //tensors->InsertComponent(this->GetCellIds(idx, elementType)->GetId(j),
               //                         i, value);
-              this->InsertVariableComponent(tensors, j, i, &value, idx, elementType, SCALAR_PER_ELEMENT);
+              this->InsertVariableComponent(tensors, j, symmTensorOrder[i],
+                                            &value, idx, elementType, SCALAR_PER_ELEMENT);
               }
             }
           lineRead = this->ReadNextDataLine(line);
diff --git a/VTK b/VTK
index 97cc876..78fd1f9 160000
--- a/VTK
+++ b/VTK
@@ -1 +1 @@
-Subproject commit 97cc8760d4019e8ba12cef50df8b011df4dc6510
+Subproject commit 78fd1f911c30dcd1eb66fa87217172feb4fc9204
-- 
2.5.1

