Viskores  1.0
CellSetExtrude.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_cont_CellSetExtrude_h
19 #define viskores_cont_CellSetExtrude_h
20 
25 #include <viskores/cont/CellSet.h>
26 #include <viskores/cont/Invoker.h>
29 
30 namespace viskores
31 {
32 namespace cont
33 {
34 
35 namespace detail
36 {
37 
38 template <typename VisitTopology, typename IncidentTopology>
39 struct CellSetExtrudeConnectivityChooser;
40 
41 template <>
42 struct CellSetExtrudeConnectivityChooser<viskores::TopologyElementTagCell,
44 {
45  using ExecConnectivityType = viskores::exec::ConnectivityExtrude;
46 };
47 
48 template <>
49 struct CellSetExtrudeConnectivityChooser<viskores::TopologyElementTagPoint,
51 {
52  using ExecConnectivityType = viskores::exec::ReverseConnectivityExtrude;
53 };
54 
55 } // namespace detail
56 
64 class VISKORES_CONT_EXPORT CellSetExtrude : public CellSet
65 {
66 public:
68 
70  viskores::Int32 numberOfPointsPerPlane,
71  viskores::Int32 numberOfPlanes,
73  bool periodic);
74 
77 
78  VISKORES_CONT CellSetExtrude& operator=(const CellSetExtrude& src);
79  VISKORES_CONT CellSetExtrude& operator=(CellSetExtrude&& src) noexcept;
80 
81  ~CellSetExtrude() override;
82 
83  viskores::Int32 GetNumberOfPlanes() const;
84 
85  viskores::Id GetNumberOfCells() const override;
86 
87  viskores::Id GetNumberOfPoints() const override;
88 
89  viskores::Id GetNumberOfFaces() const override;
90 
91  viskores::Id GetNumberOfEdges() const override;
92 
94 
96 
97  viskores::UInt8 GetCellShape(viskores::Id id) const override;
98  viskores::IdComponent GetNumberOfPointsInCell(viskores::Id id) const override;
99  void GetCellPointIds(viskores::Id id, viskores::Id* ptids) const override;
100 
101  std::shared_ptr<CellSet> NewInstance() const override;
102  void DeepCopy(const CellSet* src) override;
103 
104  void PrintSummary(std::ostream& out) const override;
105  void ReleaseResourcesExecution() override;
106 
108  {
109  return this->Connectivity;
110  }
111 
112  viskores::Int32 GetNumberOfPointsPerPlane() const { return this->NumberOfPointsPerPlane; }
113 
115  {
116  return this->NextNode;
117  }
118 
119  bool GetIsPeriodic() const { return this->IsPeriodic; }
120 
121  template <viskores::IdComponent NumIndices>
122  VISKORES_CONT void GetIndices(viskores::Id index,
124 
125  VISKORES_CONT void GetIndices(viskores::Id index,
127 
128  template <typename VisitTopology, typename IncidentTopology>
129  using ExecConnectivityType =
130  typename detail::CellSetExtrudeConnectivityChooser<VisitTopology,
131  IncidentTopology>::ExecConnectivityType;
132 
136  viskores::cont::Token&) const;
137 
141  viskores::cont::Token&) const;
142 
143 private:
144  void BuildReverseConnectivity();
145 
147 
153 
159 };
160 
161 template <typename T>
165  bool periodic = true)
166 {
167  return CellSetExtrude{
168  conn, coords.GetNumberOfPointsPerPlane(), coords.GetNumberOfPlanes(), nextNode, periodic
169  };
170 }
171 
172 template <typename T>
173 CellSetExtrude make_CellSetExtrude(const std::vector<viskores::Int32>& conn,
175  const std::vector<viskores::Int32>& nextNode,
176  bool periodic = true)
177 {
179  static_cast<viskores::Int32>(coords.GetNumberOfPointsPerPlane()),
180  static_cast<viskores::Int32>(coords.GetNumberOfPlanes()),
182  periodic };
183 }
184 
185 template <typename T>
186 CellSetExtrude make_CellSetExtrude(std::vector<viskores::Int32>&& conn,
188  std::vector<viskores::Int32>&& nextNode,
189  bool periodic = true)
190 {
191  return CellSetExtrude{ viskores::cont::make_ArrayHandleMove(std::move(conn)),
192  static_cast<viskores::Int32>(coords.GetNumberOfPointsPerPlane()),
193  static_cast<viskores::Int32>(coords.GetNumberOfPlanes()),
194  viskores::cont::make_ArrayHandleMove(std::move(nextNode)),
195  periodic };
196 }
197 }
198 } // viskores::cont
199 
200 
201 //=============================================================================
202 // Specializations of serialization related classes
204 namespace viskores
205 {
206 namespace cont
207 {
208 
209 template <>
210 struct SerializableTypeString<viskores::cont::CellSetExtrude>
211 {
212  static VISKORES_CONT const std::string& Get()
213  {
214  static std::string name = "CS_Extrude";
215  return name;
216  }
217 };
218 }
219 } // viskores::cont
220 
221 namespace mangled_diy_namespace
222 {
223 
224 template <>
225 struct Serialization<viskores::cont::CellSetExtrude>
226 {
227 private:
228  using Type = viskores::cont::CellSetExtrude;
229 
230 public:
231  static VISKORES_CONT void save(BinaryBuffer& bb, const Type& cs)
232  {
233  viskoresdiy::save(bb, cs.GetNumberOfPointsPerPlane());
234  viskoresdiy::save(bb, cs.GetNumberOfPlanes());
235  viskoresdiy::save(bb, cs.GetIsPeriodic());
236  viskoresdiy::save(bb, cs.GetConnectivityArray());
237  viskoresdiy::save(bb, cs.GetNextNodeArray());
238  }
239 
240  static VISKORES_CONT void load(BinaryBuffer& bb, Type& cs)
241  {
242  viskores::Int32 numberOfPointsPerPlane;
243  viskores::Int32 numberOfPlanes;
244  bool isPeriodic;
247 
248  viskoresdiy::load(bb, numberOfPointsPerPlane);
249  viskoresdiy::load(bb, numberOfPlanes);
250  viskoresdiy::load(bb, isPeriodic);
251  viskoresdiy::load(bb, conn);
252  viskoresdiy::load(bb, nextNode);
253 
254  cs = Type{ conn, numberOfPointsPerPlane, numberOfPlanes, nextNode, isPeriodic };
255  }
256 };
257 
258 } // diy
260 
261 #endif // viskores_cont_CellSetExtrude.h
viskores::exec::arg::load
T load(const U &u, viskores::Id v)
Definition: FetchTagArrayDirectIn.h:44
viskores::cont::CellSetExtrude::NextNode
viskores::cont::ArrayHandle< viskores::Int32 > NextNode
Definition: CellSetExtrude.h:152
ArrayHandle.h
viskores::exec::ConnectivityExtrude
Definition: ConnectivityExtrude.h:34
viskores::TopologyElementTagCell
A tag used to identify the cell elements in a topology.
Definition: TopologyElementTag.h:32
ThreadIndicesExtrude.h
viskores::cont::CellSetExtrude::NumberOfPlanes
viskores::Int32 NumberOfPlanes
Definition: CellSetExtrude.h:150
viskores::cont::make_CellSetExtrude
CellSetExtrude make_CellSetExtrude(const viskores::cont::ArrayHandle< viskores::Int32 > &conn, const viskores::cont::ArrayHandleXGCCoordinates< T > &coords, const viskores::cont::ArrayHandle< viskores::Int32 > &nextNode, bool periodic=true)
Definition: CellSetExtrude.h:162
viskores::cont::ArrayHandle< viskores::Int32 >
viskores::cont::CellSetExtrude::NumberOfPointsPerPlane
viskores::Int32 NumberOfPointsPerPlane
Definition: CellSetExtrude.h:148
viskores::cont::CellSetExtrude::GetIsPeriodic
bool GetIsPeriodic() const
Definition: CellSetExtrude.h:119
Invoker.h
viskores::IdComponent
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
viskores::cont::make_ArrayHandleMove
viskores::cont::ArrayHandleBasic< T > make_ArrayHandleMove(T *&array, viskores::Id numberOfValues, viskores::cont::internal::BufferInfo::Deleter deleter=internal::SimpleArrayDeleter< T >, viskores::cont::internal::BufferInfo::Reallocater reallocater=internal::SimpleArrayReallocater< T >)
A convenience function to move a user-allocated array into an ArrayHandle.
Definition: ArrayHandleBasic.h:310
mangled_diy_namespace
Definition: Particle.h:373
ConnectivityExtrude.h
viskores::TopologyElementTagPoint
A tag used to identify the point elements in a topology.
Definition: TopologyElementTag.h:42
viskores::exec::ReverseConnectivityExtrude
Definition: ConnectivityExtrude.h:104
viskores::Id
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
viskores::cont::CellSetExtrude::ROffsets
viskores::cont::ArrayHandle< viskores::Int32 > ROffsets
Definition: CellSetExtrude.h:156
viskores::cont::CellSetExtrude::GetNextNodeArray
const viskores::cont::ArrayHandle< viskores::Int32 > & GetNextNodeArray() const
Definition: CellSetExtrude.h:114
VISKORES_CONT
#define VISKORES_CONT
Definition: ExportMacros.h:65
viskores::cont::CellSetExtrude::GetConnectivityArray
const viskores::cont::ArrayHandle< viskores::Int32 > & GetConnectivityArray() const
Definition: CellSetExtrude.h:107
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::cont::CellSetExtrude::ReverseConnectivityBuilt
bool ReverseConnectivityBuilt
Definition: CellSetExtrude.h:154
viskores::CopyFlag::On
@ On
viskores::cont::ArrayHandleXGCCoordinates::GetNumberOfPointsPerPlane
viskores::Id GetNumberOfPointsPerPlane() const
Definition: ArrayHandleXGCCoordinates.h:347
viskores::cont::CellSetExtrude::ExecConnectivityType
typename detail::CellSetExtrudeConnectivityChooser< VisitTopology, IncidentTopology >::ExecConnectivityType ExecConnectivityType
Definition: CellSetExtrude.h:131
viskores::cont::CellSetExtrude::Connectivity
viskores::cont::ArrayHandle< viskores::Int32 > Connectivity
Definition: CellSetExtrude.h:151
CellSet.h
viskores::cont::CellSetExtrude::IsPeriodic
bool IsPeriodic
Definition: CellSetExtrude.h:146
viskores::cont::CellSetExtrude::RCounts
viskores::cont::ArrayHandle< viskores::Int32 > RCounts
Definition: CellSetExtrude.h:157
viskores::cont::CellSetExtrude::RConnectivity
viskores::cont::ArrayHandle< viskores::Int32 > RConnectivity
Definition: CellSetExtrude.h:155
viskores::UInt8
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:177
viskores::cont::DeviceAdapterId
An object used to specify a device.
Definition: DeviceAdapterTag.h:66
viskores::Int32
int32_t Int32
Base type to use for 32-bit signed integer numbers.
Definition: Types.h:189
viskores::cont::ArrayHandleXGCCoordinates
Definition: ArrayHandleXGCCoordinates.h:298
viskores::cont::CellSetExtrude::GetNumberOfPointsPerPlane
viskores::Int32 GetNumberOfPointsPerPlane() const
Definition: CellSetExtrude.h:112
ArrayHandleCounting.h
viskores::Get
auto Get(const viskores::Tuple< Ts... > &tuple)
Retrieve the object from a viskores::Tuple at the given index.
Definition: Tuple.h:89
viskores::cont::CellSetExtrude::NumberOfCellsPerPlane
viskores::Int32 NumberOfCellsPerPlane
Definition: CellSetExtrude.h:149
viskores::cont::CellSetExtrude::PrevNode
viskores::cont::ArrayHandle< viskores::Int32 > PrevNode
Definition: CellSetExtrude.h:158
viskores::cont::ArrayHandleXGCCoordinates::GetNumberOfPlanes
viskores::Id GetNumberOfPlanes() const
Definition: ArrayHandleXGCCoordinates.h:327
viskores::cont::CellSetExtrude
Defines a 3-dimensional extruded mesh representation.
Definition: CellSetExtrude.h:64
viskores::cont::make_ArrayHandle
viskores::cont::ArrayHandleBasic< T > make_ArrayHandle(const T *array, viskores::Id numberOfValues, viskores::CopyFlag copy)
A convenience function for creating an ArrayHandle from a standard C array.
Definition: ArrayHandleBasic.h:285
ArrayHandleXGCCoordinates.h
viskores::Vec< viskores::Id, 2 >
viskores::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:43
viskores::cont::CellSet
Defines the topological structure of the data in a DataSet.
Definition: CellSet.h:36
TopologyElementTag.h