2018-09-07 20:49:51 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2018-09-07 20:49:51 +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_SplitSharpEdges_hxx
|
|
|
|
#define vtk_m_filter_SplitSharpEdges_hxx
|
2020-02-06 21:58:59 +00:00
|
|
|
#include <vtkm/filter/SplitSharpEdges.h>
|
2019-10-07 19:39:02 +00:00
|
|
|
|
2018-09-07 20:49:51 +00:00
|
|
|
#include <vtkm/cont/ArrayHandlePermutation.h>
|
|
|
|
#include <vtkm/cont/CellSetExplicit.h>
|
|
|
|
#include <vtkm/cont/CoordinateSystem.h>
|
|
|
|
#include <vtkm/cont/DynamicCellSet.h>
|
|
|
|
|
2020-02-06 21:58:59 +00:00
|
|
|
#include <vtkm/filter/MapFieldPermutation.h>
|
|
|
|
|
2018-09-07 20:49:51 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
inline VTKM_CONT SplitSharpEdges::SplitSharpEdges()
|
|
|
|
: vtkm::filter::FilterDataSetWithField<SplitSharpEdges>()
|
|
|
|
, FeatureAngle(30.0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
2018-09-07 20:49:51 +00:00
|
|
|
inline VTKM_CONT vtkm::cont::DataSet SplitSharpEdges::DoExecute(
|
|
|
|
const vtkm::cont::DataSet& input,
|
|
|
|
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
|
|
|
const vtkm::filter::FieldMetadata& vtkmNotUsed(fieldMeta),
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
2018-09-07 20:49:51 +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();
|
2019-07-31 16:20:38 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Vec3f> newCoords;
|
2018-09-07 20:49:51 +00:00
|
|
|
vtkm::cont::CellSetExplicit<> newCellset;
|
|
|
|
|
2020-05-15 23:47:30 +00:00
|
|
|
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
2018-09-07 20:49:51 +00:00
|
|
|
this->FeatureAngle,
|
|
|
|
field,
|
2020-06-30 21:10:48 +00:00
|
|
|
input.GetCoordinateSystem().GetDataAsMultiplexer(),
|
2018-09-07 20:49:51 +00:00
|
|
|
newCoords,
|
2018-08-30 15:53:18 +00:00
|
|
|
newCellset);
|
2018-09-07 20:49:51 +00:00
|
|
|
|
|
|
|
vtkm::cont::DataSet output;
|
2019-08-13 17:08:54 +00:00
|
|
|
output.SetCellSet(newCellset);
|
2018-09-07 20:49:51 +00:00
|
|
|
output.AddCoordinateSystem(
|
|
|
|
vtkm::cont::CoordinateSystem(input.GetCoordinateSystem().GetName(), newCoords));
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2020-02-06 21:58:59 +00:00
|
|
|
template <typename DerivedPolicy>
|
|
|
|
inline VTKM_CONT bool SplitSharpEdges::MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
|
|
|
const vtkm::cont::Field& field,
|
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
2018-09-07 20:49:51 +00:00
|
|
|
{
|
2020-02-06 21:58:59 +00:00
|
|
|
if (field.IsFieldPoint())
|
2018-09-07 20:49:51 +00:00
|
|
|
{
|
2020-02-06 21:58:59 +00:00
|
|
|
return vtkm::filter::MapFieldPermutation(field, this->Worklet.GetNewPointsIdArray(), result);
|
2018-09-07 20:49:51 +00:00
|
|
|
}
|
2020-02-19 17:34:24 +00:00
|
|
|
else if (field.IsFieldCell() || field.IsFieldGlobal())
|
2018-09-07 20:49:51 +00:00
|
|
|
{
|
2020-02-06 21:58:59 +00:00
|
|
|
result.AddField(field); // pass through
|
2018-09-07 20:49:51 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-07 19:39:02 +00:00
|
|
|
#endif
|