VTK  9.6.20260319
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
37
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
46VTK_ABI_NAMESPACE_BEGIN
47template <class ValueTypeT>
48class 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
59public:
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
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
91 void ConstructBackend(vtkIdList* indexes, vtkDataArray* array);
94
99
104
105protected:
106 vtkIndexedArray() = default;
107 ~vtkIndexedArray() override = default;
108
109private:
110 vtkIndexedArray(const vtkIndexedArray&) = delete;
111 void operator=(const vtkIndexedArray&) = delete;
112};
113
114// Declare vtkArrayDownCast implementations for Indexed arrays:
116
117VTK_ABI_NAMESPACE_END
118
119// This macro is used by the subclasses to create dummy
120// declarations for these functions such that the wrapper
121// can see them. The wrappers ignore vtkIndexedArray.
122#define vtkCreateIndexedWrappedArrayInterface(T) \
123 vtkCreateImplicitWrappedArrayInterface(T); \
124 void ConstructBackend(vtkIdList* indexes, vtkDataArray* array); \
125 void ConstructBackend(vtkDataArray* indexes, vtkDataArray* array); \
126 vtkDataArray* GetBaseArray(); \
127 vtkDataArray* GetIndexArray();
128
129#endif // vtkIndexedArray_h
130
131// This portion must be OUTSIDE the include blockers. This is used to tell
132// libraries other than vtkCommonCore that instantiations of
133// vtkIndexedArray can be found externally. This prevents each library
134// from instantiating these on their own.
135#ifdef VTK_INDEXED_ARRAY_INSTANTIATING
136#define VTK_INDEXED_ARRAY_INSTANTIATE(T) \
137 namespace vtkDataArrayPrivate \
138 { \
139 VTK_ABI_NAMESPACE_BEGIN \
140 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE(vtkIndexedArray<T>, double); \
141 VTK_ABI_NAMESPACE_END \
142 } \
143 VTK_ABI_NAMESPACE_BEGIN \
144 template class VTKCOMMONCORE_EXPORT vtkIndexedArray<T>; \
145 VTK_ABI_NAMESPACE_END
146// We only provide these specializations for the 64-bit integer types, since
147// other types can reuse the double-precision mechanism in
148// vtkDataArray::GetRange without losing precision.
149#define VTK_INDEXED_ARRAY_INSTANTIATE_VALUERANGE(T) \
150 namespace vtkDataArrayPrivate \
151 { \
152 VTK_ABI_NAMESPACE_BEGIN \
153 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE(vtkIndexedArray<T>, T); \
154 VTK_ABI_NAMESPACE_END \
155 }
156#elif defined(VTK_USE_EXTERN_TEMPLATE)
157#ifndef VTK_INDEXED_ARRAY_EXTERN
158#define VTK_INDEXED_ARRAY_EXTERN
159#ifdef _MSC_VER
160#pragma warning(push)
161// The following is needed when the vtkIndexedArray is declared
162// dllexport and is used from another class in vtkCommonCore
163#pragma warning(disable : 4910) // extern and dllexport incompatible
164#endif
165VTK_ABI_NAMESPACE_BEGIN
166vtkExternTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkIndexedArray);
167VTK_ABI_NAMESPACE_END
168
169namespace vtkDataArrayPrivate
170{
171VTK_ABI_NAMESPACE_BEGIN
172
173// These are instantiated in vtkGenericDataArrayValueRange${i}.cxx
178// These are instantiated by vtkIndexedArrayInstantiate_double.cxx.inc, e.t.c.
192
193VTK_ABI_NAMESPACE_END
194} // namespace vtkDataArrayPrivate
195
196#ifdef _MSC_VER
197#pragma warning(pop)
198#endif
199#endif // VTK_INDEXED_ARRAY_EXTERN
200
201// The following clause is only for MSVC
202#elif defined(_MSC_VER) && !defined(VTK_BUILD_SHARED_LIBS)
203#pragma warning(push)
204
205// C4091: 'extern ' : ignored on left of 'int' when no variable is declared
206#pragma warning(disable : 4091)
207
208// Compiler-specific extension warning.
209#pragma warning(disable : 4231)
210
211// We need to disable warning 4910 and do an extern dllexport
212// anyway. When deriving new arrays from an
213// instantiation of this template the compiler does an explicit
214// instantiation of the base class. From outside the vtkCommon
215// library we block this using an extern dllimport instantiation.
216// For classes inside vtkCommon we should be able to just do an
217// extern instantiation, but VS 2008 complains about missing
218// definitions. We cannot do an extern dllimport inside vtkCommon
219// since the symbols are local to the dll. An extern dllexport
220// seems to be the only way to convince VS 2008 to do the right
221// thing, so we just disable the warning.
222#pragma warning(disable : 4910) // extern and dllexport incompatible
223
224// Use an "extern explicit instantiation" to give the class a DLL
225// interface. This is a compiler-specific extension.
226VTK_ABI_NAMESPACE_BEGIN
227vtkInstantiateTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkIndexedArray);
228VTK_ABI_NAMESPACE_END
229
230#pragma warning(pop)
231
232#endif
233
234// VTK-HeaderTest-Exclude: vtkIndexedArray.h
Abstract superclass for all arrays.
std::integral_constant< int, VTK_OPAQUE > DataTypeTag
std::integral_constant< int, vtkArrayTypes::VTK_ABSTRACT_ARRAY > ArrayTypeTag
list of point or cell ids
Definition vtkIdList.h:135
A utility array for creating a wrapper array around an existing array and reindexing its components.
~vtkIndexedArray() override=default
vtkDataArray * GetIndexArray()
Get the original index array used for indirection.
vtkIndexedArray()=default
vtkImplicitArrayTypeMacro(SelfType, ImplicitArrayType)
vtkDataArray * GetBaseArray()
Get the original base array used for value lookup.
void ConstructBackend(vtkDataArray *indexes, vtkDataArray *array)
Set which indexes from array should be exposed.
static vtkIndexedArray< ValueType > * FastDownCast(vtkAbstractArray *source)
A faster alternative to SafeDownCast for downcasting vtkAbstractArrays.
static vtkIndexedArray * New()
vtkIndexedArray< ValueTypeT > SelfType
void ConstructBackend(vtkIdList *indexes, vtkDataArray *array)
Set which indexes from array should be exposed.
#define vtkArrayDownCast_TemplateFastCastMacro(ArrayT)
Same as vtkArrayDownCast_FastCastMacro, but treats ArrayT as a single-parameter template (the paramet...
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_DECLARE_VALUERANGE_ARRAYTYPE(ArrayType, ValueType)
#define vtkCreateImplicitWrappedArrayInterface(T)
#define vtkExternTemplateMacro(decl)
A macro to declare extern templates for all numerical types.
Definition vtkType.h:458
#define vtkInstantiateTemplateMacro(decl)
A macro to instantiate a template over all numerical types.
Definition vtkType.h:411
@ VTK_INDEXED_ARRAY
Definition vtkType.h:94