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.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#include <vtkm/cont/ArrayHandlePermutation.h>
|
|
|
|
#include <vtkm/cont/CellSetPermutation.h>
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/cont/DynamicCellSet.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-03-09 02:28:08 +00:00
|
|
|
|
|
|
|
ClipWithImplicitFunction::ClipWithImplicitFunction()
|
|
|
|
: Invert(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename DerivedPolicy>
|
2018-04-02 21:58:21 +00:00
|
|
|
inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::DataSet& input,
|
2018-08-30 15:53:18 +00:00
|
|
|
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
2016-08-23 14:23:42 +00:00
|
|
|
{
|
|
|
|
//get the cells and coordinates of the dataset
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
|
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
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::CellSetExplicit<> outputCellSet = this->Worklet.Run(
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::filter::ApplyPolicy(cells, policy), this->Function, inputCoords, this->Invert);
|
2016-08-23 14:23:42 +00:00
|
|
|
|
2017-04-18 15:01:17 +00:00
|
|
|
// compute output coordinates
|
2018-08-30 15:53:18 +00:00
|
|
|
auto outputCoordsArray = this->Worklet.ProcessPointField(inputCoords.GetData());
|
2017-06-12 16:04:11 +00:00
|
|
|
vtkm::cont::CoordinateSystem outputCoords(inputCoords.GetName(), outputCoordsArray);
|
2017-04-18 15:01:17 +00:00
|
|
|
|
2016-08-23 14:23:42 +00:00
|
|
|
//create the output data
|
|
|
|
vtkm::cont::DataSet output;
|
2017-05-18 14:29:41 +00:00
|
|
|
output.AddCellSet(outputCellSet);
|
|
|
|
output.AddCoordinateSystem(outputCoords);
|
2016-08-23 14:23:42 +00:00
|
|
|
|
2018-04-02 21:58:21 +00:00
|
|
|
return output;
|
2016-08-23 14:23:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
2017-04-18 15:01:17 +00:00
|
|
|
inline bool ClipWithImplicitFunction::DoMapField(
|
2018-04-02 21:58:21 +00:00
|
|
|
vtkm::cont::DataSet& result,
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
|
|
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
2018-08-30 15:53:18 +00:00
|
|
|
const vtkm::filter::PolicyBase<DerivedPolicy>&)
|
2016-08-23 14:23:42 +00:00
|
|
|
{
|
2017-06-12 16:04:11 +00:00
|
|
|
vtkm::cont::ArrayHandle<T> output;
|
|
|
|
|
|
|
|
if (fieldMeta.IsPointField())
|
|
|
|
{
|
2018-08-30 15:53:18 +00:00
|
|
|
output = this->Worklet.ProcessPointField(input);
|
2017-06-12 16:04:11 +00:00
|
|
|
}
|
|
|
|
else if (fieldMeta.IsCellField())
|
|
|
|
{
|
2018-08-30 15:53:18 +00:00
|
|
|
output = this->Worklet.ProcessCellField(input);
|
2017-06-12 16:04:11 +00:00
|
|
|
}
|
|
|
|
else
|
2016-08-23 14:23:42 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//use the same meta data as the input so we get the same field name, etc.
|
2018-04-02 21:58:21 +00:00
|
|
|
result.AddField(fieldMeta.AsField(output));
|
2017-06-12 16:04:11 +00:00
|
|
|
|
2016-08-23 14:23:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2017-06-12 16:04:11 +00:00
|
|
|
} // end namespace vtkm::filter
|