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_ClipWithImplicitFunction_hxx
|
|
|
|
#define vtk_m_filter_ClipWithImplicitFunction_hxx
|
|
|
|
|
2020-06-30 21:10:48 +00:00
|
|
|
#include <vtkm/filter/ClipWithImplicitFunction.h>
|
|
|
|
|
2016-08-23 14:23:42 +00:00
|
|
|
#include <vtkm/cont/ArrayHandlePermutation.h>
|
|
|
|
#include <vtkm/cont/CellSetPermutation.h>
|
2022-01-04 22:38:18 +00:00
|
|
|
#include <vtkm/cont/UnknownCellSet.h>
|
2016-08-23 14:23:42 +00:00
|
|
|
|
2020-11-11 16:14:10 +00:00
|
|
|
// Do not instantiation common concrete types unless we are compiling the
|
|
|
|
// corresponding TU.
|
|
|
|
#ifndef vtkm_filter_ClipWithImplicitFunction_cxx
|
2021-08-14 17:39:53 +00:00
|
|
|
#include <vtkm/filter/ClipWithImplicitFunctionExternInstantiations.h>
|
2020-11-11 16:14:10 +00:00
|
|
|
#endif
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
2020-06-30 21:10:48 +00:00
|
|
|
|
|
|
|
namespace detail
|
|
|
|
{
|
|
|
|
|
|
|
|
struct ClipWithImplicitFunctionProcessCoords
|
|
|
|
{
|
|
|
|
template <typename T, typename Storage>
|
|
|
|
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, Storage>& inCoords,
|
|
|
|
const std::string& coordsName,
|
|
|
|
const vtkm::worklet::Clip& worklet,
|
|
|
|
vtkm::cont::DataSet& output) const
|
|
|
|
{
|
|
|
|
vtkm::cont::ArrayHandle<T> outArray = worklet.ProcessPointField(inCoords);
|
|
|
|
vtkm::cont::CoordinateSystem outCoords(coordsName, outArray);
|
|
|
|
output.AddCoordinateSystem(outCoords);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
2016-08-23 14:23:42 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename DerivedPolicy>
|
2020-11-17 19:37:05 +00:00
|
|
|
vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::DataSet& input,
|
2019-09-09 13:39:23 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
2016-08-23 14:23:42 +00:00
|
|
|
{
|
|
|
|
//get the cells and coordinates of the dataset
|
2022-01-04 22:38:18 +00:00
|
|
|
const vtkm::cont::UnknownCellSet& 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
|
|
|
|
2020-05-15 23:47:30 +00:00
|
|
|
vtkm::cont::CellSetExplicit<> outputCellSet =
|
|
|
|
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
|
|
|
this->Function,
|
|
|
|
inputCoords,
|
|
|
|
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);
|
2020-06-30 21:10:48 +00:00
|
|
|
|
|
|
|
// compute output coordinates
|
|
|
|
for (vtkm::IdComponent coordSystemId = 0; coordSystemId < input.GetNumberOfCoordinateSystems();
|
|
|
|
++coordSystemId)
|
|
|
|
{
|
|
|
|
vtkm::cont::CoordinateSystem coords = input.GetCoordinateSystem(coordSystemId);
|
|
|
|
coords.GetData().CastAndCall(
|
|
|
|
detail::ClipWithImplicitFunctionProcessCoords{}, coords.GetName(), this->Worklet, output);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
2017-06-12 16:04:11 +00:00
|
|
|
} // end namespace vtkm::filter
|
2019-10-07 19:39:02 +00:00
|
|
|
|
|
|
|
#endif
|