VTK
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 #ifndef __VTK_WRAP__
20 
21 #include "vtkAcceleratorsVTKmModule.h"
22 #include "vtkmConfig.h" //required for general vtkm setup
23 #include "PortalTraits.h"
24 #include "vtkmTags.h"
25 
26 class vtkDataArray;
27 class vtkPoints;
28 
29 #include <vtkm/cont/internal/IteratorFromArrayPortal.h>
30 
31 namespace tovtkm {
32 
33 template <typename Type, typename VTKDataArrayType_>
34 class VTKM_ALWAYS_EXPORT vtkArrayPortal
35 {
36  static const int NUM_COMPONENTS = vtkm::VecTraits<Type>::NUM_COMPONENTS;
37 
38 public:
39  typedef VTKDataArrayType_ VTKDataArrayType;
42 
44 
45  vtkArrayPortal(VTKDataArrayType* array, vtkm::Id size);
46 
47  VTKM_SUPPRESS_EXEC_WARNINGS
48  VTKM_EXEC_CONT
49  vtkm::Id GetNumberOfValues() const
50  {
51  return this->Size;
52  }
53 
54  VTKM_SUPPRESS_EXEC_WARNINGS
55  VTKM_EXEC_CONT
56  inline ValueType Get(vtkm::Id index) const;
57 
58  VTKM_SUPPRESS_EXEC_WARNINGS
59  VTKM_EXEC_CONT
60  inline void Set(vtkm::Id index, const ValueType& value) const;
61 
62  typedef vtkm::cont::internal::IteratorFromArrayPortal<vtkArrayPortal>
64 
66  {
67  return IteratorType(*this, 0);
68  }
69 
71  {
72  return IteratorType(*this, this->Size);
73  }
74 
75  VTKDataArrayType* GetVtkData() const
76  {
77  return this->VTKData;
78  }
79 
80 private:
81  VTKDataArrayType* VTKData;
82  vtkm::Id Size;
83 };
84 
85 template <typename Type> class VTKM_ALWAYS_EXPORT vtkPointsPortal
86 {
87  static const int NUM_COMPONENTS = vtkm::VecTraits<Type>::NUM_COMPONENTS;
88 
89 public:
92 
94 
96 
97  VTKM_SUPPRESS_EXEC_WARNINGS
98  VTKM_EXEC_CONT
99  vtkm::Id GetNumberOfValues() const
100  {
101  return this->Size;
102  }
103 
104  VTKM_SUPPRESS_EXEC_WARNINGS
105  VTKM_EXEC_CONT
106  inline ValueType Get(vtkm::Id index) const;
107 
108  VTKM_SUPPRESS_EXEC_WARNINGS
109  VTKM_EXEC_CONT
110  inline void Set(vtkm::Id index, const ValueType& value) const;
111 
112  typedef vtkm::cont::internal::IteratorFromArrayPortal<vtkPointsPortal>
114 
116  {
117  return IteratorType(*this, 0);
118  }
119 
121  {
122  return IteratorType(*this, this->Size);
123  }
124 
126  {
127  return Points;
128  }
129 
130 private:
131  vtkPoints* Points;
132  ComponentType* Array;
133  vtkm::Id Size;
134 };
135 }
136 
137 #define VTKM_TEMPLATE_EXPORT_ArrayPortal(T, S) \
138  extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \
139  vtkArrayPortal<const T, S<T>>; \
140  extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkArrayPortal<T, S<T>>; \
141  extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \
142  vtkArrayPortal<const vtkm::Vec<T, 2>, S<T>>; \
143  extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \
144  vtkArrayPortal<vtkm::Vec<T, 2>, S<T>>; \
145  extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \
146  vtkArrayPortal<const vtkm::Vec<T, 3>, S<T>>; \
147  extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \
148  vtkArrayPortal<vtkm::Vec<T, 3>, S<T>>; \
149  extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \
150  vtkArrayPortal<const vtkm::Vec<T, 4>, S<T>>; \
151  extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \
152  vtkArrayPortal<vtkm::Vec<T, 4>, S<T>>;
153 
154 #define VTKM_TEMPLATE_IMPORT_ArrayPortal(T, S) \
155  template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkArrayPortal<const T, S<T>>; \
156  template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkArrayPortal<T, S<T>>; \
157  template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \
158  vtkArrayPortal<const vtkm::Vec<T, 2>, S<T>>; \
159  template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \
160  vtkArrayPortal<vtkm::Vec<T, 2>, S<T>>; \
161  template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \
162  vtkArrayPortal<const vtkm::Vec<T, 3>, S<T>>; \
163  template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \
164  vtkArrayPortal<vtkm::Vec<T, 3>, S<T>>; \
165  template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \
166  vtkArrayPortal<const vtkm::Vec<T, 4>, S<T>>; \
167  template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT \
168  vtkArrayPortal<vtkm::Vec<T, 4>, S<T>>;
169 
170 #ifndef vtkmlib_Portals_cxx
171 #include <vtkm/cont/internal/ArrayPortalFromIterators.h>
172 namespace tovtkm {
173 // T extern template instantiations
185 
197 
198 #if VTKM_SIZE_LONG_LONG == 8
201 
204 #endif
205 
206 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT
207  vtkPointsPortal<vtkm::Vec<vtkm::Float32, 3> const>;
208 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT
209  vtkPointsPortal<vtkm::Vec<vtkm::Float64, 3> const>;
210 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT
211  vtkPointsPortal<vtkm::Vec<vtkm::Float32, 3>>;
212 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT
213  vtkPointsPortal<vtkm::Vec<vtkm::Float64, 3>>;
214 }
215 
216 #endif // defined vtkmlib_Portals_cxx
217 
218 #include "Portals.hxx"
219 #endif
220 #endif // vtkmlib_Portals_h
typename vtkPortalTraits< Type >::Type ValueType
Definition: Portals.h:90
Struct-Of-Arrays implementation of vtkGenericDataArray.
IteratorType GetIteratorBegin() const
Definition: Portals.h:65
typename vtkPortalTraits< Type >::ComponentType ComponentType
Definition: Portals.h:41
vtkm::cont::internal::IteratorFromArrayPortal< vtkArrayPortal > IteratorType
Definition: Portals.h:63
typename vtkPortalTraits< Type >::ComponentType ComponentType
Definition: Portals.h:91
vtkm::cont::internal::IteratorFromArrayPortal< vtkPointsPortal > IteratorType
Definition: Portals.h:113
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT vtkm::Id GetNumberOfValues() const
Definition: Portals.h:49
Array-Of-Structs implementation of vtkGenericDataArray.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
IteratorType GetIteratorEnd() const
Definition: Portals.h:120
VTKM_TEMPLATE_EXPORT_ArrayPortal(char, vtkAOSDataArrayTemplate)
IteratorType GetIteratorBegin() const
Definition: Portals.h:115
VTKDataArrayType * GetVtkData() const
Definition: Portals.h:75
IteratorType GetIteratorEnd() const
Definition: Portals.h:70
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT vtkm::Id GetNumberOfValues() const
Definition: Portals.h:99
typename std::remove_const< T >::type ComponentType
Definition: PortalTraits.h:32
vtkPoints * GetVtkData() const
Definition: Portals.h:125
VTKDataArrayType_ VTKDataArrayType
Definition: Portals.h:39
represent and manipulate 3D points
Definition: vtkPoints.h:39
typename vtkPortalTraits< Type >::Type ValueType
Definition: Portals.h:40