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 
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 template <typename Type, typename VTKDataArrayType_>
32 class VTKM_ALWAYS_EXPORT vtkArrayPortal
33 {
34  static const int NUM_COMPONENTS = vtkm::VecTraits<Type>::NUM_COMPONENTS;
35 
36 public:
37  typedef VTKDataArrayType_ VTKDataArrayType;
40 
41  VTKM_EXEC_CONT
43 
44  VTKM_CONT
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 
65  VTKM_CONT
67  {
68  return IteratorType(*this, 0);
69  }
70 
71  VTKM_CONT
73  {
74  return IteratorType(*this, this->Size);
75  }
76 
77  VTKM_CONT
79  {
80  return this->VTKData;
81  }
82 
83 private:
84  VTKDataArrayType* VTKData;
85  vtkm::Id Size;
86 };
87 
88 template <typename Type> class VTKM_ALWAYS_EXPORT vtkPointsPortal
89 {
90  static const int NUM_COMPONENTS = vtkm::VecTraits<Type>::NUM_COMPONENTS;
91 
92 public:
95 
96  VTKM_EXEC_CONT
98 
99  VTKM_CONT
100  vtkPointsPortal(vtkPoints* points, vtkm::Id size);
101 
102  VTKM_SUPPRESS_EXEC_WARNINGS
103  VTKM_EXEC_CONT
104  vtkm::Id GetNumberOfValues() const
105  {
106  return this->Size;
107  }
108 
109  VTKM_SUPPRESS_EXEC_WARNINGS
110  VTKM_EXEC_CONT
111  inline ValueType Get(vtkm::Id index) const;
112 
113  VTKM_SUPPRESS_EXEC_WARNINGS
114  VTKM_EXEC_CONT
115  inline void Set(vtkm::Id index, const ValueType& value) const;
116 
117  typedef vtkm::cont::internal::IteratorFromArrayPortal<vtkPointsPortal>
119 
120  VTKM_CONT
122  {
123  return IteratorType(*this, 0);
124  }
125 
126  VTKM_CONT
128  {
129  return IteratorType(*this, this->Size);
130  }
131 
132  VTKM_CONT
134  {
135  return Points;
136  }
137 
138 private:
139  vtkPoints* Points;
140  ComponentType* Array;
141  vtkm::Id Size;
142 };
143 }
144 
145 #ifndef vtkmlib_Portals_cxx
146 #include <vtkm/cont/internal/ArrayPortalFromIterators.h>
147 namespace tovtkm {
148 // T extern template instantiations
149 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT
150  vtkPointsPortal<vtkm::Vec<vtkm::Float32, 3> const>;
151 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT
152  vtkPointsPortal<vtkm::Vec<vtkm::Float64, 3> const>;
153 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT
154  vtkPointsPortal<vtkm::Vec<vtkm::Float32, 3>>;
155 extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT
156  vtkPointsPortal<vtkm::Vec<vtkm::Float64, 3>>;
157 }
158 
159 #endif // defined vtkmlib_Portals_cxx
160 
161 #include "Portals.hxx"
162 #endif // vtkmlib_Portals_h
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:39
tovtkm::vtkArrayPortal::ComponentType
typename vtkPortalTraits< Type >::ComponentType ComponentType
Definition: Portals.h:39
tovtkm::vtkPointsPortal::GetNumberOfValues
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT vtkm::Id GetNumberOfValues() const
Definition: Portals.h:104
vtkX3D::value
Definition: vtkX3D.h:220
tovtkm::vtkPointsPortal::GetIteratorBegin
VTKM_CONT IteratorType GetIteratorBegin() const
Definition: Portals.h:121
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
tovtkm::vtkArrayPortal::VTKDataArrayType
VTKDataArrayType_ VTKDataArrayType
Definition: Portals.h:37
tovtkm::vtkArrayPortal::GetIteratorEnd
VTKM_CONT IteratorType GetIteratorEnd() const
Definition: Portals.h:72
tovtkm::vtkArrayPortal::GetIteratorBegin
VTKM_CONT IteratorType GetIteratorBegin() const
Definition: Portals.h:66
tovtkm::vtkPortalTraits::ComponentType
typename std::remove_const< T >::type ComponentType
Definition: PortalTraits.h:37
vtkX3D::points
Definition: vtkX3D.h:446
tovtkm::vtkArrayPortal::IteratorType
vtkm::cont::internal::IteratorFromArrayPortal< vtkArrayPortal > IteratorType
Definition: Portals.h:63
tovtkm::vtkPointsPortal::ValueType
typename vtkPortalTraits< Type >::Type ValueType
Definition: Portals.h:93
vtkX3D::size
Definition: vtkX3D.h:253
tovtkm::vtkPortalTraits::Type
ComponentType Type
Definition: PortalTraits.h:38
tovtkm::vtkArrayPortal::GetNumberOfValues
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT vtkm::Id GetNumberOfValues() const
Definition: Portals.h:49
tovtkm::vtkArrayPortal::GetVtkData
VTKM_CONT VTKDataArrayType * GetVtkData() const
Definition: Portals.h:78
tovtkm::vtkArrayPortal
Definition: Portals.h:32
tovtkm::vtkArrayPortal::ValueType
typename vtkPortalTraits< Type >::Type ValueType
Definition: Portals.h:38
tovtkm::vtkPointsPortal::GetIteratorEnd
VTKM_CONT IteratorType GetIteratorEnd() const
Definition: Portals.h:127
vtkX3D::index
Definition: vtkX3D.h:246
tovtkm::vtkPointsPortal
Definition: Portals.h:88
PortalTraits.h
tovtkm
Definition: vtkmClip.h:35
tovtkm::FieldsFlag::Points
tovtkm::vtkPointsPortal::IteratorType
vtkm::cont::internal::IteratorFromArrayPortal< vtkPointsPortal > IteratorType
Definition: Portals.h:118
tovtkm::vtkPointsPortal::ComponentType
typename vtkPortalTraits< Type >::ComponentType ComponentType
Definition: Portals.h:94
tovtkm::vtkPointsPortal::GetVtkData
VTKM_CONT vtkPoints * GetVtkData() const
Definition: Portals.h:133