[vtk-developers] Active scalars and the behavior of vtkAppendFilter

David Thompson david.thompson at kitware.com
Fri Apr 25 12:47:48 EDT 2014


Hi Cory,

Congratulations, you've found a bug. :-) I agree that variables should be merged by name, not attribute type. I will be happy to review a patch to fix that.

A little more debatable: which attribute (if any) should be marked as active scalars on the output?

	David

On Apr 25, 2014, at 12:35 PM, Cory Quammen <cory.quammen at kitware.com> wrote:

> Hi all,
> 
> There is some unexpected behavior (to me, anyway) in vtkAppendFilter.
> Say I have two data sets D1 and D2, each of which has two
> single-component scalar arrays named "A" and "B". Assume for
> simplicity that each array has three elements as illustrated below:
> 
> D1:
> "A" = [ 1, 1, 1 ]
> "B" = [ 2, 2, 2 ]
> 
> D2:
> "A" = [ 1, 1, 1 ]
> "B" = [ 2, 2, 2 ]
> 
> I would expect that if I used vtkAppendFilter to merge these two
> datasets that the values from the "A" arrays in each data set would be
> merged into an "A" array in the result, with the same happening for
> the "B" arrays. That is:
> 
> Appended result:
> "A" = [ 1, 1, 1, 1, 1, 1 ]
> "B" = [ 2, 2, 2, 2, 2, 2 ]
> 
> If no "active" scalars are set in the two data sets, then everything
> works as I suspect.
> 
> "A" = [1, 1, 1, 1, 1, 1]
> "B" = [2, 2, 2, 2, 2, 2]
> 
> However, if "A" is set as the active scalar in D1 and "B" is set as
> the active scalar in D2, the result is that the merged array in the
> result with the name "A" has the first half of its values from array
> "A" in D1 and the second half of its values from array "B" in D2. The
> "B" array in the output is all 2s as I would expect.
> 
> "A" = [ 1, 1, 1, 2, 2, 2 ]
> "B" = [ 2, 2, 2, 2, 2, 2 ]
> 
> If you set "B" to be the active scalar in D1 and "A" as the active
> scalar in D2, then the resulting merged array is named "B" and has
> values from D1's "B" array followed by values from D2's "A" array. The
> "A" array in the output is all 1s as I would expected.
> 
> "B" = [ 2, 2, 2, 1, 1, 1 ]
> "A" = [ 1, 1, 1, 1, 1, 1 ]
> 
> If you set "A" to be the active scalars in both datasets, then "A" in
> the output is all 1s and "B" is all 2s as I would expect.
> 
> "A" = [ 1, 1, 1, 1, 1, 1 ]
> "B" = [ 2, 2, 2, 2, 2, 2 ]
> 
> What's happening is that the filter is merging the active scalars from
> all the data sets into an array whose name comes from whichever
> dataset happens to come first. Non-active arrays are merged by name.
> 
> Does this seem like sensible behavior? My guess is that most people
> would expect arrays with the same name to be merged. The concern is
> that some filter upstream may change which array is active, the user
> has no idea that this has happened, and unexpected results occur.
> 
> Sure, you could get merging by name only by setting the active scalar
> to the same array in each input data set for vtkAppendFilter prior to
> updating it, but this is not at all obvious or well documented.
> 
> I've attached a self-contained code sample illustrating the problem.
> 
> Thanks for your thoughts,
> Cory
> <CMakeLists.txt><AppendExample.cxx>_______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
> 




More information about the vtk-developers mailing list