VTK  9.6.20260317
vtkAffineArray.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
14#ifndef vtkAffineArray_h
15#define vtkAffineArray_h
16
17#include "vtkAffineImplicitBackend.h" // for the array backend
18#include "vtkCommonCoreModule.h" // for export macro
19#include "vtkCompiler.h" // for VTK_USE_EXTERN_TEMPLATE
20#include "vtkImplicitArray.h"
21
22VTK_ABI_NAMESPACE_BEGIN
23template <class ValueTypeT>
24class VTKCOMMONCORE_EXPORT vtkAffineArray
25#ifndef __VTK_WRAP__
26 : public vtkImplicitArray<vtkAffineImplicitBackend<ValueTypeT>, vtkArrayTypes::VTK_AFFINE_ARRAY>
27{
28 using ImplicitArrayType =
30#else // Fake the superclass for the wrappers.
31 : public vtkDataArray
32{
33 using ImplicitArrayType = vtkDataArray;
34#endif
35public:
38#ifndef __VTK_WRAP__
39 using typename Superclass::ArrayTypeTag;
40 using typename Superclass::DataTypeTag;
41 using typename Superclass::ValueType;
42#else
43 using ValueType = ValueTypeT;
44#endif
45
47
48 // This macro expands to the set of method declarations that
49 // make up the interface of vtkImplicitArray, which is ignored
50 // by the wrappers.
51#if defined(__VTK_WRAP__) || defined(__WRAP_GCCXML__)
53#endif
54
59 {
60 return static_cast<vtkAffineArray<ValueType>*>(Superclass::FastDownCast(source));
61 }
62
69 void ConstructBackend(ValueType slope, ValueType intercept);
70
75 {
76 return const_cast<vtkAffineArray<ValueType>*>(this)->GetBackend()->Slope;
77 }
78
83 {
84 return const_cast<vtkAffineArray<ValueType>*>(this)->GetBackend()->Intercept;
85 }
86
87protected:
88 vtkAffineArray() = default;
89 ~vtkAffineArray() override = default;
90
91private:
92 vtkAffineArray(const vtkAffineArray&) = delete;
93 void operator=(const vtkAffineArray&) = delete;
94};
95
96// Declare vtkArrayDownCast implementations for Affine arrays:
98
99VTK_ABI_NAMESPACE_END
100
101// This macro is used by the subclasses to create dummy
102// declarations for these functions such that the wrapper
103// can see them. The wrappers ignore vtkAffineArray.
104#define vtkCreateAffineWrappedArrayInterface(T) \
105 vtkCreateImplicitWrappedArrayInterface(T); \
106 void ConstructBackend(T slope, T intercept); \
107 T GetSlope() const; \
108 T GetIntercept() const;
109
110#endif // vtkAffineArray_h
111
112// This portion must be OUTSIDE the include blockers. This is used to tell
113// libraries other than vtkCommonCore that instantiations of
114// vtkAffineArray can be found externally. This prevents each library
115// from instantiating these on their own.
116#ifdef VTK_AFFINE_ARRAY_INSTANTIATING
117#define VTK_AFFINE_ARRAY_INSTANTIATE(T) \
118 namespace vtkDataArrayPrivate \
119 { \
120 VTK_ABI_NAMESPACE_BEGIN \
121 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE(vtkAffineArray<T>, double); \
122 VTK_ABI_NAMESPACE_END \
123 } \
124 VTK_ABI_NAMESPACE_BEGIN \
125 template class VTKCOMMONCORE_EXPORT vtkAffineArray<T>; \
126 VTK_ABI_NAMESPACE_END
127// We only provide these specializations for the 64-bit integer types, since
128// other types can reuse the double-precision mechanism in
129// vtkDataArray::GetRange without losing precision.
130#define VTK_AFFINE_ARRAY_INSTANTIATE_VALUERANGE(T) \
131 namespace vtkDataArrayPrivate \
132 { \
133 VTK_ABI_NAMESPACE_BEGIN \
134 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE(vtkAffineArray<T>, T); \
135 VTK_ABI_NAMESPACE_END \
136 }
137#elif defined(VTK_USE_EXTERN_TEMPLATE)
138#ifndef VTK_AFFINE_ARRAY_EXTERN
139#define VTK_AFFINE_ARRAY_EXTERN
140#ifdef _MSC_VER
141#pragma warning(push)
142// The following is needed when the vtkAffineArray is declared
143// dllexport and is used from another class in vtkCommonCore
144#pragma warning(disable : 4910) // extern and dllexport incompatible
145#endif
146VTK_ABI_NAMESPACE_BEGIN
147vtkExternTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkAffineArray);
148VTK_ABI_NAMESPACE_END
149
151{
152VTK_ABI_NAMESPACE_BEGIN
153// These are instantiated in vtkGenericDataArrayValueRange${i}.cxx
158// These are instantiated by vtkAffineArrayInstantiate_double.cxx.inc, e.t.c.
172
173VTK_ABI_NAMESPACE_END
174} // namespace vtkDataArrayPrivate
175
176#ifdef _MSC_VER
177#pragma warning(pop)
178#endif
179#endif // VTK_AFFINE_ARRAY_EXTERN
180
181// The following clause is only for MSVC
182#elif defined(_MSC_VER) && !defined(VTK_BUILD_SHARED_LIBS)
183#pragma warning(push)
184
185// C4091: 'extern ' : ignored on left of 'int' when no variable is declared
186#pragma warning(disable : 4091)
187
188// Compiler-specific extension warning.
189#pragma warning(disable : 4231)
190
191// We need to disable warning 4910 and do an extern dllexport
192// anyway. When deriving new arrays from an
193// instantiation of this template the compiler does an explicit
194// instantiation of the base class. From outside the vtkCommon
195// library we block this using an extern dllimport instantiation.
196// For classes inside vtkCommon we should be able to just do an
197// extern instantiation, but VS 2008 complains about missing
198// definitions. We cannot do an extern dllimport inside vtkCommon
199// since the symbols are local to the dll. An extern dllexport
200// seems to be the only way to convince VS 2008 to do the right
201// thing, so we just disable the warning.
202#pragma warning(disable : 4910) // extern and dllexport incompatible
203
204// Use an "extern explicit instantiation" to give the class a DLL
205// interface. This is a compiler-specific extension.
206VTK_ABI_NAMESPACE_BEGIN
207vtkInstantiateTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkAffineArray);
208VTK_ABI_NAMESPACE_END
209
210#pragma warning(pop)
211
212#endif
213
214// VTK-HeaderTest-Exclude: vtkAffineArray.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 wrapping affine functions in implicit arrays.
ValueType GetIntercept() const
Get the intercept of the affine function.
vtkAffineArray< ValueTypeT > SelfType
static vtkAffineArray< ValueType > * FastDownCast(vtkAbstractArray *source)
A faster alternative to SafeDownCast for downcasting vtkAbstractArrays.
vtkImplicitArrayTypeMacro(SelfType, ImplicitArrayType)
void ConstructBackend(ValueType slope, ValueType intercept)
Set the parameters for the affine backend.
vtkAffineArray()=default
~vtkAffineArray() override=default
static vtkAffineArray * New()
ValueType GetSlope() const
Get the slope of the affine function.
std::shared_ptr< BackendT > GetBackend()
Setter/Getter for Backend.
#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_AFFINE_ARRAY
Definition vtkType.h:91