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 
11 #ifndef vtk_m_exec_ConnectivityStructured_h
12 #define vtk_m_exec_ConnectivityStructured_h
13 
14 #include <vtkm/TopologyElementTag.h>
15 #include <vtkm/Types.h>
16 #include <vtkm/internal/ConnectivityStructuredInternals.h>
17 
18 namespace vtkm
19 {
20 namespace exec
21 {
22 
23 template <typename VisitTopology, typename IncidentTopology, vtkm::IdComponent Dimension>
24 class ConnectivityStructured
25 {
26   VTKM_IS_TOPOLOGY_ELEMENT_TAG(VisitTopology);
27   VTKM_IS_TOPOLOGY_ELEMENT_TAG(IncidentTopology);
28 
29   using InternalsType = vtkm::internal::ConnectivityStructuredInternals<Dimension>;
30 
31   using Helper =
32     vtkm::internal::ConnectivityStructuredIndexHelper<VisitTopology, IncidentTopology, Dimension>;
33 
34 public:
35   using SchedulingRangeType = typename InternalsType::SchedulingRangeType;
36 
37   ConnectivityStructured() = default;
38 
39   VTKM_EXEC_CONT
ConnectivityStructured(const InternalsType & src)40   ConnectivityStructured(const InternalsType& src)
41     : Internals(src)
42   {
43   }
44 
45   ConnectivityStructured(const ConnectivityStructured& src) = default;
46 
47   VTKM_EXEC_CONT
ConnectivityStructured(const ConnectivityStructured<IncidentTopology,VisitTopology,Dimension> & src)48   ConnectivityStructured(
49     const ConnectivityStructured<IncidentTopology, VisitTopology, Dimension>& src)
50     : Internals(src.Internals)
51   {
52   }
53 
54 
55   ConnectivityStructured& operator=(const ConnectivityStructured& src) = default;
56   ConnectivityStructured& operator=(ConnectivityStructured&& src) = default;
57 
58 
59   VTKM_EXEC
GetNumberOfElements()60   vtkm::Id GetNumberOfElements() const { return Helper::GetNumberOfElements(this->Internals); }
61 
62   using CellShapeTag = typename Helper::CellShapeTag;
63   VTKM_EXEC
GetCellShape(vtkm::Id)64   CellShapeTag GetCellShape(vtkm::Id) const { return CellShapeTag(); }
65 
66   template <typename IndexType>
GetNumberOfIndices(const IndexType & index)67   VTKM_EXEC vtkm::IdComponent GetNumberOfIndices(const IndexType& index) const
68   {
69     return Helper::GetNumberOfIndices(this->Internals, index);
70   }
71 
72   using IndicesType = typename Helper::IndicesType;
73 
74   template <typename IndexType>
GetIndices(const IndexType & index)75   VTKM_EXEC IndicesType GetIndices(const IndexType& index) const
76   {
77     return Helper::GetIndices(this->Internals, index);
78   }
79 
80   VTKM_EXEC_CONT
FlatToLogicalFromIndex(vtkm::Id flatFromIndex)81   SchedulingRangeType FlatToLogicalFromIndex(vtkm::Id flatFromIndex) const
82   {
83     return Helper::FlatToLogicalFromIndex(this->Internals, flatFromIndex);
84   }
85 
86   VTKM_EXEC_CONT
LogicalToFlatFromIndex(const SchedulingRangeType & logicalFromIndex)87   vtkm::Id LogicalToFlatFromIndex(const SchedulingRangeType& logicalFromIndex) const
88   {
89     return Helper::LogicalToFlatFromIndex(this->Internals, logicalFromIndex);
90   }
91 
92   VTKM_EXEC_CONT
FlatToLogicalToIndex(vtkm::Id flatToIndex)93   SchedulingRangeType FlatToLogicalToIndex(vtkm::Id flatToIndex) const
94   {
95     return Helper::FlatToLogicalToIndex(this->Internals, flatToIndex);
96   }
97 
98   VTKM_EXEC_CONT
LogicalToFlatToIndex(const SchedulingRangeType & logicalToIndex)99   vtkm::Id LogicalToFlatToIndex(const SchedulingRangeType& logicalToIndex) const
100   {
101     return Helper::LogicalToFlatToIndex(this->Internals, logicalToIndex);
102   }
103 
104   VTKM_EXEC_CONT
GetPointDimensions()105   vtkm::Vec<vtkm::Id, Dimension> GetPointDimensions() const
106   {
107     return this->Internals.GetPointDimensions();
108   }
109 
110   VTKM_EXEC_CONT
GetCellDimensions()111   vtkm::Vec<vtkm::Id, Dimension> GetCellDimensions() const
112   {
113     return this->Internals.GetCellDimensions();
114   }
115 
116   VTKM_EXEC_CONT
GetGlobalPointIndexStart()117   SchedulingRangeType GetGlobalPointIndexStart() const
118   {
119     return this->Internals.GetGlobalPointIndexStart();
120   }
121 
122   friend class ConnectivityStructured<IncidentTopology, VisitTopology, Dimension>;
123 
124 private:
125   InternalsType Internals;
126 };
127 }
128 } // namespace vtkm::exec
129 
130 #endif //vtk_m_exec_ConnectivityStructured_h
131