VTK-m  2.0
worklet/Contour.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 
11 #ifndef vtk_m_worklet_Contour_h
12 #define vtk_m_worklet_Contour_h
13 
14 #include <vtkm/cont/ArrayCopy.h>
17 
22 
23 
24 namespace vtkm
25 {
26 namespace worklet
27 {
28 
29 
30 namespace contour
31 {
33 {
34  template <typename CoordinateType, typename CellSetType, typename... Args>
35  void operator()(const CoordinateType& coords,
36  const CellSetType& cells,
38  Args&&... args) const
39  {
40  result = marching_cells::execute(cells, coords, std::forward<Args>(args)...);
41  }
42 
43  template <typename... Args>
44  void operator()(
48  Args&&... args) const
49  {
50  result = flying_edges::execute(cells, coords, std::forward<Args>(args)...);
51  }
52 };
53 
55 {
56  template <typename CellSetType, typename CoordinateType, typename... Args>
57  void operator()(const CellSetType& cells, CoordinateType&& coordinateSystem, Args&&... args) const
58  {
60  coordinateSystem, contour::DeduceCoordType{}, cells, std::forward<Args>(args)...);
61  }
62 };
63 }
64 
67 class Contour
68 {
69 public:
70  //----------------------------------------------------------------------------
71  Contour(bool mergeDuplicates = true)
72  : SharedState(mergeDuplicates)
73  {
74  }
75 
76  //----------------------------------------------------------------------------
78  {
79  return this->SharedState.InterpolationEdgeIds;
80  }
81 
82  //----------------------------------------------------------------------------
83  void SetMergeDuplicatePoints(bool merge) { this->SharedState.MergeDuplicatePoints = merge; }
84 
85  //----------------------------------------------------------------------------
87 
88  //----------------------------------------------------------------------------
90 
91  //----------------------------------------------------------------------------
92  template <typename ValueType,
93  typename CellSetType,
94  typename CoordinateSystem,
95  typename StorageTagField,
96  typename CoordinateType,
97  typename StorageTagVertices>
99  const std::vector<ValueType>& isovalues,
100  const CellSetType& cells,
101  const CoordinateSystem& coordinateSystem,
103  vtkm::cont::ArrayHandle<vtkm::Vec<CoordinateType, 3>, StorageTagVertices>& vertices)
104  {
105  this->SharedState.GenerateNormals = false;
107 
111  coordinateSystem,
112  outputCells,
113  isovalues,
114  input,
115  vertices,
116  normals,
117  this->SharedState);
118  return outputCells;
119  }
120 
121  //----------------------------------------------------------------------------
122  template <typename ValueType,
123  typename CellSetType,
124  typename CoordinateSystem,
125  typename StorageTagField,
126  typename CoordinateType,
127  typename StorageTagVertices,
128  typename StorageTagNormals>
130  const std::vector<ValueType>& isovalues,
131  const CellSetType& cells,
132  const CoordinateSystem& coordinateSystem,
134  vtkm::cont::ArrayHandle<vtkm::Vec<CoordinateType, 3>, StorageTagVertices>& vertices,
135  vtkm::cont::ArrayHandle<vtkm::Vec<CoordinateType, 3>, StorageTagNormals>& normals)
136  {
137  this->SharedState.GenerateNormals = true;
138 
142  coordinateSystem,
143  outputCells,
144  isovalues,
145  input,
146  vertices,
147  normals,
148  this->SharedState);
149  return outputCells;
150  }
151 
152  //----------------------------------------------------------------------------
153  template <typename ValueType, typename StorageType>
156  {
157 
160 
162  applyFieldDispatcher.Invoke(this->SharedState.InterpolationEdgeIds,
163  this->SharedState.InterpolationWeights,
164  input,
165  output);
166 
167  return output;
168  }
169 
170  //----------------------------------------------------------------------------
172 
173 private:
175 };
176 }
177 } // namespace vtkm::worklet
178 
179 #endif // vtk_m_worklet_Contour_h
MarchingCells.h
vtkm::worklet::Contour::GetInterpolationEdgeIds
vtkm::cont::ArrayHandle< vtkm::Id2 > GetInterpolationEdgeIds() const
Definition: worklet/Contour.h:77
vtkm::cont::ArrayHandle< vtkm::Vec3f, vtkm::cont::StorageTagUniformPoints >
vtkm::worklet::Contour::Run
vtkm::cont::CellSetSingleType Run(const std::vector< ValueType > &isovalues, const CellSetType &cells, const CoordinateSystem &coordinateSystem, const vtkm::cont::ArrayHandle< ValueType, StorageTagField > &input, vtkm::cont::ArrayHandle< vtkm::Vec< CoordinateType, 3 >, StorageTagVertices > &vertices)
Definition: worklet/Contour.h:98
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::worklet::Contour::ProcessPointField
vtkm::cont::ArrayHandle< ValueType > ProcessPointField(const vtkm::cont::ArrayHandle< ValueType, StorageType > &input) const
Definition: worklet/Contour.h:154
vtkm::worklet::contour::MapPointField
Definition: FieldPropagation.h:25
vtkm::cont::CellSetStructured< 3 >
FieldPropagation.h
vtkm::worklet::Contour::SetMergeDuplicatePoints
void SetMergeDuplicatePoints(bool merge)
Definition: worklet/Contour.h:83
FlyingEdges.h
vtkm::worklet::contour::CommonState::GenerateNormals
bool GenerateNormals
Definition: CommonState.h:32
vtkm::cont::CellSetSingleType
Definition: CastAndCall.h:34
vtkm::cont::CastAndCall
void CastAndCall(const DynamicObject &dynamicObject, Functor &&f, Args &&... args)
A Generic interface to CastAndCall.
Definition: CastAndCall.h:47
vtkm::worklet::Contour::GetMergeDuplicatePoints
bool GetMergeDuplicatePoints() const
Definition: worklet/Contour.h:86
vtkm::worklet::flying_edges::execute
vtkm::cont::CellSetSingleType execute(const vtkm::cont::CellSetStructured< 3 > &cells, const vtkm::cont::ArrayHandleUniformPointCoordinates &coordinateSystem, const std::vector< ValueType > &isovalues, const vtkm::cont::ArrayHandle< ValueType, StorageTagField > &inputField, vtkm::cont::ArrayHandle< vtkm::Vec< CoordinateType, 3 >, StorageTagVertices > &points, vtkm::cont::ArrayHandle< vtkm::Vec< NormalType, 3 >, StorageTagNormals > &normals, vtkm::worklet::contour::CommonState &sharedState)
Definition: FlyingEdges.h:49
ArrayCopy.h
vtkm::worklet::contour::DeduceCellType
Definition: worklet/Contour.h:54
vtkm::worklet::Contour::Run
vtkm::cont::CellSetSingleType Run(const std::vector< ValueType > &isovalues, const CellSetType &cells, const CoordinateSystem &coordinateSystem, const vtkm::cont::ArrayHandle< ValueType, StorageTagField > &input, vtkm::cont::ArrayHandle< vtkm::Vec< CoordinateType, 3 >, StorageTagVertices > &vertices, vtkm::cont::ArrayHandle< vtkm::Vec< CoordinateType, 3 >, StorageTagNormals > &normals)
Definition: worklet/Contour.h:129
vtkm::worklet::contour::CommonState::MergeDuplicatePoints
bool MergeDuplicatePoints
Definition: CommonState.h:31
ArrayHandleUniformPointCoordinates.h
vtkm::worklet::Contour::ReleaseCellMapArrays
void ReleaseCellMapArrays()
Definition: worklet/Contour.h:171
vtkm::worklet::Contour
Compute the isosurface of a given 3D data set, supports all linear cell types.
Definition: worklet/Contour.h:67
vtkm::worklet::DispatcherMapField
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:25
vtkm::worklet::Contour::Contour
Contour(bool mergeDuplicates=true)
Definition: worklet/Contour.h:71
ArrayHandlePermutation.h
vtkm::worklet::contour::DeduceCoordType::operator()
void operator()(const CoordinateType &coords, const CellSetType &cells, vtkm::cont::CellSetSingleType<> &result, Args &&... args) const
Definition: worklet/Contour.h:35
vtkm::worklet::contour::CommonState
Definition: CommonState.h:24
vtkm::worklet::contour::DeduceCellType::operator()
void operator()(const CellSetType &cells, CoordinateType &&coordinateSystem, Args &&... args) const
Definition: worklet/Contour.h:57
vtkm::worklet::Contour::GetCellIdMap
vtkm::cont::ArrayHandle< vtkm::Id > GetCellIdMap() const
Definition: worklet/Contour.h:89
vtkm::worklet::Contour::SharedState
vtkm::worklet::contour::CommonState SharedState
Definition: worklet/Contour.h:174
vtkm::Vec
A short fixed-length array.
Definition: Types.h:767
vtkm::worklet::marching_cells::execute
vtkm::cont::CellSetSingleType execute(const CellSetType &cells, const CoordinateSystem &coordinateSystem, const std::vector< ValueType > &isovalues, const vtkm::cont::ArrayHandle< ValueType, StorageTagField > &inputField, vtkm::cont::ArrayHandle< vtkm::Vec< CoordinateType, 3 >, StorageTagVertices > &vertices, vtkm::cont::ArrayHandle< vtkm::Vec< NormalType, 3 >, StorageTagNormals > &normals, vtkm::worklet::contour::CommonState &sharedState)
Definition: MarchingCells.h:602
vtkm::worklet::contour::CommonState::CellIdMap
vtkm::cont::ArrayHandle< vtkm::Id > CellIdMap
Definition: CommonState.h:35
CommonState.h
vtkm::worklet::contour::DeduceCoordType::operator()
void operator()(const vtkm::cont::ArrayHandle< vtkm::Vec3f, vtkm::cont::StorageTagUniformPoints > &coords, const vtkm::cont::CellSetStructured< 3 > &cells, vtkm::cont::CellSetSingleType<> &result, Args &&... args) const
Definition: worklet/Contour.h:44
vtkm::worklet::contour::CommonState::InterpolationEdgeIds
vtkm::cont::ArrayHandle< vtkm::Id2 > InterpolationEdgeIds
Definition: CommonState.h:34
vtkm::cont::ArrayHandle::ReleaseResources
VTKM_CONT void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:559
vtkm::worklet::contour::DeduceCoordType
Definition: worklet/Contour.h:32