vtk-m/vtkm/filter/DotProduct.hxx
Robert Maynard 16a6af5857 Some filters had unnecessary DoMapField methods.
The CrossProduct and DotProduct are field filters and therefore
fields are automatically propagated instead of calling DoMapField.

As GhostCellClassify is passing through all fields, it can
override `MapFieldOntoOutput` and skip the deduction of the
Field to an ArrayHandle for better compile time.
2019-09-10 15:26:16 -04:00

56 lines
1.9 KiB
C++

//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/ArrayHandleCast.h>
namespace vtkm
{
namespace filter
{
//-----------------------------------------------------------------------------
inline VTKM_CONT DotProduct::DotProduct()
: vtkm::filter::FilterField<DotProduct>()
, SecondaryFieldName()
, SecondaryFieldAssociation(vtkm::cont::Field::Association::ANY)
, UseCoordinateSystemAsSecondaryField(false)
, SecondaryCoordinateSystemIndex(0)
{
this->SetOutputFieldName("dotproduct");
}
//-----------------------------------------------------------------------------
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet DotProduct::DoExecute(
const vtkm::cont::DataSet& inDataSet,
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& primary,
const vtkm::filter::FieldMetadata& fieldMetadata,
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
vtkm::cont::Field secondaryField;
if (this->UseCoordinateSystemAsSecondaryField)
{
secondaryField = inDataSet.GetCoordinateSystem(this->GetSecondaryCoordinateSystemIndex());
}
else
{
secondaryField = inDataSet.GetField(this->SecondaryFieldName, this->SecondaryFieldAssociation);
}
auto secondary =
vtkm::filter::ApplyPolicyFieldOfType<vtkm::Vec<T, 3>>(secondaryField, policy, *this);
vtkm::cont::ArrayHandle<T> output;
this->Invoke(vtkm::worklet::DotProduct{}, primary, secondary, output);
return CreateResult(inDataSet, output, this->GetOutputFieldName(), fieldMetadata);
}
}
} // namespace vtkm::filter