VTK  9.4.20241117
Portals.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-FileCopyrightText: Copyright (c) Kitware, Inc.
3// SPDX-FileCopyrightText: Copyright 2012 Sandia Corporation.
4// SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
5
6#ifndef vtkmlib_Portals_h
7#define vtkmlib_Portals_h
8
9#include "PortalTraits.h"
10#include "vtkAcceleratorsVTKmCoreModule.h"
11#include "vtkmConfigCore.h" //required for general vtkm setup
12
13VTK_ABI_NAMESPACE_BEGIN
14class vtkDataArray;
15class vtkPoints;
16VTK_ABI_NAMESPACE_END
17
18#include <vtkm/cont/internal/IteratorFromArrayPortal.h>
19
20namespace tovtkm
21{
22VTK_ABI_NAMESPACE_BEGIN
23
24template <typename Type, typename VTKDataArrayType_>
25class VTKM_ALWAYS_EXPORT vtkArrayPortal
26{
27 static const int NUM_COMPONENTS = vtkm::VecTraits<Type>::NUM_COMPONENTS;
28
29public:
30 typedef VTKDataArrayType_ VTKDataArrayType;
33
34 VTKM_EXEC_CONT
36
37 VTKM_CONT
38 vtkArrayPortal(VTKDataArrayType* array, vtkm::Id size);
39
40 VTKM_SUPPRESS_EXEC_WARNINGS
41 VTKM_EXEC_CONT
42 vtkm::Id GetNumberOfValues() const { return this->Size; }
43
44 VTKM_SUPPRESS_EXEC_WARNINGS
45 VTKM_EXEC_CONT
46 inline ValueType Get(vtkm::Id index) const;
47
48 VTKM_SUPPRESS_EXEC_WARNINGS
49 VTKM_EXEC_CONT
50 inline void Set(vtkm::Id index, const ValueType& value) const;
51
52 typedef vtkm::cont::internal::IteratorFromArrayPortal<vtkArrayPortal> IteratorType;
53
54 VTKM_CONT
55 IteratorType GetIteratorBegin() const { return IteratorType(*this, 0); }
56
57 VTKM_CONT
58 IteratorType GetIteratorEnd() const { return IteratorType(*this, this->Size); }
59
60 VTKM_CONT
61 VTKDataArrayType* GetVtkData() const { return this->VTKData; }
62
63private:
64 VTKDataArrayType* VTKData;
65 vtkm::Id Size;
66};
67
68template <typename Type>
69class VTKM_ALWAYS_EXPORT vtkPointsPortal
70{
71 static const int NUM_COMPONENTS = vtkm::VecTraits<Type>::NUM_COMPONENTS;
72
73public:
76
77 VTKM_EXEC_CONT
79
80 VTKM_CONT
81 vtkPointsPortal(vtkPoints* points, vtkm::Id size);
82
83 VTKM_SUPPRESS_EXEC_WARNINGS
84 VTKM_EXEC_CONT
85 vtkm::Id GetNumberOfValues() const { return this->Size; }
86
87 VTKM_SUPPRESS_EXEC_WARNINGS
88 VTKM_EXEC_CONT
89 inline ValueType Get(vtkm::Id index) const;
90
91 VTKM_SUPPRESS_EXEC_WARNINGS
92 VTKM_EXEC_CONT
93 inline void Set(vtkm::Id index, const ValueType& value) const;
94
95 typedef vtkm::cont::internal::IteratorFromArrayPortal<vtkPointsPortal> IteratorType;
96
97 VTKM_CONT
98 IteratorType GetIteratorBegin() const { return IteratorType(*this, 0); }
99
100 VTKM_CONT
101 IteratorType GetIteratorEnd() const { return IteratorType(*this, this->Size); }
102
103 VTKM_CONT
104 vtkPoints* GetVtkData() const { return Points; }
105
106private:
108 ComponentType* Array;
109 vtkm::Id Size;
110};
111VTK_ABI_NAMESPACE_END
112}
113
114#ifndef vtkmlib_Portals_cxx
115#include <vtkm/cont/internal/ArrayPortalFromIterators.h>
116namespace tovtkm
117{
118VTK_ABI_NAMESPACE_BEGIN
119// T extern template instantiations
120extern template class VTKACCELERATORSVTKMCORE_TEMPLATE_EXPORT
121 vtkPointsPortal<vtkm::Vec<vtkm::Float32, 3> const>;
122extern template class VTKACCELERATORSVTKMCORE_TEMPLATE_EXPORT
123 vtkPointsPortal<vtkm::Vec<vtkm::Float64, 3> const>;
124extern template class VTKACCELERATORSVTKMCORE_TEMPLATE_EXPORT
125 vtkPointsPortal<vtkm::Vec<vtkm::Float32, 3>>;
126extern template class VTKACCELERATORSVTKMCORE_TEMPLATE_EXPORT
127 vtkPointsPortal<vtkm::Vec<vtkm::Float64, 3>>;
128VTK_ABI_NAMESPACE_END
129}
130
131#endif // defined vtkmlib_Portals_cxx
132
133#include "Portals.hxx"
134#endif // vtkmlib_Portals_h
135/* VTK-HeaderTest-Exclude: Portals.h */
VTKM_EXEC_CONT vtkArrayPortal()
vtkm::cont::internal::IteratorFromArrayPortal< vtkArrayPortal > IteratorType
Definition Portals.h:52
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT ValueType Get(vtkm::Id index) const
typename vtkPortalTraits< Type >::ComponentType ComponentType
Definition Portals.h:32
VTKM_CONT IteratorType GetIteratorBegin() const
Definition Portals.h:55
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT vtkm::Id GetNumberOfValues() const
Definition Portals.h:42
VTKM_CONT IteratorType GetIteratorEnd() const
Definition Portals.h:58
typename vtkPortalTraits< Type >::Type ValueType
Definition Portals.h:31
VTKM_CONT vtkArrayPortal(VTKDataArrayType *array, vtkm::Id size)
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT void Set(vtkm::Id index, const ValueType &value) const
VTKM_CONT VTKDataArrayType * GetVtkData() const
Definition Portals.h:61
VTKDataArrayType_ VTKDataArrayType
Definition Portals.h:30
VTKM_CONT IteratorType GetIteratorEnd() const
Definition Portals.h:101
VTKM_CONT vtkPoints * GetVtkData() const
Definition Portals.h:104
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT ValueType Get(vtkm::Id index) const
VTKM_CONT vtkPointsPortal(vtkPoints *points, vtkm::Id size)
VTKM_CONT IteratorType GetIteratorBegin() const
Definition Portals.h:98
VTKM_EXEC_CONT vtkPointsPortal()
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT void Set(vtkm::Id index, const ValueType &value) const
typename vtkPortalTraits< Type >::ComponentType ComponentType
Definition Portals.h:75
vtkm::cont::internal::IteratorFromArrayPortal< vtkPointsPortal > IteratorType
Definition Portals.h:95
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT vtkm::Id GetNumberOfValues() const
Definition Portals.h:85
typename vtkPortalTraits< Type >::Type ValueType
Definition Portals.h:74
abstract superclass for arrays of numeric data
represent and manipulate 3D points
Definition vtkPoints.h:139
typename std::remove_const< T >::type ComponentType