VTK-m  2.0
TriangulateStructured.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_TriangulateStructured_h
12 #define vtk_m_worklet_TriangulateStructured_h
13 
14 #include <vtkm/cont/ArrayCopy.h>
15 #include <vtkm/cont/ArrayHandle.h>
19 #include <vtkm/cont/DataSet.h>
21 #include <vtkm/cont/Field.h>
22 
26 
27 namespace vtkm
28 {
29 namespace worklet
30 {
31 namespace triangulate
32 {
33 //
34 // Worklet to turn quads into triangles
35 // Vertices remain the same and each cell is processed with needing topology
36 //
38 {
39 public:
40  using ControlSignature = void(CellSetIn cellset, FieldOutCell connectivityOut);
42  using InputDomain = _1;
43 
45 
46  // Each quad cell produces 2 triangle cells
47  template <typename ConnectivityInVec, typename ConnectivityOutVec>
48  VTKM_EXEC void operator()(const ConnectivityInVec& connectivityIn,
49  ConnectivityOutVec& connectivityOut,
50  vtkm::IdComponent visitIndex) const
51  {
52  VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent StructuredTriangleIndices[2][3] = { { 0, 1, 2 },
53  { 0, 2, 3 } };
54  connectivityOut[0] = connectivityIn[StructuredTriangleIndices[visitIndex][0]];
55  connectivityOut[1] = connectivityIn[StructuredTriangleIndices[visitIndex][1]];
56  connectivityOut[2] = connectivityIn[StructuredTriangleIndices[visitIndex][2]];
57  }
58 };
59 }
60 
63 {
64 public:
65  template <typename CellSetType>
66  vtkm::cont::CellSetSingleType<> Run(const CellSetType& cellSet,
68 
69  {
72 
74  dispatcher.Invoke(cellSet, vtkm::cont::make_ArrayHandleGroupVec<3>(connectivity));
75 
76  // Fill in array of output cells per input cell
78  vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>(2, cellSet.GetNumberOfCells()),
79  outCellsPerCell);
80 
81  // Add cells to output cellset
82  outCellSet.Fill(cellSet.GetNumberOfPoints(), vtkm::CellShapeTagTriangle::Id, 3, connectivity);
83  return outCellSet;
84  }
85 };
86 }
87 } // namespace vtkm::worklet
88 
89 #endif // vtk_m_worklet_TriangulateStructured_h
vtkm::cont::ArrayHandle< vtkm::IdComponent >
ArrayHandle.h
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
ScatterUniform.h
vtkm::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
VTKM_STATIC_CONSTEXPR_ARRAY
#define VTKM_STATIC_CONSTEXPR_ARRAY
Definition: ExportMacros.h:107
vtkm::worklet::ScatterUniform
A scatter that maps input to some constant numbers of output.
Definition: ScatterUniform.h:53
vtkm::worklet::triangulate::TriangulateCell::operator()
VTKM_EXEC void operator()(const ConnectivityInVec &connectivityIn, ConnectivityOutVec &connectivityOut, vtkm::IdComponent visitIndex) const
Definition: TriangulateStructured.h:48
vtkm::worklet::triangulate::TriangulateCell::ExecutionSignature
void(PointIndices, _2, VisitIndex) ExecutionSignature
Definition: TriangulateStructured.h:41
vtkm::cont::CellSetSingleType
Definition: CastAndCall.h:34
vtkm::worklet::WorkletVisitCellsWithPoints::PointIndices
IncidentElementIndices PointIndices
Definition: WorkletMapTopology.h:269
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
ArrayCopy.h
vtkm::worklet::TriangulateStructured
Compute the triangulate cells for a uniform grid data set.
Definition: TriangulateStructured.h:62
vtkm::worklet::DispatcherMapTopology
Dispatcher for worklets that inherit from WorkletMapTopology.
Definition: DispatcherMapTopology.h:31
vtkm::worklet::WorkletVisitCellsWithPoints
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:255
vtkm::cont::ArrayCopy
void ArrayCopy(const SourceArrayType &source, DestArrayType &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopy.h:142
vtkm::worklet::triangulate::TriangulateCell::InputDomain
_1 InputDomain
Definition: TriangulateStructured.h:42
vtkm::cont::ArrayHandleConstant
An array handle with a constant value.
Definition: ArrayHandleConstant.h:63
ArrayHandleGroupVec.h
vtkm::worklet::triangulate::TriangulateCell::ControlSignature
void(CellSetIn cellset, FieldOutCell connectivityOut) ControlSignature
Definition: TriangulateStructured.h:40
ErrorBadValue.h
Field.h
CellSetStructured.h
vtkm::worklet::triangulate::TriangulateCell
Definition: TriangulateStructured.h:37
vtkm::cont::CellSetSingleType::Fill
VTKM_CONT void Fill(vtkm::Id numPoints, vtkm::UInt8 shapeId, vtkm::IdComponent numberOfPointsPerCell, const vtkm::cont::ArrayHandle< vtkm::Id, ConnectivityStorageTag > &connectivity)
Definition: CellSetSingleType.h:186
vtkm::exec::arg::VisitIndex
The ExecutionSignature tag to use to get the visit index.
Definition: VisitIndex.h:43
CellSetSingleType.h
DispatcherMapTopology.h
WorkletMapTopology.h
DataSet.h
vtkm::worklet::WorkletVisitCellsWithPoints::FieldOutCell
FieldOut FieldOutCell
Definition: WorkletMapTopology.h:263
vtkm::worklet::TriangulateStructured::Run
vtkm::cont::CellSetSingleType Run(const CellSetType &cellSet, vtkm::cont::ArrayHandle< vtkm::IdComponent > &outCellsPerCell)
Definition: TriangulateStructured.h:66