Skip to content

Fix potential warning in AverageByKey

Kenneth Moreland requested to merge kmorel/vtk-m:average-by-key-warning into master

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(), 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.

Merge request reports