VTK  9.0.20200604
Portals.h
Go to the documentation of this file.
1 //=============================================================================
2 //
3 // Copyright (c) Kitware, Inc.
4 // All rights reserved.
5 // See LICENSE.txt for details.
6 //
7 // This software is distributed WITHOUT ANY WARRANTY; without even
8 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9 // PURPOSE. See the above copyright notice for more information.
10 //
11 // Copyright 2012 Sandia Corporation.
12 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
13 // the U.S. Government retains certain rights in this software.
14 //
15 //=============================================================================
16 
17 #ifndef vtkmlib_Portals_h
18 #define vtkmlib_Portals_h
19 
20 #include "PortalTraits.h"
21 #include "vtkAcceleratorsVTKmModule.h"
22 #include "vtkmConfig.h" //required for general vtkm setup
23 
24 class vtkDataArray;
25 class vtkPoints;
26 
27 #include <vtkm/cont/internal/IteratorFromArrayPortal.h>
28 
29 namespace tovtkm
30 {
31 
32 template <typename Type, typename VTKDataArrayType_>
33 class VTKM_ALWAYS_EXPORT vtkArrayPortal
34 {
35  static const int NUM_COMPONENTS = vtkm::VecTraits<Type>::NUM_COMPONENTS;
36 
37 public:
38  typedef VTKDataArrayType_ VTKDataArrayType;
41 
42  VTKM_EXEC_CONT
44 
45  VTKM_CONT
46  vtkArrayPortal(VTKDataArrayType* array, vtkm::Id size);
47 
48  VTKM_SUPPRESS_EXEC_WARNINGS
49  VTKM_EXEC_CONT
50  vtkm::Id GetNumberOfValues() const { return this->Size; }
51 
52  VTKM_SUPPRESS_EXEC_WARNINGS
53  VTKM_EXEC_CONT
54  inline ValueType Get(vtkm::Id index) const;
55 
56  VTKM_SUPPRESS_EXEC_WARNINGS
57  VTKM_EXEC_CONT
58  inline void Set(vtkm::Id index, const ValueType& value) const;
59 
60  typedef vtkm::cont::internal::IteratorFromArrayPortal<vtkArrayPortal> IteratorType;
61 
62  VTKM_CONT
63  IteratorType GetIteratorBegin() const { return IteratorType(*this, 0); }
64 
65  VTKM_CONT
66  IteratorType GetIteratorEnd() const { return IteratorType(*this, this->Size); }
67 
68  VTKM_CONT
69  VTKDataArrayType* GetVtkData() const { return this->VTKData; }
70 
71 private:
72  VTKDataArrayType* VTKData;
73  vtkm::Id Size;
74 };
75 
76 template <typename Type>
77 class VTKM_ALWAYS_EXPORT vtkPointsPortal
78 {
79  static const int NUM_COMPONENTS = vtkm::VecTraits<Type>::NUM_COMPONENTS;
80 
81 public:
84 
85  VTKM_EXEC_CONT
87 
88  VTKM_CONT
90 
91  VTKM_SUPPRESS_EXEC_WARNINGS
92  VTKM_EXEC_CONT
93  vtkm::Id GetNumberOfValues() const { return this->Size; }
94 
95  VTKM_SUPPRESS_EXEC_WARNINGS
96  VTKM_EXEC_CONT
97  inline ValueType Get(vtkm::Id index) const;
98 
99  VTKM_SUPPRESS_EXEC_WARNINGS
100  VTKM_EXEC_CONT
101  inline void Set(vtkm::Id index, const ValueType& value) const;
102 
103  typedef vtkm::cont::internal::IteratorFromArrayPortal<vtkPointsPortal> IteratorType;
104 
105  VTKM_CONT
106  IteratorType GetIteratorBegin() const { return IteratorType(*this, 0); }
107 
108  VTKM_CONT
109  IteratorType GetIteratorEnd() const { return IteratorType(*this, this->Size); }
110 
111  VTKM_CONT
112  vtkPoints* GetVtkData() const { return Points; }
113 
114 private:
115  vtkPoints* Points;
116  ComponentType* Array;
117  vtkm::Id Size;
118 };
119 }
120 
121 #ifndef vtkmlib_Portals_cxx
122 #include <vtkm/cont/internal/ArrayPortalFromIterators.h>
123 namespace tovtkm
124 {
125 // T extern template instantiations
126 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT
127  vtkPointsPortal<vtkm::Vec<vtkm::Float32, 3> const>;
128 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT
129  vtkPointsPortal<vtkm::Vec<vtkm::Float64, 3> const>;
130 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT
131  vtkPointsPortal<vtkm::Vec<vtkm::Float32, 3>>;
132 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT
133  vtkPointsPortal<vtkm::Vec<vtkm::Float64, 3>>;
134 }
135 
136 #endif // defined vtkmlib_Portals_cxx
137 
138 #include "Portals.hxx"
139 #endif // vtkmlib_Portals_h
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
tovtkm::vtkArrayPortal::ComponentType
typename vtkPortalTraits< Type >::ComponentType ComponentType
Definition: Portals.h:40
tovtkm::vtkPointsPortal::GetNumberOfValues
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT vtkm::Id GetNumberOfValues() const
Definition: Portals.h:93
vtkX3D::value
Definition: vtkX3D.h:226
tovtkm::vtkPointsPortal::GetIteratorBegin
VTKM_CONT IteratorType GetIteratorBegin() const
Definition: Portals.h:106
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
tovtkm::vtkArrayPortal::VTKDataArrayType
VTKDataArrayType_ VTKDataArrayType
Definition: Portals.h:38
tovtkm::vtkArrayPortal::GetIteratorEnd
VTKM_CONT IteratorType GetIteratorEnd() const
Definition: Portals.h:66
tovtkm::vtkArrayPortal::GetIteratorBegin
VTKM_CONT IteratorType GetIteratorBegin() const
Definition: Portals.h:63
tovtkm::vtkPortalTraits::ComponentType
typename std::remove_const< T >::type ComponentType
Definition: PortalTraits.h:38
vtkX3D::points
Definition: vtkX3D.h:452
tovtkm::vtkArrayPortal::IteratorType
vtkm::cont::internal::IteratorFromArrayPortal< vtkArrayPortal > IteratorType
Definition: Portals.h:60
tovtkm::vtkPointsPortal::ValueType
typename vtkPortalTraits< Type >::Type ValueType
Definition: Portals.h:82
vtkX3D::size
Definition: vtkX3D.h:259
tovtkm::vtkPortalTraits::Type
ComponentType Type
Definition: PortalTraits.h:39
tovtkm::vtkArrayPortal::GetNumberOfValues
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT vtkm::Id GetNumberOfValues() const
Definition: Portals.h:50
tovtkm::vtkArrayPortal::GetVtkData
VTKM_CONT VTKDataArrayType * GetVtkData() const
Definition: Portals.h:69
tovtkm::vtkArrayPortal
Definition: Portals.h:33
tovtkm::vtkArrayPortal::ValueType
typename vtkPortalTraits< Type >::Type ValueType
Definition: Portals.h:39
tovtkm::vtkPointsPortal::GetIteratorEnd
VTKM_CONT IteratorType GetIteratorEnd() const
Definition: Portals.h:109
vtkX3D::index
Definition: vtkX3D.h:252
tovtkm::vtkPointsPortal
Definition: Portals.h:77
PortalTraits.h
tovtkm
Definition: vtkmClip.h:35
tovtkm::FieldsFlag::Points
tovtkm::vtkPointsPortal::IteratorType
vtkm::cont::internal::IteratorFromArrayPortal< vtkPointsPortal > IteratorType
Definition: Portals.h:103
tovtkm::vtkPointsPortal::ComponentType
typename vtkPortalTraits< Type >::ComponentType ComponentType
Definition: Portals.h:83
tovtkm::vtkPointsPortal::GetVtkData
VTKM_CONT vtkPoints * GetVtkData() const
Definition: Portals.h:112