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>
|
2016-05-05 18:42:46 +00:00
|
|
|
#include <vtkm/filter/PolicyDefault.h>
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2021-08-31 20:24:50 +00:00
|
|
|
#include <vtkm/cont/ErrorBadType.h>
|
|
|
|
#include <vtkm/cont/Logging.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
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2018-03-02 20:49:07 +00:00
|
|
|
template <typename Derived>
|
2017-05-18 14:29:41 +00:00
|
|
|
inline VTKM_CONT FilterDataSet<Derived>::FilterDataSet()
|
2019-08-13 17:08:54 +00:00
|
|
|
: CoordinateSystemIndex(0)
|
2017-02-23 16:54:41 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename Derived>
|
2018-03-02 20:49:07 +00:00
|
|
|
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>
|
2018-04-02 21:58:21 +00:00
|
|
|
inline VTKM_CONT vtkm::cont::DataSet FilterDataSet<Derived>::PrepareForExecution(
|
|
|
|
const vtkm::cont::DataSet& input,
|
2019-09-17 12:04:59 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
2016-08-17 20:13:51 +00:00
|
|
|
{
|
2018-08-30 15:53:18 +00:00
|
|
|
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(
|
2018-04-02 21:58:21 +00:00
|
|
|
vtkm::cont::DataSet& result,
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::Field& field,
|
2019-09-17 12:04:59 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
2016-01-19 14:59:31 +00:00
|
|
|
{
|
|
|
|
bool valid = false;
|
|
|
|
|
2018-04-02 21:58:21 +00:00
|
|
|
vtkm::filter::FieldMetadata metaData(field);
|
|
|
|
using FunctorType = internal::ResolveFieldTypeAndMap<Derived, DerivedPolicy>;
|
|
|
|
FunctorType functor(static_cast<Derived*>(this), result, metaData, policy, valid);
|
|
|
|
|
2021-08-31 20:24:50 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicyFieldNotActive(field, policy), functor);
|
|
|
|
}
|
|
|
|
catch (vtkm::cont::ErrorBadType& error)
|
|
|
|
{
|
|
|
|
VTKM_LOG_S(vtkm::cont::LogLevel::Warn,
|
|
|
|
"Failed to map field " << field.GetName()
|
|
|
|
<< " because it is an unknown type. Cast error:\n"
|
|
|
|
<< error.GetMessage());
|
2021-09-17 11:34:26 +00:00
|
|
|
(void)error; // Suppress unused error message if logging is turned off.
|
2021-08-31 20:24:50 +00:00
|
|
|
}
|
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
|
2018-04-02 21:58:21 +00:00
|
|
|
//added to the result that was passed in.
|
2016-01-19 14:59:31 +00:00
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|