VTK  9.6.20260320
vtkCompositeArray.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
31
32#ifndef vtkCompositeArray_h
33#define vtkCompositeArray_h
34
35#include "vtkCommonCoreModule.h" // for export macro
36#include "vtkCompiler.h" // for VTK_USE_EXTERN_TEMPLATE
37#include "vtkCompositeImplicitBackend.h" // for the array backend
38#include "vtkImplicitArray.h"
39
40#include <vector>
41
42VTK_ABI_NAMESPACE_BEGIN
43template <class ValueTypeT>
44class VTKCOMMONCORE_EXPORT vtkCompositeArray
45#ifndef __VTK_WRAP__
46 : public vtkImplicitArray<vtkCompositeImplicitBackend<ValueTypeT>,
47 vtkArrayTypes::VTK_COMPOSITE_ARRAY>
48{
49 using ImplicitArrayType =
51#else // Fake the superclass for the wrappers.
52 : public vtkDataArray
53{
54 using ImplicitArrayType = vtkDataArray;
55#endif
56public:
59#ifndef __VTK_WRAP__
60 using typename Superclass::ArrayTypeTag;
61 using typename Superclass::DataTypeTag;
62 using typename Superclass::ValueType;
63#else
64 using ValueType = ValueTypeT;
65#endif
66
68
69 // This macro expands to the set of method declarations that
70 // make up the interface of vtkImplicitArray, which is ignored
71 // by the wrappers.
72#if defined(__VTK_WRAP__) || defined(__WRAP_GCCXML__)
74#endif
75
80 {
81 return static_cast<vtkCompositeArray<ValueType>*>(Superclass::FastDownCast(source));
82 }
83
88
93
98
103
104protected:
105 vtkCompositeArray() = default;
106 ~vtkCompositeArray() override = default;
107
108private:
109 vtkCompositeArray(const vtkCompositeArray&) = delete;
110 void operator=(const vtkCompositeArray&) = delete;
111};
112
113// Declare vtkArrayDownCast implementations for Composite arrays:
115
116VTK_ABI_NAMESPACE_END
117
118// This macro is used by the subclasses to create dummy
119// declarations for these functions such that the wrapper
120// can see them. The wrappers ignore vtkCompositeArray.
121#define vtkCreateCompositeWrappedArrayInterface(T) \
122 vtkCreateImplicitWrappedArrayInterface(T); \
123 void ConstructBackend(vtkDataArrayCollection* arrays); \
124 vtkIdType GetNumberOfArrays(); \
125 vtkDataArray* GetArray(vtkIdType idx); \
126 vtkIdType GetOffset(vtkIdType idx);
127
128namespace vtk
129{
130VTK_ABI_NAMESPACE_BEGIN
139template <typename ValueTypeT>
141 const std::vector<vtkDataArray*>& arrays);
142VTK_ABI_NAMESPACE_END
143}
144
145#endif // vtkCompositeArray_h
146
147// This portion must be OUTSIDE the include blockers. This is used to tell
148// libraries other than vtkCommonCore that instantiations of
149// vtkCompositeArray can be found externally. This prevents each library
150// from instantiating these on their own.
151#ifdef VTK_COMPOSITE_ARRAY_INSTANTIATING
152#define VTK_COMPOSITE_ARRAY_INSTANTIATE(T) \
153 namespace vtkDataArrayPrivate \
154 { \
155 VTK_ABI_NAMESPACE_BEGIN \
156 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE(vtkCompositeArray<T>, double); \
157 VTK_ABI_NAMESPACE_END \
158 } \
159 VTK_ABI_NAMESPACE_BEGIN \
160 template class VTKCOMMONCORE_EXPORT vtkCompositeArray<T>; \
161 VTK_ABI_NAMESPACE_END \
162 namespace vtk \
163 { \
164 VTK_ABI_NAMESPACE_BEGIN \
165 template VTKCOMMONCORE_EXPORT vtkSmartPointer<vtkCompositeArray<T>> ConcatenateDataArrays( \
166 const std::vector<vtkDataArray*>& arrays); \
167 VTK_ABI_NAMESPACE_END \
168 }
169// We only provide these specializations for the 64-bit integer types, since
170// other types can reuse the double-precision mechanism in
171// vtkDataArray::GetRange without losing precision.
172#define VTK_COMPOSITE_ARRAY_INSTANTIATE_VALUERANGE(T) \
173 namespace vtkDataArrayPrivate \
174 { \
175 VTK_ABI_NAMESPACE_BEGIN \
176 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE(vtkCompositeArray<T>, T); \
177 VTK_ABI_NAMESPACE_END \
178 }
179#elif defined(VTK_USE_EXTERN_TEMPLATE)
180#ifndef VTK_COMPOSITE_ARRAY_EXTERN
181#define VTK_COMPOSITE_ARRAY_EXTERN
182#ifdef _MSC_VER
183#pragma warning(push)
184// The following is needed when the vtkCompositeArray is declared
185// dllexport and is used from another class in vtkCommonCore
186#pragma warning(disable : 4910) // extern and dllexport incompatible
187#endif
188VTK_ABI_NAMESPACE_BEGIN
189vtkExternTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkCompositeArray);
190VTK_ABI_NAMESPACE_END
191
192namespace vtkDataArrayPrivate
193{
194VTK_ABI_NAMESPACE_BEGIN
195
196// These are instantiated in vtkGenericDataArrayValueRange${i}.cxx
201// These are instantiated by vtkCompositeArrayInstantiate_double.cxx.inc, e.t.c.
215
216VTK_ABI_NAMESPACE_END
217} // namespace vtkDataArrayPrivate
218
219#ifdef _MSC_VER
220#pragma warning(pop)
221#endif
222#endif // VTK_COMPOSITE_ARRAY_EXTERN
223
224// The following clause is only for MSVC
225#elif defined(_MSC_VER) && !defined(VTK_BUILD_SHARED_LIBS)
226#pragma warning(push)
227
228// C4091: 'extern ' : ignored on left of 'int' when no variable is declared
229#pragma warning(disable : 4091)
230
231// Compiler-specific extension warning.
232#pragma warning(disable : 4231)
233
234// We need to disable warning 4910 and do an extern dllexport
235// anyway. When deriving new arrays from an
236// instantiation of this template the compiler does an explicit
237// instantiation of the base class. From outside the vtkCommon
238// library we block this using an extern dllimport instantiation.
239// For classes inside vtkCommon we should be able to just do an
240// extern instantiation, but VS 2008 complains about missing
241// definitions. We cannot do an extern dllimport inside vtkCommon
242// since the symbols are local to the dll. An extern dllexport
243// seems to be the only way to convince VS 2008 to do the right
244// thing, so we just disable the warning.
245#pragma warning(disable : 4910) // extern and dllexport incompatible
246
247// Use an "extern explicit instantiation" to give the class a DLL
248// interface. This is a compiler-specific extension.
249VTK_ABI_NAMESPACE_BEGIN
250vtkInstantiateTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkCompositeArray);
251VTK_ABI_NAMESPACE_END
252
253#pragma warning(pop)
254
255#endif
256
257// VTK-HeaderTest-Exclude: vtkCompositeArray.h
Abstract superclass for all arrays.
std::integral_constant< int, VTK_OPAQUE > DataTypeTag
std::integral_constant< int, vtkArrayTypes::VTK_ABSTRACT_ARRAY > ArrayTypeTag
A utility array for concatenating arrays into an implicit array.
vtkCompositeArray< ValueTypeT > SelfType
static vtkCompositeArray * New()
static vtkCompositeArray< ValueType > * FastDownCast(vtkAbstractArray *source)
A faster alternative to SafeDownCast for downcasting vtkAbstractArrays.
void ConstructBackend(vtkDataArrayCollection *arrays)
Set the underlying arrays to use.
~vtkCompositeArray() override=default
vtkIdType GetNumberOfArrays()
Get the number of original arrays composing this composite array.
vtkImplicitArrayTypeMacro(SelfType, ImplicitArrayType)
vtkDataArray * GetArray(vtkIdType idx)
Get the original array at the given index.
vtkIdType GetOffset(vtkIdType idx)
Get the tuple offset of the array at the given index.
vtkCompositeArray()=default
maintain an ordered list of dataarray objects
Hold a reference to a vtkObjectBase instance.
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
vtkSmartPointer< vtkCompositeArray< ValueTypeT > > ConcatenateDataArrays(const std::vector< vtkDataArray * > &arrays)
#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
int vtkIdType
Definition vtkType.h:363
#define vtkInstantiateTemplateMacro(decl)
A macro to instantiate a template over all numerical types.
Definition vtkType.h:411
@ VTK_COMPOSITE_ARRAY
Definition vtkType.h:92