VTK  9.6.20260430
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
92 void ConstructBackend(vtkIdList* indexes, vtkDataArray* array, bool mapTuples = false);
93 void ConstructBackend(vtkDataArray* indexes, vtkDataArray* array, bool mapTuples = false);
95
100
105
110
111protected:
112 vtkIndexedArray() = default;
113 ~vtkIndexedArray() override = default;
114
115private:
116 vtkIndexedArray(const vtkIndexedArray&) = delete;
117 void operator=(const vtkIndexedArray&) = delete;
118};
119
120// Declare vtkArrayDownCast implementations for Indexed arrays:
122
123VTK_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
171VTK_ABI_NAMESPACE_BEGIN
172vtkExternTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkIndexedArray);
173VTK_ABI_NAMESPACE_END
174
175namespace vtkDataArrayPrivate
176{
177VTK_ABI_NAMESPACE_BEGIN
178
179// These are instantiated in vtkGenericDataArrayValueRange${i}.cxx
184// These are instantiated by vtkIndexedArrayInstantiate_double.cxx.inc, e.t.c.
198
199VTK_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.
232VTK_ABI_NAMESPACE_BEGIN
233vtkInstantiateTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkIndexedArray);
234VTK_ABI_NAMESPACE_END
235
236#pragma warning(pop)
237
238#endif
239
240// 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, bool mapTuples=false)
Set which indexes from array should be exposed and if we want to map values or tuples.
static vtkIndexedArray< ValueType > * FastDownCast(vtkAbstractArray *source)
A faster alternative to SafeDownCast for downcasting vtkAbstractArrays.
static vtkIndexedArray * New()
bool GetMapTuples()
Get the original index array used for indirection.
vtkIndexedArray< ValueTypeT > SelfType
void ConstructBackend(vtkIdList *indexes, vtkDataArray *array, bool mapTuples=false)
Set which indexes from array should be exposed and if we want to map values or tuples.
#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