VTK-m  2.2
ConnectivityExtrude.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_exec_ConnectivityExtrude_h
11 #define vtk_m_exec_ConnectivityExtrude_h
12 
14 
15 #include <vtkm/CellShape.h>
16 #include <vtkm/cont/ArrayHandle.h>
17 
19 
20 
21 namespace vtkm
22 {
23 namespace exec
24 {
25 
27 {
28 private:
31 
32 public:
35 
37 
39 
41 
42  ConnectivityExtrude() = default;
43 
45  const NextNodePortalType& nextnode,
46  vtkm::Int32 cellsPerPlane,
47  vtkm::Int32 pointsPerPlane,
48  vtkm::Int32 numPlanes,
49  bool periodic);
50 
51  VTKM_EXEC
52  vtkm::Id GetNumberOfElements() const { return this->NumberOfCells; }
53 
54  VTKM_EXEC
56 
57  VTKM_EXEC
59  {
60  return this->GetIndices(this->FlatToLogicalToIndex(index));
61  }
62 
63  VTKM_EXEC
64  IndicesType GetIndices(const vtkm::Id2& index) const;
65  template <typename IndexType>
67  {
68  return 6;
69  }
70 
71  VTKM_EXEC
73  {
74  return index[0] + (index[1] * this->NumberOfCellsPerPlane);
75  };
76 
77  VTKM_EXEC
79  {
80  const vtkm::Id cellId = index % this->NumberOfCellsPerPlane;
81  const vtkm::Id plane = index / this->NumberOfCellsPerPlane;
82  return vtkm::Id2(cellId, plane);
83  }
84 
85 private:
92 };
93 
94 
96 {
97 private:
100 
101 public:
106 
108 
110 
112 
113  ReverseConnectivityExtrude() = default;
114 
115  VTKM_EXEC
117  const OffsetsPortalType& offsets,
118  const CountsPortalType& counts,
119  const PrevNodePortalType& prevNode,
120  vtkm::Int32 cellsPerPlane,
121  vtkm::Int32 pointsPerPlane,
122  vtkm::Int32 numPlanes);
123 
124  VTKM_EXEC
126  {
127  return this->NumberOfPointsPerPlane * this->NumberOfPlanes;
128  }
129 
130  VTKM_EXEC
132 
138  VTKM_EXEC
140  {
141  return this->GetIndices(this->FlatToLogicalToIndex(index));
142  }
143 
144  VTKM_EXEC
145  IndicesType GetIndices(const vtkm::Id2& index) const;
146 
147  template <typename IndexType>
149  {
150  return 1;
151  }
152 
153  VTKM_EXEC
155  {
156  return index[0] + (index[1] * this->NumberOfPointsPerPlane);
157  };
158 
159  VTKM_EXEC
161  {
162  const vtkm::Id vertId = index % this->NumberOfPointsPerPlane;
163  const vtkm::Id plane = index / this->NumberOfPointsPerPlane;
164  return vtkm::Id2(vertId, plane);
165  }
166 
174 };
175 
176 
178  const ConnectivityPortalType& nextNode,
179  vtkm::Int32 cellsPerPlane,
180  vtkm::Int32 pointsPerPlane,
181  vtkm::Int32 numPlanes,
182  bool periodic)
183  : Connectivity(conn)
184  , NextNode(nextNode)
185  , NumberOfCellsPerPlane(cellsPerPlane)
186  , NumberOfPointsPerPlane(pointsPerPlane)
187  , NumberOfPlanes(numPlanes)
188 {
189  this->NumberOfCells = periodic ? (static_cast<vtkm::Id>(cellsPerPlane) * numPlanes)
190  : (static_cast<vtkm::Id>(cellsPerPlane) * (numPlanes - 1));
191 }
192 
194  const vtkm::Id2& index) const
195 {
196  vtkm::Id tr = index[0];
197  vtkm::Id p0 = index[1];
198  vtkm::Id p1 = (p0 < (this->NumberOfPlanes - 1)) ? (p0 + 1) : 0;
199 
200  vtkm::Vec3i_32 pointIds1, pointIds2;
201  for (int i = 0; i < 3; ++i)
202  {
203  pointIds1[i] = this->Connectivity.Get((tr * 3) + i);
204  pointIds2[i] = this->NextNode.Get(pointIds1[i]);
205  }
206 
207  return IndicesType(pointIds1,
208  static_cast<vtkm::Int32>(p0),
209  pointIds2,
210  static_cast<vtkm::Int32>(p1),
211  this->NumberOfPointsPerPlane);
212 }
213 
214 
216  const ConnectivityPortalType& conn,
217  const OffsetsPortalType& offsets,
218  const CountsPortalType& counts,
219  const PrevNodePortalType& prevNode,
220  vtkm::Int32 cellsPerPlane,
221  vtkm::Int32 pointsPerPlane,
222  vtkm::Int32 numPlanes)
223  : Connectivity(conn)
224  , Offsets(offsets)
225  , Counts(counts)
226  , PrevNode(prevNode)
227  , NumberOfCellsPerPlane(cellsPerPlane)
228  , NumberOfPointsPerPlane(pointsPerPlane)
229  , NumberOfPlanes(numPlanes)
230 {
231 }
232 
234  const vtkm::Id2& index) const
235 {
236  auto ptCur = index[0];
237  auto ptPre = this->PrevNode.Get(ptCur);
238  auto plCur = index[1];
239  auto plPre = (plCur == 0) ? (this->NumberOfPlanes - 1) : (plCur - 1);
240 
241  return IndicesType(this->Connectivity,
242  this->Offsets.Get(ptPre),
243  this->Counts.Get(ptPre),
244  this->Offsets.Get(ptCur),
245  this->Counts.Get(ptCur),
246  static_cast<vtkm::IdComponent>(plPre),
247  static_cast<vtkm::IdComponent>(plCur),
248  this->NumberOfCellsPerPlane);
249 }
250 }
251 } // namespace vtkm::exec
252 #endif
vtkm::exec::ReverseConnectivityExtrude::FlatToLogicalToIndex
vtkm::Id2 FlatToLogicalToIndex(vtkm::Id index) const
Definition: ConnectivityExtrude.h:160
vtkm::exec::ReverseConnectivityExtrude
Definition: ConnectivityExtrude.h:95
vtkm::cont::ArrayHandle< vtkm::Int32 >
ArrayHandle.h
vtkm::exec::ReverseConnectivityExtrude::NumberOfCellsPerPlane
vtkm::Int32 NumberOfCellsPerPlane
Definition: ConnectivityExtrude.h:171
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::exec::ReverseConnectivityExtrude::LogicalToFlatToIndex
vtkm::Id LogicalToFlatToIndex(const vtkm::Id2 &index) const
Definition: ConnectivityExtrude.h:154
vtkm::exec::ConnectivityExtrude::ConnectivityExtrude
ConnectivityExtrude()=default
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
IndicesExtrude.h
vtkm::exec::ReverseConnectivityExtrude::PrevNodePortalType
Int32PortalType PrevNodePortalType
Definition: ConnectivityExtrude.h:105
vtkm::exec::ReverseConnectivityExtrude::NumberOfPointsPerPlane
vtkm::Int32 NumberOfPointsPerPlane
Definition: ConnectivityExtrude.h:172
ThreadIndicesTopologyMap.h
vtkm::exec::ReverseConnectivityExtrude::OffsetsPortalType
Int32PortalType OffsetsPortalType
Definition: ConnectivityExtrude.h:103
CellShape.h
vtkm::exec::ReverseConnectivityExtrude::ConnectivityPortalType
Int32PortalType ConnectivityPortalType
Definition: ConnectivityExtrude.h:102
vtkm::cont::ArrayHandle< vtkm::Int32 >::ReadPortalType
typename StorageType::ReadPortalType ReadPortalType
The type of portal used when accessing data in a read-only mode.
Definition: ArrayHandle.h:312
vtkm::exec::ReverseIndicesExtrude
Definition: IndicesExtrude.h:71
vtkm::exec::ReverseConnectivityExtrude::GetNumberOfElements
vtkm::Id GetNumberOfElements() const
Definition: ConnectivityExtrude.h:125
vtkm::exec::ConnectivityExtrude::Connectivity
ConnectivityPortalType Connectivity
Definition: ConnectivityExtrude.h:86
vtkm::exec::ConnectivityExtrude::NextNodePortalType
Int32PortalType NextNodePortalType
Definition: ConnectivityExtrude.h:34
vtkm::exec::ReverseConnectivityExtrude::IndicesType
ReverseIndicesExtrude< ConnectivityPortalType > IndicesType
Definition: ConnectivityExtrude.h:111
vtkm::exec::ConnectivityExtrude::GetNumberOfElements
vtkm::Id GetNumberOfElements() const
Definition: ConnectivityExtrude.h:52
vtkm::exec::ReverseConnectivityExtrude::NumberOfPlanes
vtkm::Int32 NumberOfPlanes
Definition: ConnectivityExtrude.h:173
vtkm::exec::ConnectivityExtrude::IndicesType
IndicesExtrude IndicesType
Definition: ConnectivityExtrude.h:40
vtkm::exec::ConnectivityExtrude::FlatToLogicalToIndex
vtkm::Id2 FlatToLogicalToIndex(vtkm::Id index) const
Definition: ConnectivityExtrude.h:78
vtkm::CellShapeTagVertex
Definition: CellShape.h:148
vtkm::exec::ReverseConnectivityExtrude::Counts
CountsPortalType Counts
Definition: ConnectivityExtrude.h:169
vtkm::exec::ConnectivityExtrude::NumberOfPlanes
vtkm::Int32 NumberOfPlanes
Definition: ConnectivityExtrude.h:90
vtkm::exec::ReverseConnectivityExtrude::PrevNode
PrevNodePortalType PrevNode
Definition: ConnectivityExtrude.h:170
vtkm::exec::ConnectivityExtrude::LogicalToFlatToIndex
vtkm::Id LogicalToFlatToIndex(const vtkm::Id2 &index) const
Definition: ConnectivityExtrude.h:72
vtkm::exec::ReverseConnectivityExtrude::Offsets
OffsetsPortalType Offsets
Definition: ConnectivityExtrude.h:168
vtkm::exec::ReverseConnectivityExtrude::Connectivity
ConnectivityPortalType Connectivity
Definition: ConnectivityExtrude.h:167
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
vtkm::exec::IndicesExtrude
Definition: IndicesExtrude.h:21
vtkm::exec::ConnectivityExtrude
Definition: ConnectivityExtrude.h:26
vtkm::exec::ConnectivityExtrude::GetIndices
IndicesType GetIndices(vtkm::Id index) const
Definition: ConnectivityExtrude.h:58
vtkm::exec::ConnectivityExtrude::Int32PortalType
typename Int32HandleType::ReadPortalType Int32PortalType
Definition: ConnectivityExtrude.h:30
vtkmNotUsed
#define vtkmNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:128
vtkm::Vec< vtkm::Id, 2 >
vtkm::exec::ConnectivityExtrude::NumberOfCells
vtkm::Id NumberOfCells
Definition: ConnectivityExtrude.h:91
vtkm::exec::ConnectivityExtrude::NextNode
NextNodePortalType NextNode
Definition: ConnectivityExtrude.h:87
vtkm::exec::ConnectivityExtrude::NumberOfCellsPerPlane
vtkm::Int32 NumberOfCellsPerPlane
Definition: ConnectivityExtrude.h:88
vtkm::exec::ReverseConnectivityExtrude::GetIndices
IndicesType GetIndices(vtkm::Id index) const
Returns a Vec-like object containing the indices for the given index.
Definition: ConnectivityExtrude.h:139
vtkm::exec::ConnectivityExtrude::GetCellShape
CellShapeTag GetCellShape(vtkm::Id) const
Definition: ConnectivityExtrude.h:55
vtkm::Int32
int32_t Int32
Base type to use for 32-bit signed integer numbers.
Definition: Types.h:181
vtkm::exec::ConnectivityExtrude::NumberOfPointsPerPlane
vtkm::Int32 NumberOfPointsPerPlane
Definition: ConnectivityExtrude.h:89
vtkm::CellShapeTagWedge
Definition: CellShape.h:160
vtkm::exec::ConnectivityExtrude::GetNumberOfIndices
vtkm::IdComponent GetNumberOfIndices(const IndexType &) const
Definition: ConnectivityExtrude.h:66
vtkm::exec::ReverseConnectivityExtrude::Int32PortalType
typename Int32HandleType::ReadPortalType Int32PortalType
Definition: ConnectivityExtrude.h:99
VTKM_ALWAYS_EXPORT
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:89
vtkm::exec::ReverseConnectivityExtrude::CountsPortalType
Int32PortalType CountsPortalType
Definition: ConnectivityExtrude.h:104
vtkm::exec::ConnectivityExtrude::ConnectivityPortalType
Int32PortalType ConnectivityPortalType
Definition: ConnectivityExtrude.h:33
vtkm::exec::ReverseConnectivityExtrude::ReverseConnectivityExtrude
ReverseConnectivityExtrude()=default
vtkm::exec::ReverseConnectivityExtrude::GetNumberOfIndices
vtkm::IdComponent GetNumberOfIndices(const IndexType &) const
Definition: ConnectivityExtrude.h:148
vtkm::exec::ReverseConnectivityExtrude::GetCellShape
CellShapeTag GetCellShape(vtkm::Id) const
Definition: ConnectivityExtrude.h:131
vtkm::Id2
vtkm::Vec< vtkm::Id, 2 > Id2
Id2 corresponds to a 2-dimensional index.
Definition: Types.h:923