2016-08-23 14:23:42 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2016-08-23 14:23:42 +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_ClipWithField_hxx
|
|
|
|
#define vtk_m_filter_ClipWithField_hxx
|
|
|
|
|
2016-08-23 14:23:42 +00:00
|
|
|
#include <vtkm/cont/ArrayHandlePermutation.h>
|
|
|
|
#include <vtkm/cont/CellSetPermutation.h>
|
2017-02-23 16:54:05 +00:00
|
|
|
#include <vtkm/cont/CoordinateSystem.h>
|
|
|
|
#include <vtkm/cont/DynamicCellSet.h>
|
2018-04-02 21:58:21 +00:00
|
|
|
#include <vtkm/cont/ErrorFilterExecution.h>
|
2016-08-23 14:23:42 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
2016-08-23 14:23:42 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
2018-04-02 21:58:21 +00:00
|
|
|
inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::DataSet& input,
|
|
|
|
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
2017-04-18 15:01:17 +00:00
|
|
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
2016-08-23 14:23:42 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
if (fieldMeta.IsPointField() == false)
|
2016-08-23 14:23:42 +00:00
|
|
|
{
|
2018-04-02 21:58:21 +00:00
|
|
|
throw vtkm::cont::ErrorFilterExecution("Point field expected.");
|
2016-08-23 14:23:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//get the cells and coordinates of the dataset
|
2019-08-13 17:08:54 +00:00
|
|
|
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
2016-08-23 14:23:42 +00:00
|
|
|
|
|
|
|
const vtkm::cont::CoordinateSystem& inputCoords =
|
2017-05-18 14:29:41 +00:00
|
|
|
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
2016-08-23 14:23:42 +00:00
|
|
|
|
2018-03-09 02:28:08 +00:00
|
|
|
vtkm::cont::CellSetExplicit<> outputCellSet = this->Worklet.Run(
|
2019-09-09 22:08:11 +00:00
|
|
|
vtkm::filter::ApplyPolicyCellSet(cells, policy), field, this->ClipValue, this->Invert);
|
2016-08-23 14:23:42 +00:00
|
|
|
|
|
|
|
//create the output data
|
|
|
|
vtkm::cont::DataSet output;
|
2019-08-13 17:08:54 +00:00
|
|
|
output.SetCellSet(outputCellSet);
|
2016-08-23 14:23:42 +00:00
|
|
|
|
2017-02-23 16:54:05 +00:00
|
|
|
// Compute the new boundary points and add them to the output:
|
2018-08-30 15:53:18 +00:00
|
|
|
auto outputCoordsArray = this->Worklet.ProcessPointField(inputCoords.GetData());
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::CoordinateSystem outputCoords(inputCoords.GetName(), outputCoordsArray);
|
2017-02-23 16:54:05 +00:00
|
|
|
output.AddCoordinateSystem(outputCoords);
|
2018-04-02 21:58:21 +00:00
|
|
|
return output;
|
2016-08-23 14:23:42 +00:00
|
|
|
}
|
|
|
|
}
|
2017-06-12 16:04:11 +00:00
|
|
|
} // end namespace vtkm::filter
|
2019-10-07 19:39:02 +00:00
|
|
|
|
|
|
|
#endif
|