2017-03-23 17:58:00 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2017-03-23 17:58:00 +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.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtkm_m_worklet_Triangulate_h
|
|
|
|
#define vtkm_m_worklet_Triangulate_h
|
|
|
|
|
|
|
|
#include <vtkm/worklet/triangulate/TriangulateExplicit.h>
|
|
|
|
#include <vtkm/worklet/triangulate/TriangulateStructured.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace worklet
|
|
|
|
{
|
2017-03-23 17:58:00 +00:00
|
|
|
|
2017-10-02 21:20:08 +00:00
|
|
|
class Triangulate
|
2017-03-24 22:34:53 +00:00
|
|
|
{
|
2017-10-02 21:20:08 +00:00
|
|
|
public:
|
|
|
|
//
|
|
|
|
// Distribute multiple copies of cell data depending on cells create from original
|
|
|
|
//
|
|
|
|
struct DistributeCellData : public vtkm::worklet::WorkletMapField
|
|
|
|
{
|
2019-01-10 18:59:25 +00:00
|
|
|
using ControlSignature = void(FieldIn inIndices, FieldOut outIndices);
|
2017-03-24 22:34:53 +00:00
|
|
|
|
2018-02-22 13:29:13 +00:00
|
|
|
using ScatterType = vtkm::worklet::ScatterCounting;
|
2017-03-24 22:34:53 +00:00
|
|
|
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename CountArrayType>
|
|
|
|
VTKM_CONT static ScatterType MakeScatter(const CountArrayType& countArray)
|
2017-10-02 21:20:08 +00:00
|
|
|
{
|
2018-08-30 15:53:18 +00:00
|
|
|
return ScatterType(countArray);
|
2017-10-02 21:20:08 +00:00
|
|
|
}
|
2017-03-24 22:34:53 +00:00
|
|
|
|
2017-10-02 21:20:08 +00:00
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC void operator()(T inputIndex, T& outputIndex) const
|
|
|
|
{
|
|
|
|
outputIndex = inputIndex;
|
|
|
|
}
|
|
|
|
};
|
2017-03-24 22:34:53 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
Triangulate()
|
|
|
|
: OutCellsPerCell()
|
|
|
|
{
|
|
|
|
}
|
2017-03-23 17:58:00 +00:00
|
|
|
|
2017-03-24 22:34:53 +00:00
|
|
|
// Triangulate explicit data set, save number of triangulated cells per input
|
2018-08-28 20:36:50 +00:00
|
|
|
template <typename CellSetType>
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::cont::CellSetSingleType<> Run(const CellSetType& cellSet)
|
2017-03-23 17:58:00 +00:00
|
|
|
{
|
2018-08-28 20:36:50 +00:00
|
|
|
TriangulateExplicit worklet;
|
2018-08-30 15:53:18 +00:00
|
|
|
return worklet.Run(cellSet, this->OutCellsPerCell);
|
2017-03-23 17:58:00 +00:00
|
|
|
}
|
|
|
|
|
2017-03-24 22:34:53 +00:00
|
|
|
// Triangulate structured data set, save number of triangulated cells per input
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::cont::CellSetSingleType<> Run(const vtkm::cont::CellSetStructured<2>& cellSet)
|
2017-03-23 17:58:00 +00:00
|
|
|
{
|
2018-08-30 15:53:18 +00:00
|
|
|
TriangulateStructured worklet;
|
2017-04-17 20:21:29 +00:00
|
|
|
return worklet.Run(cellSet, this->OutCellsPerCell);
|
2017-03-24 22:34:53 +00:00
|
|
|
}
|
|
|
|
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::cont::CellSetSingleType<> Run(const vtkm::cont::CellSetStructured<3>&)
|
2017-03-27 22:09:18 +00:00
|
|
|
{
|
2017-03-27 22:25:38 +00:00
|
|
|
throw vtkm::cont::ErrorBadType("CellSetStructured<3> can't be triangulated");
|
2017-03-27 22:09:18 +00:00
|
|
|
}
|
|
|
|
|
2017-03-24 22:34:53 +00:00
|
|
|
// Using the saved input to output cells, expand cell data
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename ValueType, typename StorageType>
|
2017-06-19 18:50:06 +00:00
|
|
|
vtkm::cont::ArrayHandle<ValueType> ProcessCellField(
|
2018-08-30 15:53:18 +00:00
|
|
|
const vtkm::cont::ArrayHandle<ValueType, StorageType>& input) const
|
2017-03-24 22:34:53 +00:00
|
|
|
{
|
2017-06-19 18:50:06 +00:00
|
|
|
vtkm::cont::ArrayHandle<ValueType> output;
|
2017-03-24 22:34:53 +00:00
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<DistributeCellData> dispatcher(
|
2018-08-30 15:53:18 +00:00
|
|
|
DistributeCellData::MakeScatter(this->OutCellsPerCell));
|
2017-03-24 22:34:53 +00:00
|
|
|
dispatcher.Invoke(input, output);
|
|
|
|
|
|
|
|
return output;
|
2017-03-23 17:58:00 +00:00
|
|
|
}
|
2017-03-24 22:34:53 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::IdComponent> OutCellsPerCell;
|
2017-03-23 17:58:00 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
} // namespace vtkm::worklet
|
|
|
|
|
|
|
|
#endif // vtkm_m_worklet_Triangulate_h
|