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

Aashish Chaudhary aashish.chaudhary at kitware.com
Fri May 2 12:05:15 EDT 2014


CBC.        —
Sent from Mailbox

On Fri, May 2, 2014 at 8:52 AM, Cory Quammen <cory.quammen at kitware.com>
wrote:

> David,
> Thanks for your reply :-)
> As for determining the active scalars (vectors, etc) on the output,
> one thing that might make sense would be to set the active scalars to
> an output array only if the input arrays being appended are designated
> the active scalars in their respective inputs, e.g. if "A" is the
> active scalar in input 1 and input 2, set "A" as the active scalar in
> the output. If "A" is active in input 1 and "B" is active in input 2,
> then don't set an active scalar in the output. How does that sound?
> Thanks,
> Cory
> On Fri, Apr 25, 2014 at 12:47 PM, David Thompson
> <david.thompson at kitware.com> wrote:
>> 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
>>>
>>
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20140502/5c253c8f/attachment-0002.html>


More information about the vtk-developers mailing list