vtk-m2/vtkm/filter/FilterDataSet.hxx

71 lines
2.4 KiB
C++
Raw Normal View History

2016-01-19 14:59:31 +00:00
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
2019-04-15 23:24:21 +00:00
//
2016-01-19 14:59:31 +00:00
// 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/filter/FieldMetadata.h>
#include <vtkm/filter/FilterTraits.h>
#include <vtkm/filter/PolicyDefault.h>
2016-01-19 14:59:31 +00:00
#include <vtkm/filter/internal/ResolveFieldTypeAndExecute.h>
#include <vtkm/filter/internal/ResolveFieldTypeAndMap.h>
2017-05-18 14:29:41 +00:00
namespace vtkm
{
namespace filter
{
2016-01-19 14:59:31 +00:00
//----------------------------------------------------------------------------
template <typename Derived>
2017-05-18 14:29:41 +00:00
inline VTKM_CONT FilterDataSet<Derived>::FilterDataSet()
: CellSetIndex(0)
2017-05-18 14:29:41 +00:00
, CoordinateSystemIndex(0)
{
}
//----------------------------------------------------------------------------
2017-05-18 14:29:41 +00:00
template <typename Derived>
inline VTKM_CONT FilterDataSet<Derived>::~FilterDataSet()
2016-01-19 14:59:31 +00:00
{
}
//-----------------------------------------------------------------------------
2017-05-18 14:29:41 +00:00
template <typename Derived>
template <typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet FilterDataSet<Derived>::PrepareForExecution(
const vtkm::cont::DataSet& input,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
{
return (static_cast<Derived*>(this))->DoExecute(input, policy);
2016-01-19 14:59:31 +00:00
}
//-----------------------------------------------------------------------------
2017-05-18 14:29:41 +00:00
template <typename Derived>
template <typename DerivedPolicy>
inline VTKM_CONT bool FilterDataSet<Derived>::MapFieldOntoOutput(
vtkm::cont::DataSet& result,
const vtkm::cont::Field& field,
2017-05-18 14:29:41 +00:00
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
2016-01-19 14:59:31 +00:00
{
bool valid = false;
vtkm::filter::FieldMetadata metaData(field);
using FunctorType = internal::ResolveFieldTypeAndMap<Derived, DerivedPolicy>;
FunctorType functor(static_cast<Derived*>(this), result, metaData, policy, valid);
using Traits = vtkm::filter::FilterTraits<Derived>;
vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicy(field, policy, Traits()), functor);
2016-01-19 14:59:31 +00:00
//the bool valid will be modified by the map algorithm to hold if the
//mapping occurred or not. If the mapping was good a new field has been
//added to the result that was passed in.
2016-01-19 14:59:31 +00:00
return valid;
}
}
}