Skip to content
  • Kenneth Moreland's avatar
    Fix potential warning in AverageByKey · 6ebc3ea7
    Kenneth Moreland authored
    To get the average, we (of course) divide the sum by the amount of
    values, which is returned from valuesIn.GetNumberOfComponents(). To do
    this, we need to cast the number of components (returned as a
    vtkm::IdComponent) to a FieldType. This is a little more complex than it
    first seems because FieldType might be a Vec type. If you just try a
    static_cast<FieldType>(), it will use the constructor to FieldType which
    might be a Vec constructor expecting the type of the component. This in
    turn could cause a warning because the vtkm::IdComponent is implicitly
    converted to the Vec's component type.
    
    Get around this problem by first casting to the component type of the
    field and then constructing a field value from that.
    6ebc3ea7