VTK  9.7.1
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
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 
42 VTK_ABI_NAMESPACE_BEGIN
43 template <class ValueTypeT>
44 class 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
56 public:
58  vtkImplicitArrayTypeMacro(SelfType, ImplicitArrayType);
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 
67  static vtkCompositeArray* New();
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 
92  vtkIdType GetNumberOfArrays();
93 
97  vtkDataArray* GetArray(vtkIdType idx);
98 
102  vtkIdType GetOffset(vtkIdType idx);
103 
104 protected:
105  vtkCompositeArray() = default;
106  ~vtkCompositeArray() override = default;
107 
108 private:
109  vtkCompositeArray(const vtkCompositeArray&) = delete;
110  void operator=(const vtkCompositeArray&) = delete;
111 };
112 
113 // Declare vtkArrayDownCast implementations for Composite arrays:
115 
116 VTK_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 
128 namespace vtk
129 {
130 VTK_ABI_NAMESPACE_BEGIN
139 template <typename ValueTypeT>
141  const std::vector<vtkDataArray*>& arrays);
142 VTK_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
188 VTK_ABI_NAMESPACE_BEGIN
189 vtkExternTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkCompositeArray);
190 VTK_ABI_NAMESPACE_END
191 
192 namespace vtkDataArrayPrivate
193 {
194 VTK_ABI_NAMESPACE_BEGIN
195 
196 // These are instantiated in vtkGenericDataArrayValueRange${i}.cxx
198 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkCompositeArray<unsigned long>, unsigned long)
200 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkCompositeArray<unsigned long long>, unsigned long long)
201 // These are instantiated by vtkCompositeArrayInstantiate_double.cxx.inc, e.t.c.
214 VTK_DECLARE_VALUERANGE_ARRAYTYPE(vtkCompositeArray<unsigned long long>, double)
215 
216 VTK_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.
249 VTK_ABI_NAMESPACE_BEGIN
250 vtkInstantiateTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkCompositeArray);
251 VTK_ABI_NAMESPACE_END
252 
253 #pragma warning(pop)
254 
255 #endif
256 
257 // VTK-HeaderTest-Exclude: vtkCompositeArray.h
vtkSmartPointer< vtkCompositeArray< ValueTypeT > > ConcatenateDataArrays(const std::vector< vtkDataArray * > &arrays)
Abstract superclass for all arrays.
vtkImplicitArrayTypeMacro(SelfType, GenericDataArrayType)
#define VTK_DECLARE_VALUERANGE_ARRAYTYPE(ArrayType, ValueType)
Hold a reference to a vtkObjectBase instance.
Definition: vtkMeta.h:23
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
int vtkIdType
Definition: vtkType.h:363
vtkExternTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkCompositeArray)
static vtkCompositeArray< ValueType > * FastDownCast(vtkAbstractArray *source)
A faster alternative to SafeDownCast for downcasting vtkAbstractArrays.
vtkInstantiateTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkArrayIteratorTemplate)
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
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 ...
maintain an ordered list of dataarray objects
vtkArrayDownCast_TemplateFastCastMacro(vtkCompositeArray)
#define vtkCreateImplicitWrappedArrayInterface(T)
static vtkImplicitArray * New()
A utility array for concatenating arrays into an implicit array.
void ConstructBackend(Params &&...params)
Utility method for setting backend parameterization directly.