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
|
|
|
|
|
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>
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2019-09-09 22:08:11 +00:00
|
|
|
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy),
|
2018-09-07 20:49:51 +00:00
|
|
|
this->FeatureAngle,
|
|
|
|
field,
|
|
|
|
input.GetCoordinateSystem().GetData(),
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
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 bool SplitSharpEdges::DoMapField(
|
|
|
|
vtkm::cont::DataSet& result,
|
|
|
|
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
|
|
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
2018-09-07 20:49:51 +00:00
|
|
|
{
|
|
|
|
if (fieldMeta.IsPointField())
|
|
|
|
{
|
|
|
|
// We copy the input handle to the result dataset, reusing the metadata
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::cont::ArrayHandle<T> out = this->Worklet.ProcessPointField(input);
|
2018-09-07 20:49:51 +00:00
|
|
|
result.AddField(fieldMeta.AsField(out));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (fieldMeta.IsCellField())
|
|
|
|
{
|
|
|
|
result.AddField(fieldMeta.AsField(input));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-07 19:39:02 +00:00
|
|
|
#endif
|