Skip to content
  • Cory Quammen's avatar
    KW00001404: Major overhaul of vtkAppendFilter · 69a06e4d
    Cory Quammen authored
    The previous behavior of vtkAppendFilter was to append data arrays set
    as attributes and then only secondarily append data arrays by
    name. This could lead to unexpected behavior as illustrated in the
    following scenario:
    
    - set two datasets are set as inputs to the filter
    - each dataset has a point array named "A" and another named "B"
    - in the first input, "A" is set as the scalar attribute
    - in the second input, "B" is set as the scalar attribute
    
    Previously, the output of vtkAppendFilter would append the scalar
    attribute array "A" from the first input to the scalar attribute array
    "B" from the second, storing the result in an array named "A" and
    setting that as the scalar attribute in the output dataset. If you
    reversed the order of inputs, the resulting scalar attribute array
    would be named "B" and the output array would have the contents of "B"
    followed by the contents of "A".
    
    This patch changes the behavior of the vtkAppendFilter to merge arrays
    primarily by name, which is more in line with how the rest of VTK
    works. In the scenario above, the "A" arrays from the input are
    appended together and the "B" arrays from the input are appended
    together. Because "A" is set as the scalar attribute in one input and
    "B" is set as the scalar in the other, the inputs disagree on which
    array is the scalar attribute, so in the output no scalar attribute is
    set. More broadly, if both inputs have arrays with the same name,
    number of components, and data type set as an attribute, then the
    result of appending those attribute arrays from the inputs will be set
    as the attribute in the output. If any of those conditions are not
    met, then the attribute will not be set in the output.
    
    A somewhat special case is possible where the scalar attribute in the
    inputs is set to an array with NULL name. If all inputs have their
    scalar attribute set to an array with a NULL name, then the output's
    scalar attribute will be an array that is the result of appending the
    input scalar attribute arrays into a new array with a NULL name.
    
    This patch also contributes a fairly comprehensive test for
    the vtkAppendFilter.
    
    Finally, this patch makes the vtkDataSetAttributes::SetAttribute()
    method public instead of private.
    
    Change-Id: Id3914957b65bfcce346968dc8fba6a3df0861cd8
    69a06e4d