2018-01-09 19:01:43 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2018-01-09 19:01:43 +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.
|
|
|
|
//============================================================================
|
2019-10-07 19:39:02 +00:00
|
|
|
#ifndef vtk_m_filter_Probe_hxx
|
|
|
|
#define vtk_m_filter_Probe_hxx
|
2018-01-09 19:01:43 +00:00
|
|
|
|
2020-02-06 21:58:59 +00:00
|
|
|
#include <vtkm/filter/Probe.h>
|
|
|
|
|
|
|
|
#include <vtkm/filter/MapFieldPermutation.h>
|
|
|
|
|
2020-06-03 21:24:36 +00:00
|
|
|
#include <vtkm/cont/internal/CastInvalidValue.h>
|
|
|
|
|
2018-01-09 19:01:43 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
inline void Probe::SetGeometry(const vtkm::cont::DataSet& geometry)
|
|
|
|
{
|
|
|
|
this->Geometry = vtkm::cont::DataSet();
|
2019-08-13 17:08:54 +00:00
|
|
|
this->Geometry.SetCellSet(geometry.GetCellSet());
|
2018-01-09 19:01:43 +00:00
|
|
|
this->Geometry.AddCoordinateSystem(geometry.GetCoordinateSystem());
|
|
|
|
}
|
|
|
|
|
2020-06-03 21:24:36 +00:00
|
|
|
VTKM_CONT
|
|
|
|
inline const vtkm::cont::DataSet& Probe::GetGeometry() const
|
|
|
|
{
|
|
|
|
return this->Geometry;
|
|
|
|
}
|
|
|
|
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename DerivedPolicy>
|
2018-04-02 21:58:21 +00:00
|
|
|
VTKM_CONT inline vtkm::cont::DataSet Probe::DoExecute(
|
2018-01-09 19:01:43 +00:00
|
|
|
const vtkm::cont::DataSet& input,
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
2018-01-09 19:01:43 +00:00
|
|
|
{
|
2020-05-15 23:47:30 +00:00
|
|
|
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy, *this),
|
2019-08-13 17:08:54 +00:00
|
|
|
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
|
|
|
|
this->Geometry.GetCoordinateSystem().GetData());
|
2018-01-09 19:01:43 +00:00
|
|
|
|
|
|
|
auto output = this->Geometry;
|
2018-08-30 15:53:18 +00:00
|
|
|
auto hpf = this->Worklet.GetHiddenPointsField();
|
2019-09-09 22:08:11 +00:00
|
|
|
auto hcf = this->Worklet.GetHiddenCellsField(
|
2020-05-15 23:47:30 +00:00
|
|
|
vtkm::filter::ApplyPolicyCellSet(output.GetCellSet(), policy, *this));
|
2018-01-09 19:01:43 +00:00
|
|
|
|
2019-08-13 14:10:52 +00:00
|
|
|
output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", hpf));
|
2019-08-13 17:08:54 +00:00
|
|
|
output.AddField(vtkm::cont::make_FieldCell("HIDDEN", hcf));
|
2018-01-09 19:01:43 +00:00
|
|
|
|
2018-04-02 21:58:21 +00:00
|
|
|
return output;
|
2018-01-09 19:01:43 +00:00
|
|
|
}
|
|
|
|
|
2020-02-06 21:58:59 +00:00
|
|
|
template <typename DerivedPolicy>
|
|
|
|
VTKM_CONT inline bool Probe::MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
|
|
|
const vtkm::cont::Field& field,
|
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
2018-01-09 19:01:43 +00:00
|
|
|
{
|
2020-02-06 21:58:59 +00:00
|
|
|
if (field.IsFieldPoint())
|
2018-01-09 19:01:43 +00:00
|
|
|
{
|
2020-02-19 17:34:24 +00:00
|
|
|
// If the field is a point field, then we need to do a custom interpolation of the points.
|
|
|
|
// In this case, we need to call the superclass's MapFieldOntoOutput, which will in turn
|
|
|
|
// call our DoMapField.
|
2020-02-06 21:58:59 +00:00
|
|
|
return this->FilterDataSet<Probe>::MapFieldOntoOutput(result, field, policy);
|
2018-01-09 19:01:43 +00:00
|
|
|
}
|
2020-02-19 17:34:24 +00:00
|
|
|
else if (field.IsFieldCell())
|
2018-01-09 19:01:43 +00:00
|
|
|
{
|
2020-06-03 21:24:36 +00:00
|
|
|
return vtkm::filter::MapFieldPermutation(
|
|
|
|
field, this->Worklet.GetCellIds(), result, this->InvalidValue);
|
2018-01-09 19:01:43 +00:00
|
|
|
}
|
2020-02-19 17:34:24 +00:00
|
|
|
else if (field.IsFieldGlobal())
|
|
|
|
{
|
|
|
|
result.AddField(field);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2018-01-09 19:01:43 +00:00
|
|
|
}
|
2020-02-06 21:58:59 +00:00
|
|
|
|
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
|
|
|
VTKM_CONT inline bool Probe::DoMapField(vtkm::cont::DataSet& result,
|
|
|
|
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
|
|
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
|
|
|
{
|
|
|
|
VTKM_ASSERT(fieldMeta.IsPointField());
|
|
|
|
auto fieldArray =
|
2020-06-03 21:24:36 +00:00
|
|
|
this->Worklet.ProcessPointField(input,
|
|
|
|
vtkm::cont::internal::CastInvalidValue<T>(this->InvalidValue),
|
|
|
|
typename DerivedPolicy::AllCellSetList());
|
2020-02-06 21:58:59 +00:00
|
|
|
result.AddField(fieldMeta.AsField(fieldArray));
|
|
|
|
return true;
|
|
|
|
}
|
2018-01-09 19:01:43 +00:00
|
|
|
}
|
|
|
|
} // vtkm::filter
|
2019-10-07 19:39:02 +00:00
|
|
|
#endif
|