MantisBT - ParaView
View Issue Details
0013088ParaView(No Category)public2012-04-13 10:102012-10-29 17:04
Sebastien Jourdain 
Sebastien Jourdain 
normalminorhave not tried
closedfixed 
 
3.98.0 
TBD
13088-calculator-multi-block-fix
incorrect functionality
0013088: Calculator produce invalid results
The calculator gives incorrect results for multiblock unless the variables have the same index internally. This can be reproduced with the steps below:
 
1. Create a python source that outputs vtkUnstructuredGrid with the following script:

def add_scalar(ds, val):
                arr = vtk.vtkDoubleArray()
                arr.SetName("Scalar"+str(val))
                arr.SetNumberOfComponents(1)
                arr.SetNumberOfTuples(8)
                for i in range(8):
                                arr.SetTuple1(i, float(val))
                output.GetPointData().AddArray(arr)
 
output = self.GetOutput()
npts = 8
pts = vtk.vtkPoints()
pts.InsertNextPoint(-3.0, -1.0, -1.0)
pts.InsertNextPoint(-1.0, -1.0, -1.0)
pts.InsertNextPoint(-1.0, 1.0, -1.0)
pts.InsertNextPoint(-3.0, 1.0, -1.0)
pts.InsertNextPoint(-3.0, -1.0, 1.0)
pts.InsertNextPoint(-1.0, -1.0, 1.0)
pts.InsertNextPoint(-1.0, 1.0, 1.0)
pts.InsertNextPoint(-3.0, 1.0, 1.0)
output.SetPoints(pts)
output.Allocate(1,1)
ids = vtk.vtkIdList()
for i in range(npts):
    ids.InsertId(i,i)
add_scalar(output, 1)
add_scalar(output, 2)
output.InsertNextCell(vtk.VTK_HEXAHEDRON, ids)
2. Create a second python source that outputs vtkUnstructuredGrid with the following script (notice the change in order when adding the scalars):

def add_scalar(ds, val):
                arr = vtk.vtkDoubleArray()
                arr.SetName("Scalar"+str(val))
                arr.SetNumberOfComponents(1)
                arr.SetNumberOfTuples(8)
                for i in range(8):
                                arr.SetTuple1(i, float(val))
                output.GetPointData().AddArray(arr)
 
output = self.GetOutput()
npts = 8
pts = vtk.vtkPoints()
pts.InsertNextPoint(-3.0, -1.0, -1.0)
pts.InsertNextPoint(-1.0, -1.0, -1.0)
pts.InsertNextPoint(-1.0, 1.0, -1.0)
pts.InsertNextPoint(-3.0, 1.0, -1.0)
pts.InsertNextPoint(-3.0, -1.0, 1.0)
pts.InsertNextPoint(-1.0, -1.0, 1.0)
pts.InsertNextPoint(-1.0, 1.0, 1.0)
pts.InsertNextPoint(-3.0, 1.0, 1.0)
output.SetPoints(pts)
output.Allocate(1,1)
ids = vtk.vtkIdList()
for i in range(npts):
    ids.InsertId(i,i)
add_scalar(output, 2)
add_scalar(output, 1)
output.InsertNextCell(vtk.VTK_HEXAHEDRON, ids)
3. Group the two python sources together

4. Use the Calculator filter to pass through Scalar1

 
See output below:
 

 
No tags attached.
has duplicate 0012929closed Sebastien Jourdain Calculator gives incorrect results for multiblock datasets 
png image001.png (29,544) 2012-04-13 10:10
https://www.vtk.org/Bug/file/9154/image001.png
png

zip MultiBlock-ArrayDifferentOrder.zip (2,205) 2012-07-19 16:25
https://www.vtk.org/Bug/file/9233/MultiBlock-ArrayDifferentOrder.zip
Issue History
2012-04-13 10:10Sebastien JourdainNew Issue
2012-04-13 10:10Sebastien JourdainAssigned To => Sebastiennn Jourdain
2012-04-13 10:10Sebastien JourdainFile Added: image001.png
2012-04-13 11:42Sebastien JourdainRelationship addedhas duplicate 0012929
2012-04-17 09:02Sebastien JourdainStatusbacklog => todo
2012-04-17 09:02Sebastien JourdainStatustodo => active development
2012-04-17 11:05Sebastien JourdainNote Added: 0028483
2012-04-17 11:07Sebastien JourdainNote Added: 0028484
2012-04-17 11:09Sebastien JourdainNote Added: 0028485
2012-04-17 11:10Sebastien JourdainStatusactive development => gatekeeper review
2012-04-17 11:10Sebastien JourdainResolutionopen => fixed
2012-04-17 11:16Sebastien JourdainTopic Name => 13088-calculator-fix (On Seb computer...)
2012-04-20 13:50Utkarsh AyachitFixed in Version => git-master
2012-04-20 13:51Utkarsh AyachitStatusgatekeeper review => customer review
2012-04-20 13:51Utkarsh AyachitNote Added: 0028500
2012-05-23 08:02Sebastien JourdainNote Added: 0028637
2012-05-23 08:02Sebastien JourdainStatuscustomer review => active development
2012-05-23 11:30Sebastien JourdainNote Edited: 0028484bug_revision_view_page.php?bugnote_id=28484#r446
2012-05-29 13:30Sebastien JourdainTopic Name13088-calculator-fix (On Seb computer...) => 13088-calculator-multi-block-fix
2012-05-29 13:33Sebastien JourdainStatusactive development => gatekeeper review
2012-06-01 14:41Utkarsh AyachitStatusgatekeeper review => customer review
2012-06-01 14:41Utkarsh AyachitNote Added: 0028669
2012-07-19 16:25Sebastien JourdainFile Added: MultiBlock-ArrayDifferentOrder.zip
2012-07-19 16:27Sebastien JourdainNote Added: 0028873
2012-07-19 16:27Sebastien JourdainStatuscustomer review => closed
2012-10-29 17:04Utkarsh AyachitFixed in Versiongit-master => 3.98.0

Notes
(0028483)
Sebastien Jourdain   
2012-04-17 11:05   
diff --git a/ParaViewCore/VTKExtensions/vtkPVArrayCalculator.cxx b/ParaViewCore/VTKExtensions/vtkPVArrayCalculator.cxx
index 37eec77..9cc728f 100644
--- a/ParaViewCore/VTKExtensions/vtkPVArrayCalculator.cxx
+++ b/ParaViewCore/VTKExtensions/vtkPVArrayCalculator.cxx
@@ -17,6 +17,7 @@
 #include "vtkCellData.h"
 #include "vtkDataObject.h"
 #include "vtkDataSet.h"
+#include "vtkFunctionParser.h"
 #include "vtkGraph.h"
 #include "vtkInformation.h"
 #include "vtkInformationVector.h"
@@ -73,6 +74,9 @@ void vtkPVArrayCalculator::UpdateArrayAndVariableNames
 {
   unsigned long mtime = this->GetMTime();
 
+ // Make sure we reparse the function based on the current array order
+ this->FunctionParser->InvalidateFunction();
+
   // Look at the data-arrays available in the input and register them as
   // variables with the superclass.
   // It's safe to call these methods in RequestData() since they don't call
(0028484)
Sebastien Jourdain   
2012-04-17 11:07   
(edited on: 2012-05-23 11:30)
diff --git a/Common/vtkFunctionParser.cxx b/Common/vtkFunctionParser.cxx
index e955af7..da7f678 100644
--- a/Common/vtkFunctionParser.cxx
+++ b/Common/vtkFunctionParser.cxx
@@ -564,6 +564,12 @@ int vtkFunctionParser::DisambiguateOperators()
 }
 
 //-----------------------------------------------------------------------------
+void vtkFunctionParser::InvalidateFunction()
+{
+ this->FunctionMTime.Modified();
+}
+
+//-----------------------------------------------------------------------------
 bool vtkFunctionParser::Evaluate()
 {
   int numBytesProcessed;
diff --git a/Common/vtkFunctionParser.h b/Common/vtkFunctionParser.h
index f81ff2c..e3c7724 100644
--- a/Common/vtkFunctionParser.h
+++ b/Common/vtkFunctionParser.h
@@ -234,6 +234,10 @@ public:
   // Check the validity of the function expression.
   void CheckExpression(int &pos, char **error);
 
+ // Description:
+ // Allow the user to force the function to be re-parsed
+ void InvalidateFunction();
+
 protected:
   vtkFunctionParser();
   ~vtkFunctionParser();

====> Done (http://review.source.kitware.com/#/t/702/ [^])

(0028485)
Sebastien Jourdain   
2012-04-17 11:09   
Those are the 2 patch needed to fix the issue. Although with the current changes on VTK, we will wait to apply them once VTK/master will be in synch with ParaView/master.

Otherwise user that need it could patch their current sources...
(0028500)
Utkarsh Ayachit   
2012-04-20 13:51   
merged into master, where applicable.
(0028637)
Sebastien Jourdain   
2012-05-23 08:02   
Now that ParaView is using VTK/master, we can apply this patch...
(0028669)
Utkarsh Ayachit   
2012-06-01 14:41   
Merged in master, if applicable.
(0028873)
Sebastien Jourdain   
2012-07-19 16:27   
Tested by loading the multi-block file and apply a calculator computation using on of the array and make sure the result is the same on both block regardless the ordering of the array names that differ for each block...