Viskores  1.0
ConnectivityExtrude.h
Go to the documentation of this file.
1 //============================================================================
2 // The contents of this file are covered by the Viskores license. See
3 // LICENSE.txt for details.
4 //
5 // By contributing to this file, all contributors agree to the Developer
6 // Certificate of Origin Version 1.1 (DCO 1.1) as stated in DCO.txt.
7 //============================================================================
8 
9 //============================================================================
10 // Copyright (c) Kitware, Inc.
11 // All rights reserved.
12 // See LICENSE.txt for details.
13 //
14 // This software is distributed WITHOUT ANY WARRANTY; without even
15 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 // PURPOSE. See the above copyright notice for more information.
17 //============================================================================
18 #ifndef viskores_exec_ConnectivityExtrude_h
19 #define viskores_exec_ConnectivityExtrude_h
20 
22 
23 #include <viskores/CellShape.h>
25 
27 
28 
29 namespace viskores
30 {
31 namespace exec
32 {
33 
34 class VISKORES_ALWAYS_EXPORT ConnectivityExtrude
35 {
36 private:
39 
40 public:
43 
45 
47 
49 
50  ConnectivityExtrude() = default;
51 
53  const NextNodePortalType& nextnode,
54  viskores::Int32 cellsPerPlane,
55  viskores::Int32 pointsPerPlane,
56  viskores::Int32 numPlanes,
57  bool periodic);
58 
60  viskores::Id GetNumberOfElements() const { return this->NumberOfCells; }
61 
64 
67  {
68  return this->GetIndices(this->FlatToLogicalToIndex(index));
69  }
70 
72  IndicesType GetIndices(const viskores::Id2& index) const;
73  template <typename IndexType>
75  const IndexType& viskoresNotUsed(index)) const
76  {
77  return 6;
78  }
79 
82  {
83  return index[0] + (index[1] * this->NumberOfCellsPerPlane);
84  };
85 
88  {
89  const viskores::Id cellId = index % this->NumberOfCellsPerPlane;
90  const viskores::Id plane = index / this->NumberOfCellsPerPlane;
91  return viskores::Id2(cellId, plane);
92  }
93 
94 private:
101 };
102 
103 
105 {
106 private:
109 
110 public:
115 
117 
119 
121 
122  ReverseConnectivityExtrude() = default;
123 
126  const OffsetsPortalType& offsets,
127  const CountsPortalType& counts,
128  const PrevNodePortalType& prevNode,
129  viskores::Int32 cellsPerPlane,
130  viskores::Int32 pointsPerPlane,
131  viskores::Int32 numPlanes);
132 
135  {
136  return this->NumberOfPointsPerPlane * this->NumberOfPlanes;
137  }
138 
141 
149  {
150  return this->GetIndices(this->FlatToLogicalToIndex(index));
151  }
152 
154  IndicesType GetIndices(const viskores::Id2& index) const;
155 
156  template <typename IndexType>
158  const IndexType& viskoresNotUsed(index)) const
159  {
160  return 1;
161  }
162 
165  {
166  return index[0] + (index[1] * this->NumberOfPointsPerPlane);
167  };
168 
171  {
172  const viskores::Id vertId = index % this->NumberOfPointsPerPlane;
173  const viskores::Id plane = index / this->NumberOfPointsPerPlane;
174  return viskores::Id2(vertId, plane);
175  }
176 
184 };
185 
186 
188  const ConnectivityPortalType& nextNode,
189  viskores::Int32 cellsPerPlane,
190  viskores::Int32 pointsPerPlane,
191  viskores::Int32 numPlanes,
192  bool periodic)
193  : Connectivity(conn)
194  , NextNode(nextNode)
195  , NumberOfCellsPerPlane(cellsPerPlane)
196  , NumberOfPointsPerPlane(pointsPerPlane)
197  , NumberOfPlanes(numPlanes)
198 {
199  this->NumberOfCells = periodic ? (static_cast<viskores::Id>(cellsPerPlane) * numPlanes)
200  : (static_cast<viskores::Id>(cellsPerPlane) * (numPlanes - 1));
201 }
202 
204  const viskores::Id2& index) const
205 {
206  viskores::Id tr = index[0];
207  viskores::Id p0 = index[1];
208  viskores::Id p1 = (p0 < (this->NumberOfPlanes - 1)) ? (p0 + 1) : 0;
209 
210  viskores::Vec3i_32 pointIds1, pointIds2;
211  for (int i = 0; i < 3; ++i)
212  {
213  pointIds1[i] = this->Connectivity.Get((tr * 3) + i);
214  pointIds2[i] = this->NextNode.Get(pointIds1[i]);
215  }
216 
217  return IndicesType(pointIds1,
218  static_cast<viskores::Int32>(p0),
219  pointIds2,
220  static_cast<viskores::Int32>(p1),
221  this->NumberOfPointsPerPlane);
222 }
223 
224 
226  const ConnectivityPortalType& conn,
227  const OffsetsPortalType& offsets,
228  const CountsPortalType& counts,
229  const PrevNodePortalType& prevNode,
230  viskores::Int32 cellsPerPlane,
231  viskores::Int32 pointsPerPlane,
232  viskores::Int32 numPlanes)
233  : Connectivity(conn)
234  , Offsets(offsets)
235  , Counts(counts)
236  , PrevNode(prevNode)
237  , NumberOfCellsPerPlane(cellsPerPlane)
238  , NumberOfPointsPerPlane(pointsPerPlane)
239  , NumberOfPlanes(numPlanes)
240 {
241 }
242 
244  const viskores::Id2& index) const
245 {
246  auto ptCur = index[0];
247  auto ptPre = this->PrevNode.Get(ptCur);
248  auto plCur = index[1];
249  auto plPre = (plCur == 0) ? (this->NumberOfPlanes - 1) : (plCur - 1);
250 
251  return IndicesType(this->Connectivity,
252  this->Offsets.Get(ptPre),
253  this->Counts.Get(ptPre),
254  this->Offsets.Get(ptCur),
255  this->Counts.Get(ptCur),
256  static_cast<viskores::IdComponent>(plPre),
257  static_cast<viskores::IdComponent>(plCur),
258  this->NumberOfCellsPerPlane);
259 }
260 }
261 } // namespace viskores::exec
262 #endif
viskores::exec::ReverseConnectivityExtrude::Int32PortalType
typename Int32HandleType::ReadPortalType Int32PortalType
Definition: ConnectivityExtrude.h:108
viskores::Id2
viskores::Vec< viskores::Id, 2 > Id2
Id2 corresponds to a 2-dimensional index.
Definition: Types.h:935
ArrayHandle.h
viskores::exec::ConnectivityExtrude
Definition: ConnectivityExtrude.h:34
viskores::exec::ReverseConnectivityExtrude::IndicesType
ReverseIndicesExtrude< ConnectivityPortalType > IndicesType
Definition: ConnectivityExtrude.h:120
viskores::exec::ReverseConnectivityExtrude::PrevNode
PrevNodePortalType PrevNode
Definition: ConnectivityExtrude.h:180
viskores::exec::ReverseConnectivityExtrude::ConnectivityPortalType
Int32PortalType ConnectivityPortalType
Definition: ConnectivityExtrude.h:111
viskores::exec::ConnectivityExtrude::GetIndices
IndicesType GetIndices(viskores::Id index) const
Definition: ConnectivityExtrude.h:66
viskores::exec::ReverseConnectivityExtrude::GetIndices
IndicesType GetIndices(viskores::Id index) const
Returns a Vec-like object containing the indices for the given index.
Definition: ConnectivityExtrude.h:148
IndicesExtrude.h
viskores::exec::ConnectivityExtrude::GetNumberOfIndices
viskores::IdComponent GetNumberOfIndices(const IndexType &) const
Definition: ConnectivityExtrude.h:74
viskores::exec::ReverseConnectivityExtrude::ReverseConnectivityExtrude
ReverseConnectivityExtrude()=default
viskoresNotUsed
#define viskoresNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:136
viskores::exec::ReverseConnectivityExtrude::Offsets
OffsetsPortalType Offsets
Definition: ConnectivityExtrude.h:178
ThreadIndicesTopologyMap.h
viskores::exec::ConnectivityExtrude::ConnectivityPortalType
Int32PortalType ConnectivityPortalType
Definition: ConnectivityExtrude.h:41
viskores::cont::ArrayHandle< viskores::Int32 >
viskores::cont::ArrayHandle< viskores::Int32 >::ReadPortalType
typename StorageType::ReadPortalType ReadPortalType
The type of portal used when accessing data in a read-only mode.
Definition: ArrayHandle.h:325
viskores::IdComponent
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
CellShape.h
viskores::exec::ReverseConnectivityExtrude::CountsPortalType
Int32PortalType CountsPortalType
Definition: ConnectivityExtrude.h:113
viskores::exec::IndicesExtrude
Definition: IndicesExtrude.h:29
viskores::exec::ConnectivityExtrude::NumberOfCells
viskores::Id NumberOfCells
Definition: ConnectivityExtrude.h:100
viskores::exec::ReverseConnectivityExtrude::GetCellShape
CellShapeTag GetCellShape(viskores::Id) const
Definition: ConnectivityExtrude.h:140
viskores::exec::ReverseConnectivityExtrude
Definition: ConnectivityExtrude.h:104
viskores::CellShapeTagWedge
Definition: CellShape.h:168
viskores::Id
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
viskores::exec::ReverseIndicesExtrude
Definition: IndicesExtrude.h:79
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::exec::ReverseConnectivityExtrude::FlatToLogicalToIndex
viskores::Id2 FlatToLogicalToIndex(viskores::Id index) const
Definition: ConnectivityExtrude.h:170
viskores::CellShapeTagVertex
Definition: CellShape.h:156
viskores::exec::ConnectivityExtrude::FlatToLogicalToIndex
viskores::Id2 FlatToLogicalToIndex(viskores::Id index) const
Definition: ConnectivityExtrude.h:87
viskores::exec::ConnectivityExtrude::IndicesType
IndicesExtrude IndicesType
Definition: ConnectivityExtrude.h:48
viskores::exec::ConnectivityExtrude::GetCellShape
CellShapeTag GetCellShape(viskores::Id) const
Definition: ConnectivityExtrude.h:63
viskores::exec::ConnectivityExtrude::NumberOfCellsPerPlane
viskores::Int32 NumberOfCellsPerPlane
Definition: ConnectivityExtrude.h:97
viskores::exec::ConnectivityExtrude::NextNodePortalType
Int32PortalType NextNodePortalType
Definition: ConnectivityExtrude.h:42
viskores::exec::ReverseConnectivityExtrude::LogicalToFlatToIndex
viskores::Id LogicalToFlatToIndex(const viskores::Id2 &index) const
Definition: ConnectivityExtrude.h:164
viskores::exec::ConnectivityExtrude::NumberOfPlanes
viskores::Int32 NumberOfPlanes
Definition: ConnectivityExtrude.h:99
viskores::exec::ReverseConnectivityExtrude::Connectivity
ConnectivityPortalType Connectivity
Definition: ConnectivityExtrude.h:177
viskores::exec::ReverseConnectivityExtrude::NumberOfCellsPerPlane
viskores::Int32 NumberOfCellsPerPlane
Definition: ConnectivityExtrude.h:181
viskores::Int32
int32_t Int32
Base type to use for 32-bit signed integer numbers.
Definition: Types.h:189
viskores::exec::ReverseConnectivityExtrude::GetNumberOfIndices
viskores::IdComponent GetNumberOfIndices(const IndexType &) const
Definition: ConnectivityExtrude.h:157
viskores::exec::ReverseConnectivityExtrude::Counts
CountsPortalType Counts
Definition: ConnectivityExtrude.h:179
viskores::exec::ConnectivityExtrude::LogicalToFlatToIndex
viskores::Id LogicalToFlatToIndex(const viskores::Id2 &index) const
Definition: ConnectivityExtrude.h:81
viskores::exec::ConnectivityExtrude::GetNumberOfElements
viskores::Id GetNumberOfElements() const
Definition: ConnectivityExtrude.h:60
viskores::exec::ConnectivityExtrude::NextNode
NextNodePortalType NextNode
Definition: ConnectivityExtrude.h:96
viskores::exec::ConnectivityExtrude::NumberOfPointsPerPlane
viskores::Int32 NumberOfPointsPerPlane
Definition: ConnectivityExtrude.h:98
viskores::exec::ConnectivityExtrude::Connectivity
ConnectivityPortalType Connectivity
Definition: ConnectivityExtrude.h:95
viskores::exec::ReverseConnectivityExtrude::NumberOfPointsPerPlane
viskores::Int32 NumberOfPointsPerPlane
Definition: ConnectivityExtrude.h:182
viskores::exec::ReverseConnectivityExtrude::NumberOfPlanes
viskores::Int32 NumberOfPlanes
Definition: ConnectivityExtrude.h:183
viskores::exec::ReverseConnectivityExtrude::PrevNodePortalType
Int32PortalType PrevNodePortalType
Definition: ConnectivityExtrude.h:114
viskores::exec::ConnectivityExtrude::Int32PortalType
typename Int32HandleType::ReadPortalType Int32PortalType
Definition: ConnectivityExtrude.h:38
viskores::Vec< viskores::Id, 2 >
VISKORES_EXEC
#define VISKORES_EXEC
Definition: ExportMacros.h:59
viskores::exec::ReverseConnectivityExtrude::OffsetsPortalType
Int32PortalType OffsetsPortalType
Definition: ConnectivityExtrude.h:112
viskores::exec::ConnectivityExtrude::ConnectivityExtrude
ConnectivityExtrude()=default
viskores::exec::ReverseConnectivityExtrude::GetNumberOfElements
viskores::Id GetNumberOfElements() const
Definition: ConnectivityExtrude.h:134