Calculator gives incorrect results for multiblock datasets
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
The calculator gives incorrect results for multiblock unless the variables have the same index internally. This can be reproduced with the steps below:
- 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