VTK-m  2.0
ConnectivityExplicit.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_ConnectivityExplicit_h
11 #define vtk_m_exec_ConnectivityExplicit_h
12 
13 #include <vtkm/CellShape.h>
14 #include <vtkm/Types.h>
15 
16 #include <vtkm/VecFromPortal.h>
17 
18 namespace vtkm
19 {
20 namespace exec
21 {
22 
23 template <typename ShapesPortalType, typename ConnectivityPortalType, typename OffsetsPortalType>
25 {
26 public:
28 
30 
31  ConnectivityExplicit(const ShapesPortalType& shapesPortal,
32  const ConnectivityPortalType& connPortal,
33  const OffsetsPortalType& offsetsPortal)
34  : Shapes(shapesPortal)
35  , Connectivity(connPortal)
36  , Offsets(offsetsPortal)
37  {
38  }
39 
40  VTKM_EXEC
41  SchedulingRangeType GetNumberOfElements() const { return this->Shapes.GetNumberOfValues(); }
42 
44 
45  VTKM_EXEC
46  CellShapeTag GetCellShape(vtkm::Id index) const { return CellShapeTag(this->Shapes.Get(index)); }
47 
48  VTKM_EXEC
50  {
51  return static_cast<vtkm::IdComponent>(this->Offsets.Get(index + 1) - this->Offsets.Get(index));
52  }
53 
55 
61  VTKM_EXEC
63  {
64  const vtkm::Id offset = this->Offsets.Get(index);
65  const vtkm::Id endOffset = this->Offsets.Get(index + 1);
66  const auto length = static_cast<vtkm::IdComponent>(endOffset - offset);
67 
68  return IndicesType(this->Connectivity, length, offset);
69  }
70 
71 private:
72  ShapesPortalType Shapes;
73  ConnectivityPortalType Connectivity;
74  OffsetsPortalType Offsets;
75 };
76 
77 } // namespace exec
78 } // namespace vtkm
79 
80 #endif // vtk_m_exec_ConnectivityExplicit_h
vtkm::exec::ConnectivityExplicit::GetIndices
VTKM_EXEC IndicesType GetIndices(vtkm::Id index) const
Returns a Vec-like object containing the indices for the given index.
Definition: ConnectivityExplicit.h:62
vtkm::exec::ConnectivityExplicit::Shapes
ShapesPortalType Shapes
Definition: ConnectivityExplicit.h:72
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::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
vtkm::exec::ConnectivityExplicit::GetNumberOfElements
VTKM_EXEC SchedulingRangeType GetNumberOfElements() const
Definition: ConnectivityExplicit.h:41
vtkm::exec::ConnectivityExplicit::ConnectivityExplicit
ConnectivityExplicit(const ShapesPortalType &shapesPortal, const ConnectivityPortalType &connPortal, const OffsetsPortalType &offsetsPortal)
Definition: ConnectivityExplicit.h:31
CellShape.h
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::exec::ConnectivityExplicit::ConnectivityExplicit
ConnectivityExplicit()
Definition: ConnectivityExplicit.h:29
vtkm::exec::ConnectivityExplicit::CellShapeTag
vtkm::CellShapeTagGeneric CellShapeTag
Definition: ConnectivityExplicit.h:43
VecFromPortal.h
vtkm::exec::ConnectivityExplicit::SchedulingRangeType
vtkm::Id SchedulingRangeType
Definition: ConnectivityExplicit.h:27
vtkm::exec::ConnectivityExplicit
Definition: ConnectivityExplicit.h:24
vtkm::exec::ConnectivityExplicit::GetCellShape
VTKM_EXEC CellShapeTag GetCellShape(vtkm::Id index) const
Definition: ConnectivityExplicit.h:46
vtkm::exec::ConnectivityExplicit::GetNumberOfIndices
VTKM_EXEC vtkm::IdComponent GetNumberOfIndices(vtkm::Id index) const
Definition: ConnectivityExplicit.h:49
vtkm::CellShapeTagGeneric
A special cell shape tag that holds a cell shape that is not known at compile time.
Definition: CellShape.h:152
vtkm::exec::ConnectivityExplicit::Offsets
OffsetsPortalType Offsets
Definition: ConnectivityExplicit.h:74
vtkm::VecFromPortal
A short variable-length array from a window in an ArrayPortal.
Definition: VecFromPortal.h:29
vtkm::exec::ConnectivityExplicit::IndicesType
vtkm::VecFromPortal< ConnectivityPortalType > IndicesType
Definition: ConnectivityExplicit.h:54
vtkm::exec::ConnectivityExplicit::Connectivity
ConnectivityPortalType Connectivity
Definition: ConnectivityExplicit.h:73