VTK-m  2.2
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 
28 template <typename ShapesPortalType, typename ConnectivityPortalType, typename OffsetsPortalType>
30 {
31 public:
33 
35 
36  ConnectivityExplicit(const ShapesPortalType& shapesPortal,
37  const ConnectivityPortalType& connPortal,
38  const OffsetsPortalType& offsetsPortal)
39  : Shapes(shapesPortal)
40  , Connectivity(connPortal)
41  , Offsets(offsetsPortal)
42  {
43  }
44 
50  VTKM_EXEC
51  SchedulingRangeType GetNumberOfElements() const { return this->Shapes.GetNumberOfValues(); }
52 
58 
63  VTKM_EXEC
64  CellShapeTag GetCellShape(vtkm::Id index) const { return CellShapeTag(this->Shapes.Get(index)); }
65 
68  VTKM_EXEC
70  {
71  return static_cast<vtkm::IdComponent>(this->Offsets.Get(index + 1) - this->Offsets.Get(index));
72  }
73 
76 
84  VTKM_EXEC
86  {
87  const vtkm::Id offset = this->Offsets.Get(index);
88  const vtkm::Id endOffset = this->Offsets.Get(index + 1);
89  const auto length = static_cast<vtkm::IdComponent>(endOffset - offset);
90 
91  return IndicesType(this->Connectivity, length, offset);
92  }
93 
94 private:
95  ShapesPortalType Shapes;
96  ConnectivityPortalType Connectivity;
97  OffsetsPortalType Offsets;
98 };
99 
100 } // namespace exec
101 } // namespace vtkm
102 
103 #endif // vtk_m_exec_ConnectivityExplicit_h
vtkm::exec::ConnectivityExplicit::Shapes
ShapesPortalType Shapes
Definition: ConnectivityExplicit.h:95
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
Base type to use to index small lists.
Definition: Types.h:194
vtkm::exec::ConnectivityExplicit::GetNumberOfElements
SchedulingRangeType GetNumberOfElements() const
Provides the number of elements in the topology.
Definition: ConnectivityExplicit.h:51
vtkm::exec::ConnectivityExplicit::ConnectivityExplicit
ConnectivityExplicit(const ShapesPortalType &shapesPortal, const ConnectivityPortalType &connPortal, const OffsetsPortalType &offsetsPortal)
Definition: ConnectivityExplicit.h:36
CellShape.h
vtkm::exec::ConnectivityExplicit::GetCellShape
CellShapeTag GetCellShape(vtkm::Id index) const
Returns a tagfor the cell shape associated with the element at the given index.
Definition: ConnectivityExplicit.h:64
vtkm::exec::ConnectivityExplicit::ConnectivityExplicit
ConnectivityExplicit()
Definition: ConnectivityExplicit.h:34
vtkm::exec::ConnectivityExplicit::CellShapeTag
vtkm::CellShapeTagGeneric CellShapeTag
The tag representing the cell shape of the visited elements.
Definition: ConnectivityExplicit.h:57
VecFromPortal.h
vtkm::exec::ConnectivityExplicit::SchedulingRangeType
vtkm::Id SchedulingRangeType
Definition: ConnectivityExplicit.h:32
vtkm::exec::ConnectivityExplicit::GetNumberOfIndices
vtkm::IdComponent GetNumberOfIndices(vtkm::Id index) const
Given the index of a visited element, returns the number of incident elements touching it.
Definition: ConnectivityExplicit.h:69
vtkm::exec::ConnectivityExplicit
A class holding information about topology connections.
Definition: ConnectivityExplicit.h:29
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
vtkm::CellShapeTagGeneric
A special cell shape tag that holds a cell shape that is not known at compile time.
Definition: CellShape.h:170
vtkm::exec::ConnectivityExplicit::Offsets
OffsetsPortalType Offsets
Definition: ConnectivityExplicit.h:97
vtkm::VecFromPortal
A short variable-length array from a window in an ArrayPortal.
Definition: VecFromPortal.h:29
vtkm::exec::ConnectivityExplicit::GetIndices
IndicesType GetIndices(vtkm::Id index) const
Provides the indices of all elements incident to the visit element of the provided index.
Definition: ConnectivityExplicit.h:85
vtkm::exec::ConnectivityExplicit::IndicesType
vtkm::VecFromPortal< ConnectivityPortalType > IndicesType
Type of variable that lists of incident indices will be put into.
Definition: ConnectivityExplicit.h:75
vtkm::exec::ConnectivityExplicit::Connectivity
ConnectivityPortalType Connectivity
Definition: ConnectivityExplicit.h:96