VTK-m  2.0
worklet/Triangulate.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtkm_m_worklet_Triangulate_h
11 #define vtkm_m_worklet_Triangulate_h
12 
15 
16 namespace vtkm
17 {
18 namespace worklet
19 {
20 
22 {
23 public:
24  //
25  // Distribute multiple copies of cell data depending on cells create from original
26  //
28  {
29  using ControlSignature = void(FieldIn inIndices, FieldOut outIndices);
30 
32 
33  template <typename CountArrayType>
34  VTKM_CONT static ScatterType MakeScatter(const CountArrayType& countArray)
35  {
36  return ScatterType(countArray);
37  }
38 
39  template <typename T>
40  VTKM_EXEC void operator()(T inputIndex, T& outputIndex) const
41  {
42  outputIndex = inputIndex;
43  }
44  };
45 
47  : OutCellScatter(vtkm::cont::ArrayHandle<vtkm::IdComponent>{})
48  {
49  }
50 
51  // Triangulate explicit data set, save number of triangulated cells per input
52  template <typename CellSetType>
53  vtkm::cont::CellSetSingleType<> Run(const CellSetType& cellSet)
54  {
55  TriangulateExplicit worklet;
57  vtkm::cont::CellSetSingleType<> result = worklet.Run(cellSet, outCellsPerCell);
58  this->OutCellScatter = DistributeCellData::MakeScatter(outCellsPerCell);
59  return result;
60  }
61 
62  // Triangulate structured data set, save number of triangulated cells per input
64  {
65  TriangulateStructured worklet;
67  vtkm::cont::CellSetSingleType<> result = worklet.Run(cellSet, outCellsPerCell);
68  this->OutCellScatter = DistributeCellData::MakeScatter(outCellsPerCell);
69  return result;
70  }
71 
73  {
74  throw vtkm::cont::ErrorBadType("CellSetStructured<3> can't be triangulated");
75  }
76 
78  {
79  throw vtkm::cont::ErrorBadType("CellSetStructured<1> can't be tetrahedralized");
80  }
81 
83 
84 private:
86 };
87 }
88 } // namespace vtkm::worklet
89 
90 #endif // vtkm_m_worklet_Triangulate_h
vtkm::worklet::Triangulate::Run
vtkm::cont::CellSetSingleType Run(const CellSetType &cellSet)
Definition: worklet/Triangulate.h:53
vtkm::cont::ArrayHandle< vtkm::IdComponent >
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm::worklet::TriangulateExplicit::Run
vtkm::cont::CellSetSingleType Run(const CellSetType &cellSet, vtkm::cont::ArrayHandle< vtkm::IdComponent > &outCellsPerCell)
Definition: TriangulateExplicit.h:99
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::worklet::Triangulate::DistributeCellData::ControlSignature
void(FieldIn inIndices, FieldOut outIndices) ControlSignature
Definition: worklet/Triangulate.h:29
vtkm::worklet::TriangulateExplicit
Compute the triangulate cells for an explicit grid data set.
Definition: TriangulateExplicit.h:34
vtkm::worklet::Triangulate::OutCellScatter
DistributeCellData::ScatterType OutCellScatter
Definition: worklet/Triangulate.h:85
vtkm::worklet::WorkletMapField::FieldOut
A control signature tag for output fields.
Definition: WorkletMapField.h:60
vtkm::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
vtkm::cont::CellSetStructured
Definition: CastAndCall.h:32
vtkm::worklet::Triangulate::Run
vtkm::cont::CellSetSingleType Run(const vtkm::cont::CellSetStructured< 1 > &)
Definition: worklet/Triangulate.h:77
vtkm::worklet::Triangulate::GetOutCellScatter
DistributeCellData::ScatterType GetOutCellScatter() const
Definition: worklet/Triangulate.h:82
vtkm::cont::CellSetSingleType
Definition: CastAndCall.h:34
vtkm::cont::ErrorBadType
This class is thrown when VTK-m encounters data of a type that is incompatible with the current opera...
Definition: ErrorBadType.h:25
TriangulateStructured.h
vtkm::worklet::TriangulateStructured
Compute the triangulate cells for a uniform grid data set.
Definition: TriangulateStructured.h:62
vtkm::worklet::Triangulate
Definition: worklet/Triangulate.h:21
vtkm::worklet::ScatterCounting
A scatter that maps input to some numbers of output.
Definition: ScatterCounting.h:44
vtkm::worklet::Triangulate::DistributeCellData
Definition: worklet/Triangulate.h:27
vtkm::worklet::WorkletMapField::FieldIn
A control signature tag for input fields.
Definition: WorkletMapField.h:49
vtkm::worklet::Triangulate::DistributeCellData::MakeScatter
static VTKM_CONT ScatterType MakeScatter(const CountArrayType &countArray)
Definition: worklet/Triangulate.h:34
vtkm::worklet::Triangulate::DistributeCellData::operator()
VTKM_EXEC void operator()(T inputIndex, T &outputIndex) const
Definition: worklet/Triangulate.h:40
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
TriangulateExplicit.h
vtkm::worklet::Triangulate::DistributeCellData::ScatterType
vtkm::worklet::ScatterCounting ScatterType
Definition: worklet/Triangulate.h:31
vtkm::worklet::Triangulate::Triangulate
Triangulate()
Definition: worklet/Triangulate.h:46
vtkm::worklet::Triangulate::Run
vtkm::cont::CellSetSingleType Run(const vtkm::cont::CellSetStructured< 2 > &cellSet)
Definition: worklet/Triangulate.h:63
vtkm::worklet::Triangulate::Run
vtkm::cont::CellSetSingleType Run(const vtkm::cont::CellSetStructured< 3 > &)
Definition: worklet/Triangulate.h:72
vtkm::worklet::WorkletMapField
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
vtkm::worklet::TriangulateStructured::Run
vtkm::cont::CellSetSingleType Run(const CellSetType &cellSet, vtkm::cont::ArrayHandle< vtkm::IdComponent > &outCellsPerCell)
Definition: TriangulateStructured.h:66