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
|
|
|
|
|
|
|
#include <vtkm/filter/internal/ResolveFieldTypeAndExecute.h>
|
|
|
|
|
|
|
|
#include <vtkm/cont/Error.h>
|
2017-01-09 21:15:32 +00:00
|
|
|
#include <vtkm/cont/ErrorBadAllocation.h>
|
2016-01-19 14:59:31 +00:00
|
|
|
#include <vtkm/cont/ErrorExecution.h>
|
|
|
|
|
|
|
|
#include <vtkm/cont/cuda/DeviceAdapterCuda.h>
|
|
|
|
#include <vtkm/cont/tbb/DeviceAdapterTBB.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2017-02-23 16:54:41 +00:00
|
|
|
//----------------------------------------------------------------------------
|
2018-03-02 20:49:07 +00:00
|
|
|
template <typename Derived>
|
2017-05-18 14:29:41 +00:00
|
|
|
inline VTKM_CONT FilterField<Derived>::FilterField()
|
2018-03-02 20:49:07 +00:00
|
|
|
: OutputFieldName()
|
|
|
|
, CoordinateSystemIndex(0)
|
|
|
|
, ActiveFieldName()
|
2022-03-17 17:02:37 +00:00
|
|
|
, ActiveFieldAssociation(vtkm::cont::Field::Association::Any)
|
2018-03-02 20:49:07 +00:00
|
|
|
, UseCoordinateSystemAsField(false)
|
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 FilterField<Derived>::~FilterField()
|
2016-01-19 14:59:31 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-06-01 03:16:12 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2017-08-03 17:35:42 +00:00
|
|
|
template <typename Derived>
|
2018-03-02 20:49:07 +00:00
|
|
|
template <typename DerivedPolicy>
|
2019-09-09 13:39:23 +00:00
|
|
|
VTKM_CONT vtkm::cont::DataSet FilterField<Derived>::PrepareForExecution(
|
2018-04-02 21:58:21 +00:00
|
|
|
const vtkm::cont::DataSet& input,
|
2019-09-17 12:04:59 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
2017-06-01 03:16:12 +00:00
|
|
|
{
|
2018-03-02 20:49:07 +00:00
|
|
|
if (this->UseCoordinateSystemAsField)
|
2017-08-02 19:34:34 +00:00
|
|
|
{
|
2018-03-02 20:49:07 +00:00
|
|
|
// we need to state that the field is actually a coordinate system, so that
|
|
|
|
// the filter uses the proper policy to convert the types.
|
|
|
|
return this->PrepareForExecution(
|
|
|
|
input, input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()), policy);
|
2017-06-01 03:16:12 +00:00
|
|
|
}
|
2018-03-02 20:49:07 +00:00
|
|
|
else
|
2017-08-18 20:28:33 +00:00
|
|
|
{
|
2018-03-02 20:49:07 +00:00
|
|
|
return this->PrepareForExecution(
|
|
|
|
input, input.GetField(this->GetActiveFieldName(), this->GetActiveFieldAssociation()), policy);
|
2017-08-18 20:28:33 +00:00
|
|
|
}
|
2016-01-19 14:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename Derived>
|
|
|
|
template <typename DerivedPolicy>
|
2019-09-09 13:39:23 +00:00
|
|
|
VTKM_CONT vtkm::cont::DataSet FilterField<Derived>::PrepareForExecution(
|
2018-04-02 21:58:21 +00:00
|
|
|
const vtkm::cont::DataSet& input,
|
|
|
|
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
|
|
|
{
|
2016-03-22 16:27:45 +00:00
|
|
|
vtkm::filter::FieldMetadata metaData(field);
|
2018-04-02 21:58:21 +00:00
|
|
|
vtkm::cont::DataSet result;
|
2016-03-22 16:27:45 +00:00
|
|
|
|
2017-11-09 18:47:45 +00:00
|
|
|
vtkm::cont::CastAndCall(
|
2019-09-09 22:08:11 +00:00
|
|
|
vtkm::filter::ApplyPolicyFieldActive(field, policy, vtkm::filter::FilterTraits<Derived>()),
|
2018-08-30 15:53:18 +00:00
|
|
|
internal::ResolveFieldTypeAndExecute(),
|
|
|
|
static_cast<Derived*>(this),
|
|
|
|
input,
|
|
|
|
metaData,
|
|
|
|
policy,
|
|
|
|
result);
|
2016-01-19 14:59:31 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename Derived>
|
|
|
|
template <typename DerivedPolicy>
|
2019-09-09 13:39:23 +00:00
|
|
|
VTKM_CONT vtkm::cont::DataSet FilterField<Derived>::PrepareForExecution(
|
2018-04-02 21:58:21 +00:00
|
|
|
const vtkm::cont::DataSet& input,
|
|
|
|
const vtkm::cont::CoordinateSystem& field,
|
2019-09-17 12:04:59 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
2016-01-19 14:59:31 +00:00
|
|
|
{
|
|
|
|
//We have a special signature just for CoordinateSystem, so that we can ask
|
|
|
|
//the policy for the storage types and value types just for coordinate systems
|
2016-03-22 16:27:45 +00:00
|
|
|
vtkm::filter::FieldMetadata metaData(field);
|
2018-04-02 21:58:21 +00:00
|
|
|
vtkm::cont::DataSet result;
|
2016-03-22 16:27:45 +00:00
|
|
|
|
2018-03-02 20:49:07 +00:00
|
|
|
using Traits = vtkm::filter::FilterTraits<Derived>;
|
2019-07-31 16:20:38 +00:00
|
|
|
constexpr bool supportsVec3 =
|
2019-12-05 02:17:19 +00:00
|
|
|
vtkm::ListHas<typename Traits::InputFieldTypeList, vtkm::Vec3f>::value;
|
2018-03-02 20:49:07 +00:00
|
|
|
|
|
|
|
using supportsCoordinateSystem = std::integral_constant<bool, supportsVec3>;
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::cont::ConditionalCastAndCall(supportsCoordinateSystem(),
|
|
|
|
field,
|
|
|
|
internal::ResolveFieldTypeAndExecute(),
|
|
|
|
static_cast<Derived*>(this),
|
|
|
|
input,
|
|
|
|
metaData,
|
|
|
|
policy,
|
|
|
|
result);
|
2017-05-18 14:29:41 +00:00
|
|
|
|
2016-01-19 14:59:31 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|