Viskores  1.0
IndicesExtrude.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_internal_IndicesExtrude_h
19 #define viskores_internal_IndicesExtrude_h
20 
21 #include <viskores/Math.h>
22 #include <viskores/Types.h>
23 
24 namespace viskores
25 {
26 namespace exec
27 {
28 
30 {
31  IndicesExtrude() = default;
32 
35  viskores::Int32 plane1,
36  viskores::Vec3i_32 pointIds2,
37  viskores::Int32 plane2,
38  viskores::Int32 numberOfPointsPerPlane)
39  : PointIds{ pointIds1, pointIds2 }
40  , Planes{ plane1, plane2 }
41  , NumberOfPointsPerPlane(numberOfPointsPerPlane)
42  {
43  }
44 
47  {
48  VISKORES_ASSERT(index >= 0 && index < 6);
49  if (index < 3)
50  {
51  return (static_cast<viskores::Id>(this->NumberOfPointsPerPlane) * this->Planes[0]) +
52  this->PointIds[0][index];
53  }
54  else
55  {
56  return (static_cast<viskores::Id>(this->NumberOfPointsPerPlane) * this->Planes[1]) +
57  this->PointIds[1][index - 3];
58  }
59  }
60 
62  constexpr viskores::IdComponent GetNumberOfComponents() const { return 6; }
63 
64  template <typename T, viskores::IdComponent DestSize>
66  {
67  for (viskores::IdComponent i = 0; i < viskores::Min(6, DestSize); ++i)
68  {
69  dest[i] = (*this)[i];
70  }
71  }
72 
76 };
77 
78 template <typename ConnectivityPortalType>
80 {
81  ReverseIndicesExtrude() = default;
82 
84  ReverseIndicesExtrude(const ConnectivityPortalType conn,
85  viskores::Id offset1,
86  viskores::IdComponent length1,
87  viskores::Id offset2,
88  viskores::IdComponent length2,
89  viskores::IdComponent plane1,
90  viskores::IdComponent plane2,
91  viskores::Int32 numberOfCellsPerPlane)
92  : Connectivity(conn)
93  , Offset1(offset1)
94  , Offset2(offset2)
95  , Length1(length1)
96  , NumberOfComponents(length1 + length2)
97  , CellOffset1(plane1 * numberOfCellsPerPlane)
98  , CellOffset2(plane2 * numberOfCellsPerPlane)
99  {
100  }
101 
104  {
105  VISKORES_ASSERT(index >= 0 && index < (this->NumberOfComponents));
106  if (index < this->Length1)
107  {
108  return this->Connectivity.Get(this->Offset1 + index) + this->CellOffset1;
109  }
110  else
111  {
112  return this->Connectivity.Get(this->Offset2 + index - this->Length1) + this->CellOffset2;
113  }
114  }
115 
118 
119  template <typename T, viskores::IdComponent DestSize>
121  {
122  for (viskores::IdComponent i = 0; i < viskores::Min(this->NumberOfComponents, DestSize); ++i)
123  {
124  dest[i] = (*this)[i];
125  }
126  }
127 
128  ConnectivityPortalType Connectivity;
133 };
134 }
135 }
136 
137 #endif //viskores_m_internal_IndicesExtrude_h
viskores::exec::ReverseIndicesExtrude::operator[]
viskores::Id operator[](viskores::IdComponent index) const
Definition: IndicesExtrude.h:103
viskores::exec::ReverseIndicesExtrude::CopyInto
void CopyInto(viskores::Vec< T, DestSize > &dest) const
Definition: IndicesExtrude.h:120
viskores::exec::ReverseIndicesExtrude::ReverseIndicesExtrude
ReverseIndicesExtrude(const ConnectivityPortalType conn, viskores::Id offset1, viskores::IdComponent length1, viskores::Id offset2, viskores::IdComponent length2, viskores::IdComponent plane1, viskores::IdComponent plane2, viskores::Int32 numberOfCellsPerPlane)
Definition: IndicesExtrude.h:84
Types.h
viskores::IdComponent
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
viskores::exec::IndicesExtrude::IndicesExtrude
IndicesExtrude()=default
viskores::exec::IndicesExtrude::PointIds
viskores::Vec3i_32 PointIds[2]
Definition: IndicesExtrude.h:73
viskores::exec::IndicesExtrude
Definition: IndicesExtrude.h:29
viskores::exec::IndicesExtrude::NumberOfPointsPerPlane
viskores::Int32 NumberOfPointsPerPlane
Definition: IndicesExtrude.h:75
viskores::exec::ReverseIndicesExtrude::Offset1
viskores::Id Offset1
Definition: IndicesExtrude.h:129
viskores::exec::ReverseIndicesExtrude::Connectivity
ConnectivityPortalType Connectivity
Definition: IndicesExtrude.h:128
viskores::exec::ReverseIndicesExtrude::Length1
viskores::IdComponent Length1
Definition: IndicesExtrude.h:130
viskores::Id
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
viskores::exec::IndicesExtrude::IndicesExtrude
IndicesExtrude(viskores::Vec3i_32 pointIds1, viskores::Int32 plane1, viskores::Vec3i_32 pointIds2, viskores::Int32 plane2, viskores::Int32 numberOfPointsPerPlane)
Definition: IndicesExtrude.h:34
viskores::exec::ReverseIndicesExtrude
Definition: IndicesExtrude.h:79
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
Math.h
viskores::exec::IndicesExtrude::operator[]
viskores::Id operator[](viskores::IdComponent index) const
Definition: IndicesExtrude.h:46
VISKORES_ASSERT
#define VISKORES_ASSERT(condition)
Definition: Assert.h:51
viskores::exec::ReverseIndicesExtrude::GetNumberOfComponents
viskores::IdComponent GetNumberOfComponents() const
Definition: IndicesExtrude.h:117
viskores::exec::ReverseIndicesExtrude::CellOffset1
viskores::Id CellOffset1
Definition: IndicesExtrude.h:132
viskores::exec::ReverseIndicesExtrude::ReverseIndicesExtrude
ReverseIndicesExtrude()=default
viskores::Int32
int32_t Int32
Base type to use for 32-bit signed integer numbers.
Definition: Types.h:189
viskores::exec::IndicesExtrude::CopyInto
void CopyInto(viskores::Vec< T, DestSize > &dest) const
Definition: IndicesExtrude.h:65
viskores::exec::IndicesExtrude::GetNumberOfComponents
constexpr viskores::IdComponent GetNumberOfComponents() const
Definition: IndicesExtrude.h:62
viskores::exec::ReverseIndicesExtrude::NumberOfComponents
viskores::IdComponent NumberOfComponents
Definition: IndicesExtrude.h:131
viskores::exec::ReverseIndicesExtrude::CellOffset2
viskores::Id CellOffset2
Definition: IndicesExtrude.h:132
viskores::Vec< viskores::Int32, 3 >
VISKORES_EXEC
#define VISKORES_EXEC
Definition: ExportMacros.h:59
viskores::exec::ReverseIndicesExtrude::Offset2
viskores::Id Offset2
Definition: IndicesExtrude.h:129
viskores::exec::IndicesExtrude::Planes
viskores::Int32 Planes[2]
Definition: IndicesExtrude.h:74