VTK-m  2.0
IndicesExtrude.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 vtk_m_internal_IndicesExtrude_h
11 #define vtk_m_internal_IndicesExtrude_h
12 
13 #include <vtkm/Math.h>
14 #include <vtkm/Types.h>
15 
16 namespace vtkm
17 {
18 namespace exec
19 {
20 
22 {
23  IndicesExtrude() = default;
24 
25  VTKM_EXEC
27  vtkm::Int32 plane1,
28  vtkm::Vec3i_32 pointIds2,
29  vtkm::Int32 plane2,
30  vtkm::Int32 numberOfPointsPerPlane)
31  : PointIds{ pointIds1, pointIds2 }
32  , Planes{ plane1, plane2 }
33  , NumberOfPointsPerPlane(numberOfPointsPerPlane)
34  {
35  }
36 
37  VTKM_EXEC
39  {
40  VTKM_ASSERT(index >= 0 && index < 6);
41  if (index < 3)
42  {
43  return (static_cast<vtkm::Id>(this->NumberOfPointsPerPlane) * this->Planes[0]) +
44  this->PointIds[0][index];
45  }
46  else
47  {
48  return (static_cast<vtkm::Id>(this->NumberOfPointsPerPlane) * this->Planes[1]) +
49  this->PointIds[1][index - 3];
50  }
51  }
52 
53  VTKM_EXEC
54  constexpr vtkm::IdComponent GetNumberOfComponents() const { return 6; }
55 
56  template <typename T, vtkm::IdComponent DestSize>
58  {
59  for (vtkm::IdComponent i = 0; i < vtkm::Min(6, DestSize); ++i)
60  {
61  dest[i] = (*this)[i];
62  }
63  }
64 
68 };
69 
70 template <typename ConnectivityPortalType>
72 {
73  ReverseIndicesExtrude() = default;
74 
75  VTKM_EXEC
76  ReverseIndicesExtrude(const ConnectivityPortalType conn,
77  vtkm::Id offset1,
78  vtkm::IdComponent length1,
79  vtkm::Id offset2,
80  vtkm::IdComponent length2,
81  vtkm::IdComponent plane1,
82  vtkm::IdComponent plane2,
83  vtkm::Int32 numberOfCellsPerPlane)
84  : Connectivity(conn)
85  , Offset1(offset1)
86  , Offset2(offset2)
87  , Length1(length1)
88  , NumberOfComponents(length1 + length2)
89  , CellOffset1(plane1 * numberOfCellsPerPlane)
90  , CellOffset2(plane2 * numberOfCellsPerPlane)
91  {
92  }
93 
94  VTKM_EXEC
96  {
97  VTKM_ASSERT(index >= 0 && index < (this->NumberOfComponents));
98  if (index < this->Length1)
99  {
100  return this->Connectivity.Get(this->Offset1 + index) + this->CellOffset1;
101  }
102  else
103  {
104  return this->Connectivity.Get(this->Offset2 + index - this->Length1) + this->CellOffset2;
105  }
106  }
107 
108  VTKM_EXEC
110 
111  template <typename T, vtkm::IdComponent DestSize>
113  {
114  for (vtkm::IdComponent i = 0; i < vtkm::Min(this->NumberOfComponents, DestSize); ++i)
115  {
116  dest[i] = (*this)[i];
117  }
118  }
119 
120  ConnectivityPortalType Connectivity;
125 };
126 }
127 }
128 
129 #endif //vtkm_m_internal_IndicesExtrude_h
vtkm::exec::IndicesExtrude::IndicesExtrude
IndicesExtrude()=default
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
Types.h
vtkm::exec::ReverseIndicesExtrude::CopyInto
VTKM_EXEC void CopyInto(vtkm::Vec< T, DestSize > &dest) const
Definition: IndicesExtrude.h:112
VTKM_ASSERT
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
vtkm::exec::ReverseIndicesExtrude::ReverseIndicesExtrude
VTKM_EXEC ReverseIndicesExtrude(const ConnectivityPortalType conn, vtkm::Id offset1, vtkm::IdComponent length1, vtkm::Id offset2, vtkm::IdComponent length2, vtkm::IdComponent plane1, vtkm::IdComponent plane2, vtkm::Int32 numberOfCellsPerPlane)
Definition: IndicesExtrude.h:76
vtkm::exec::IndicesExtrude::GetNumberOfComponents
constexpr VTKM_EXEC vtkm::IdComponent GetNumberOfComponents() const
Definition: IndicesExtrude.h:54
vtkm::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
vtkm::exec::ReverseIndicesExtrude::Connectivity
ConnectivityPortalType Connectivity
Definition: IndicesExtrude.h:120
vtkm::exec::ReverseIndicesExtrude::Offset1
vtkm::Id Offset1
Definition: IndicesExtrude.h:121
vtkm::exec::IndicesExtrude::NumberOfPointsPerPlane
vtkm::Int32 NumberOfPointsPerPlane
Definition: IndicesExtrude.h:67
vtkm::exec::ReverseIndicesExtrude::NumberOfComponents
vtkm::IdComponent NumberOfComponents
Definition: IndicesExtrude.h:123
vtkm::exec::IndicesExtrude::Planes
vtkm::Int32 Planes[2]
Definition: IndicesExtrude.h:66
vtkm::exec::ReverseIndicesExtrude::Length1
vtkm::IdComponent Length1
Definition: IndicesExtrude.h:122
vtkm::exec::ReverseIndicesExtrude
Definition: IndicesExtrude.h:71
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
Math.h
vtkm::exec::ReverseIndicesExtrude::Offset2
vtkm::Id Offset2
Definition: IndicesExtrude.h:121
vtkm::exec::IndicesExtrude
Definition: IndicesExtrude.h:21
vtkm::exec::IndicesExtrude::PointIds
vtkm::Vec3i_32 PointIds[2]
Definition: IndicesExtrude.h:65
vtkm::exec::IndicesExtrude::IndicesExtrude
VTKM_EXEC IndicesExtrude(vtkm::Vec3i_32 pointIds1, vtkm::Int32 plane1, vtkm::Vec3i_32 pointIds2, vtkm::Int32 plane2, vtkm::Int32 numberOfPointsPerPlane)
Definition: IndicesExtrude.h:26
vtkm::Vec< vtkm::Int32, 3 >
vtkm::exec::ReverseIndicesExtrude::GetNumberOfComponents
VTKM_EXEC vtkm::IdComponent GetNumberOfComponents() const
Definition: IndicesExtrude.h:109
vtkm::Int32
int32_t Int32
Definition: Types.h:160
vtkm::exec::IndicesExtrude::CopyInto
VTKM_EXEC void CopyInto(vtkm::Vec< T, DestSize > &dest) const
Definition: IndicesExtrude.h:57
vtkm::exec::ReverseIndicesExtrude::CellOffset2
vtkm::Id CellOffset2
Definition: IndicesExtrude.h:124
vtkm::exec::ReverseIndicesExtrude::operator[]
VTKM_EXEC vtkm::Id operator[](vtkm::IdComponent index) const
Definition: IndicesExtrude.h:95
vtkm::exec::IndicesExtrude::operator[]
VTKM_EXEC vtkm::Id operator[](vtkm::IdComponent index) const
Definition: IndicesExtrude.h:38
vtkm::exec::ReverseIndicesExtrude::CellOffset1
vtkm::Id CellOffset1
Definition: IndicesExtrude.h:124
vtkm::exec::ReverseIndicesExtrude::ReverseIndicesExtrude
ReverseIndicesExtrude()=default