VTK  9.7.1
vtkIndexedArray.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Funded by CEA, DAM, DIF, F-91297 Arpajon, France
38 #ifndef vtkIndexedArray_h
39 #define vtkIndexedArray_h
40 
41 #include "vtkCommonCoreModule.h" // for export macro
42 #include "vtkCompiler.h" // for VTK_USE_EXTERN_TEMPLATE
43 #include "vtkImplicitArray.h"
44 #include "vtkIndexedImplicitBackend.h" // for the array backend
45 
46 VTK_ABI_NAMESPACE_BEGIN
47 template <class ValueTypeT>
48 class VTKCOMMONCORE_EXPORT vtkIndexedArray
49 #ifndef __VTK_WRAP__
50  : public vtkImplicitArray<vtkIndexedImplicitBackend<ValueTypeT>, vtkArrayTypes::VTK_INDEXED_ARRAY>
51 {
52  using ImplicitArrayType =
54 #else // Fake the superclass for the wrappers.
55  : public vtkDataArray
56 {
57  using ImplicitArrayType = vtkDataArray;
58 #endif
59 public:
61  vtkImplicitArrayTypeMacro(SelfType, ImplicitArrayType);
62 #ifndef __VTK_WRAP__
63  using typename Superclass::ArrayTypeTag;
64  using typename Superclass::DataTypeTag;
65  using typename Superclass::ValueType;
66 #else
67  using ValueType = ValueTypeT;
68 #endif
69 
70  static vtkIndexedArray* New();
71 
72  // This macro expands to the set of method declarations that
73  // make up the interface of vtkImplicitArray, which is ignored
74  // by the wrappers.
75 #if defined(__VTK_WRAP__) || defined(__WRAP_GCCXML__)
77 #endif
78 
83  {
84  return static_cast<vtkIndexedArray<ValueType>*>(Superclass::FastDownCast(source));
85  }
86 
88 
92  void ConstructBackend(vtkIdList* indexes, vtkDataArray* array, bool mapTuples = false);
93  void ConstructBackend(vtkDataArray* indexes, vtkDataArray* array, bool mapTuples = false);
95 
99  vtkDataArray* GetBaseArray();
100 
104  vtkDataArray* GetIndexArray();
105 
109  bool GetMapTuples();
110 
111 protected:
112  vtkIndexedArray() = default;
113  ~vtkIndexedArray() override = default;
114 
115 private:
116  vtkIndexedArray(const vtkIndexedArray&) = delete;
117  void operator=(const vtkIndexedArray&) = delete;
118 };
119 
120 // Declare vtkArrayDownCast implementations for Indexed arrays:
122 
123 VTK_ABI_NAMESPACE_END
124 
125 // This macro is used by the subclasses to create dummy
126 // declarations for these functions such that the wrapper
127 // can see them. The wrappers ignore vtkIndexedArray.
128 #define vtkCreateIndexedWrappedArrayInterface(T) \
129  vtkCreateImplicitWrappedArrayInterface(T); \
130  void ConstructBackend(vtkIdList* indexes, vtkDataArray* array); \
131  void ConstructBackend(vtkDataArray* indexes, vtkDataArray* array); \
132  vtkDataArray* GetBaseArray(); \
133  vtkDataArray* GetIndexArray();
134 
135 #endif // vtkIndexedArray_h
136 
137 // This portion must be OUTSIDE the include blockers. This is used to tell
138 // libraries other than vtkCommonCore that instantiations of
139 // vtkIndexedArray can be found externally. This prevents each library
140 // from instantiating these on their own.
141 #ifdef VTK_INDEXED_ARRAY_INSTANTIATING
142 #define VTK_INDEXED_ARRAY_INSTANTIATE(T) \
143  namespace vtkDataArrayPrivate \
144  { \
145  VTK_ABI_NAMESPACE_BEGIN \
146  VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE(vtkIndexedArray<T>, double); \
147  VTK_ABI_NAMESPACE_END \
148  } \
149  VTK_ABI_NAMESPACE_BEGIN \
150  template class VTKCOMMONCORE_EXPORT vtkIndexedArray<T>; \
151  VTK_ABI_NAMESPACE_END
152 // We only provide these specializations for the 64-bit integer types, since
153 // other types can reuse the double-precision mechanism in
154 // vtkDataArray::GetRange without losing precision.
155 #define VTK_INDEXED_ARRAY_INSTANTIATE_VALUERANGE(T) \
156  namespace vtkDataArrayPrivate \
157  { \
158  VTK_ABI_NAMESPACE_BEGIN \
159  VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE(vtkIndexedArray<T>, T); \
160  VTK_ABI_NAMESPACE_END \
161  }
162 #elif defined(VTK_USE_EXTERN_TEMPLATE)
163 #ifndef VTK_INDEXED_ARRAY_EXTERN
164 #define VTK_INDEXED_ARRAY_EXTERN
165 #ifdef _MSC_VER
166 #pragma warning(push)
167 // The following is needed when the vtkIndexedArray is declared
168 // dllexport and is used from another class in vtkCommonCore
169 #pragma warning(disable : 4910) // extern and dllexport incompatible
170 #endif
171 VTK_ABI_NAMESPACE_BEGIN
172 vtkExternTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkIndexedArray);
173 VTK_ABI_NAMESPACE_END
174 
175 namespace vtkDataArrayPrivate
176 {
177 VTK_ABI_NAMESPACE_BEGIN
178 
179 // These are instantiated in vtkGenericDataArrayValueRange${i}.cxx
181 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkIndexedArray<unsigned long>, unsigned long)
183 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkIndexedArray<unsigned long long>, unsigned long long)
184 // These are instantiated by vtkIndexedArrayInstantiate_double.cxx.inc, e.t.c.
191 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkIndexedArray<unsigned short>, double)
197 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkIndexedArray<unsigned long long>, double)
198 
199 VTK_ABI_NAMESPACE_END
200 } // namespace vtkDataArrayPrivate
201 
202 #ifdef _MSC_VER
203 #pragma warning(pop)
204 #endif
205 #endif // VTK_INDEXED_ARRAY_EXTERN
206 
207 // The following clause is only for MSVC
208 #elif defined(_MSC_VER) && !defined(VTK_BUILD_SHARED_LIBS)
209 #pragma warning(push)
210 
211 // C4091: 'extern ' : ignored on left of 'int' when no variable is declared
212 #pragma warning(disable : 4091)
213 
214 // Compiler-specific extension warning.
215 #pragma warning(disable : 4231)
216 
217 // We need to disable warning 4910 and do an extern dllexport
218 // anyway. When deriving new arrays from an
219 // instantiation of this template the compiler does an explicit
220 // instantiation of the base class. From outside the vtkCommon
221 // library we block this using an extern dllimport instantiation.
222 // For classes inside vtkCommon we should be able to just do an
223 // extern instantiation, but VS 2008 complains about missing
224 // definitions. We cannot do an extern dllimport inside vtkCommon
225 // since the symbols are local to the dll. An extern dllexport
226 // seems to be the only way to convince VS 2008 to do the right
227 // thing, so we just disable the warning.
228 #pragma warning(disable : 4910) // extern and dllexport incompatible
229 
230 // Use an "extern explicit instantiation" to give the class a DLL
231 // interface. This is a compiler-specific extension.
232 VTK_ABI_NAMESPACE_BEGIN
233 vtkInstantiateTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkIndexedArray);
234 VTK_ABI_NAMESPACE_END
235 
236 #pragma warning(pop)
237 
238 #endif
239 
240 // VTK-HeaderTest-Exclude: vtkIndexedArray.h
Abstract superclass for all arrays.
vtkImplicitArrayTypeMacro(SelfType, GenericDataArrayType)
#define VTK_DECLARE_VALUERANGE_ARRAYTYPE(ArrayType, ValueType)
Base interface for all typed vtkDataArray subclasses.
vtkArrayDownCast_TemplateFastCastMacro(vtkIndexedArray)
vtkInstantiateTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkArrayIteratorTemplate)
list of point or cell ids
Definition: vtkIdList.h:25
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
static vtkIndexedArray< ValueType > * FastDownCast(vtkAbstractArray *source)
A faster alternative to SafeDownCast for downcasting vtkAbstractArrays.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
A read only array class that wraps an implicit function from integers to any value type supported by ...
#define vtkCreateImplicitWrappedArrayInterface(T)
static vtkImplicitArray * New()
A utility array for creating a wrapper array around an existing array and reindexing its components...
vtkExternTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkIndexedArray)
void ConstructBackend(Params &&...params)
Utility method for setting backend parameterization directly.