VTK  9.5.20250907
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 viskores setup
12
13VTK_ABI_NAMESPACE_BEGIN
14class vtkDataArray;
15class vtkPoints;
16VTK_ABI_NAMESPACE_END
17
18#include <viskores/cont/internal/IteratorFromArrayPortal.h>
19
20namespace tovtkm
21{
22VTK_ABI_NAMESPACE_BEGIN
23
24template <typename Type, typename VTKDataArrayType_>
25class VISKORES_ALWAYS_EXPORT vtkArrayPortal
26{
27 static const int NUM_COMPONENTS = viskores::VecTraits<Type>::NUM_COMPONENTS;
28
29public:
30 typedef VTKDataArrayType_ VTKDataArrayType;
33
34 VISKORES_EXEC_CONT
36
37 VISKORES_CONT
38 vtkArrayPortal(VTKDataArrayType* array, viskores::Id size);
39
40 VISKORES_SUPPRESS_EXEC_WARNINGS
41 VISKORES_EXEC_CONT
42 viskores::Id GetNumberOfValues() const { return this->Size; }
43
44 VISKORES_SUPPRESS_EXEC_WARNINGS
45 VISKORES_EXEC_CONT
46 inline ValueType Get(viskores::Id index) const;
47
48 VISKORES_SUPPRESS_EXEC_WARNINGS
49 VISKORES_EXEC_CONT
50 inline void Set(viskores::Id index, const ValueType& value) const;
51
52 typedef viskores::cont::internal::IteratorFromArrayPortal<vtkArrayPortal> IteratorType;
53
54 VISKORES_CONT
55 IteratorType GetIteratorBegin() const { return IteratorType(*this, 0); }
56
57 VISKORES_CONT
58 IteratorType GetIteratorEnd() const { return IteratorType(*this, this->Size); }
59
60 VISKORES_CONT
61 VTKDataArrayType* GetVtkData() const { return this->VTKData; }
62
63private:
64 VTKDataArrayType* VTKData;
65 viskores::Id Size;
66};
67
68template <typename Type>
69class VISKORES_ALWAYS_EXPORT vtkPointsPortal
70{
71 static const int NUM_COMPONENTS = viskores::VecTraits<Type>::NUM_COMPONENTS;
72
73public:
76
77 VISKORES_EXEC_CONT
79
80 VISKORES_CONT
81 vtkPointsPortal(vtkPoints* points, viskores::Id size);
82
83 VISKORES_SUPPRESS_EXEC_WARNINGS
84 VISKORES_EXEC_CONT
85 viskores::Id GetNumberOfValues() const { return this->Size; }
86
87 VISKORES_SUPPRESS_EXEC_WARNINGS
88 VISKORES_EXEC_CONT
89 inline ValueType Get(viskores::Id index) const;
90
91 VISKORES_SUPPRESS_EXEC_WARNINGS
92 VISKORES_EXEC_CONT
93 inline void Set(viskores::Id index, const ValueType& value) const;
94
95 typedef viskores::cont::internal::IteratorFromArrayPortal<vtkPointsPortal> IteratorType;
96
97 VISKORES_CONT
98 IteratorType GetIteratorBegin() const { return IteratorType(*this, 0); }
99
100 VISKORES_CONT
101 IteratorType GetIteratorEnd() const { return IteratorType(*this, this->Size); }
102
103 VISKORES_CONT
104 vtkPoints* GetVtkData() const { return Points; }
105
106private:
108 ComponentType* Array;
109 viskores::Id Size;
110};
111VTK_ABI_NAMESPACE_END
112}
113
114#ifndef vtkmlib_Portals_cxx
115#include <viskores/cont/internal/ArrayPortalFromIterators.h>
116namespace tovtkm
117{
118VTK_ABI_NAMESPACE_BEGIN
119// T extern template instantiations
120extern template class VTKACCELERATORSVTKMCORE_TEMPLATE_EXPORT
121 vtkPointsPortal<viskores::Vec<viskores::Float32, 3> const>;
122extern template class VTKACCELERATORSVTKMCORE_TEMPLATE_EXPORT
123 vtkPointsPortal<viskores::Vec<viskores::Float64, 3> const>;
124extern template class VTKACCELERATORSVTKMCORE_TEMPLATE_EXPORT
125 vtkPointsPortal<viskores::Vec<viskores::Float32, 3>>;
126extern template class VTKACCELERATORSVTKMCORE_TEMPLATE_EXPORT
127 vtkPointsPortal<viskores::Vec<viskores::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 */
viskores::cont::internal::IteratorFromArrayPortal< vtkArrayPortal > IteratorType
Definition Portals.h:52
typename vtkPortalTraits< Type >::ComponentType ComponentType
Definition Portals.h:32
VISKORES_SUPPRESS_EXEC_WARNINGS VISKORES_EXEC_CONT ValueType Get(viskores::Id index) const
VISKORES_SUPPRESS_EXEC_WARNINGS VISKORES_EXEC_CONT void Set(viskores::Id index, const ValueType &value) const
VISKORES_SUPPRESS_EXEC_WARNINGS VISKORES_EXEC_CONT viskores::Id GetNumberOfValues() const
Definition Portals.h:42
VISKORES_CONT vtkArrayPortal(VTKDataArrayType *array, viskores::Id size)
VISKORES_CONT IteratorType GetIteratorBegin() const
Definition Portals.h:55
typename vtkPortalTraits< Type >::Type ValueType
Definition Portals.h:31
VISKORES_EXEC_CONT vtkArrayPortal()
VISKORES_CONT IteratorType GetIteratorEnd() const
Definition Portals.h:58
VISKORES_CONT VTKDataArrayType * GetVtkData() const
Definition Portals.h:61
VTKDataArrayType_ VTKDataArrayType
Definition Portals.h:30
viskores::cont::internal::IteratorFromArrayPortal< vtkPointsPortal > IteratorType
Definition Portals.h:95
VISKORES_SUPPRESS_EXEC_WARNINGS VISKORES_EXEC_CONT void Set(viskores::Id index, const ValueType &value) const
VISKORES_CONT vtkPoints * GetVtkData() const
Definition Portals.h:104
VISKORES_SUPPRESS_EXEC_WARNINGS VISKORES_EXEC_CONT ValueType Get(viskores::Id index) const
typename vtkPortalTraits< Type >::ComponentType ComponentType
Definition Portals.h:75
VISKORES_CONT IteratorType GetIteratorBegin() const
Definition Portals.h:98
VISKORES_SUPPRESS_EXEC_WARNINGS VISKORES_EXEC_CONT viskores::Id GetNumberOfValues() const
Definition Portals.h:85
VISKORES_CONT vtkPointsPortal(vtkPoints *points, viskores::Id size)
typename vtkPortalTraits< Type >::Type ValueType
Definition Portals.h:74
VISKORES_EXEC_CONT vtkPointsPortal()
VISKORES_CONT IteratorType GetIteratorEnd() const
Definition Portals.h:101
abstract superclass for arrays of numeric data
represent and manipulate 3D points
Definition vtkPoints.h:139
typename std::remove_const< T >::type ComponentType