VTK  9.1.0
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 "vtkAcceleratorsVTKmCoreModule.h"
22#include "vtkmConfigCore.h" //required for general vtkm setup
23
24class vtkDataArray;
25class vtkPoints;
26
27#include <vtkm/cont/internal/IteratorFromArrayPortal.h>
28
29namespace tovtkm
30{
31
32template <typename Type, typename VTKDataArrayType_>
33class VTKM_ALWAYS_EXPORT vtkArrayPortal
34{
35 static const int NUM_COMPONENTS = vtkm::VecTraits<Type>::NUM_COMPONENTS;
36
37public:
38 typedef VTKDataArrayType_ VTKDataArrayType;
41
42 VTKM_EXEC_CONT
44
45 VTKM_CONT
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
71private:
72 VTKDataArrayType* VTKData;
73 vtkm::Id Size;
74};
75
76template <typename Type>
77class VTKM_ALWAYS_EXPORT vtkPointsPortal
78{
79 static const int NUM_COMPONENTS = vtkm::VecTraits<Type>::NUM_COMPONENTS;
80
81public:
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
114private:
116 ComponentType* Array;
117 vtkm::Id Size;
118};
119}
120
121#ifndef vtkmlib_Portals_cxx
122#include <vtkm/cont/internal/ArrayPortalFromIterators.h>
123namespace tovtkm
124{
125// T extern template instantiations
126extern template class VTKACCELERATORSVTKMCORE_TEMPLATE_EXPORT
127 vtkPointsPortal<vtkm::Vec<vtkm::Float32, 3> const>;
128extern template class VTKACCELERATORSVTKMCORE_TEMPLATE_EXPORT
129 vtkPointsPortal<vtkm::Vec<vtkm::Float64, 3> const>;
130extern template class VTKACCELERATORSVTKMCORE_TEMPLATE_EXPORT
131 vtkPointsPortal<vtkm::Vec<vtkm::Float32, 3>>;
132extern template class VTKACCELERATORSVTKMCORE_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
VTKM_EXEC_CONT vtkArrayPortal()
vtkm::cont::internal::IteratorFromArrayPortal< vtkArrayPortal > IteratorType
Definition: Portals.h:60
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT ValueType Get(vtkm::Id index) const
typename vtkPortalTraits< Type >::ComponentType ComponentType
Definition: Portals.h:40
VTKM_CONT IteratorType GetIteratorBegin() const
Definition: Portals.h:63
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT vtkm::Id GetNumberOfValues() const
Definition: Portals.h:50
VTKM_CONT IteratorType GetIteratorEnd() const
Definition: Portals.h:66
typename vtkPortalTraits< Type >::Type ValueType
Definition: Portals.h:39
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:69
VTKDataArrayType_ VTKDataArrayType
Definition: Portals.h:38
VTKM_CONT IteratorType GetIteratorEnd() const
Definition: Portals.h:109
VTKM_CONT vtkPoints * GetVtkData() const
Definition: Portals.h:112
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:106
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:83
vtkm::cont::internal::IteratorFromArrayPortal< vtkPointsPortal > IteratorType
Definition: Portals.h:103
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT vtkm::Id GetNumberOfValues() const
Definition: Portals.h:93
typename vtkPortalTraits< Type >::Type ValueType
Definition: Portals.h:82
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
represent and manipulate 3D points
Definition: vtkPoints.h:143
@ points
Definition: vtkX3D.h:452
@ value
Definition: vtkX3D.h:226
@ size
Definition: vtkX3D.h:259
@ index
Definition: vtkX3D.h:252
typename std::remove_const< T >::type ComponentType
Definition: PortalTraits.h:38