vtk-m/vtkm/filter/ExtractStructured.hxx
Matt Larsen ae3687cb8f Merge topic 'ExtractStructured'
42a3602ed Had missed a few unused variables when fixing rebase issues.
63a4e696c vim retabed and removed trailing whitespaces form Unit Test
e0000f35f Should be working now
63165904c Merged with the pull (reword)
5cc1de297 Clearing out unused variables
c7bd79e78 Extract Structured with Offset
56598ebfa Maybe closer
5feadd166 Pushing for Abhishek (Don't merge)
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1644
2019-05-30 20:23:08 -04:00

83 lines
2.7 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/worklet/DispatcherMapField.h>
namespace vtkm
{
namespace filter
{
//-----------------------------------------------------------------------------
inline VTKM_CONT ExtractStructured::ExtractStructured()
: vtkm::filter::FilterDataSet<ExtractStructured>()
, VOI(vtkm::RangeId3(0, -1, 0, -1, 0, -1))
, SampleRate(vtkm::Id3(1, 1, 1))
, IncludeBoundary(false)
, IncludeOffset(false)
, Worklet()
{
}
//-----------------------------------------------------------------------------
template <typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet ExtractStructured::DoExecute(
const vtkm::cont::DataSet& input,
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::CoordinateSystem& coordinates =
input.GetCoordinateSystem(this->GetActiveCellSetIndex());
auto cellset = this->Worklet.Run(vtkm::filter::ApplyPolicyStructured(cells, policy),
this->VOI,
this->SampleRate,
this->IncludeBoundary,
this->IncludeOffset);
auto coords = this->Worklet.MapCoordinates(coordinates);
vtkm::cont::CoordinateSystem outputCoordinates(coordinates.GetName(), coords);
vtkm::cont::DataSet output;
output.AddCellSet(vtkm::cont::DynamicCellSet(cellset));
output.AddCoordinateSystem(outputCoordinates);
return output;
}
//-----------------------------------------------------------------------------
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT bool ExtractStructured::DoMapField(
vtkm::cont::DataSet& result,
const vtkm::cont::ArrayHandle<T, StorageType>& input,
const vtkm::filter::FieldMetadata& fieldMeta,
vtkm::filter::PolicyBase<DerivedPolicy>)
{
if (fieldMeta.IsPointField())
{
vtkm::cont::ArrayHandle<T> output = this->Worklet.ProcessPointField(input);
result.AddField(fieldMeta.AsField(output));
return true;
}
// cell data must be scattered to the cells created per input cell
if (fieldMeta.IsCellField())
{
vtkm::cont::ArrayHandle<T> output = this->Worklet.ProcessCellField(input);
result.AddField(fieldMeta.AsField(output));
return true;
}
return false;
}
}
}