VTK  9.5.20250916
vtkArrayComponents.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#ifndef vtkArrayComponents_h
4#define vtkArrayComponents_h
5
6#include "vtkCommonCoreModule.h" // For export macros
7#include "vtkCompiler.h" // For VTK_ALWAYS_EXPORT
8#include "vtkDataArray.h" // For API
9#include "vtkSmartPointer.h" // For API
10
11#include <string>
12
13VTK_ABI_NAMESPACE_BEGIN
14
16class vtkDataArray;
17
34{
35 L1Norm = -1, // Take the L₁ norm of all components and treat it as a virtual component.
36 L2Norm = -2, // Take the L₂ norm of all components and treat it as a virtual component.
37 LInfNorm = -99, // Take the L∞ norm of all components and treat it as a virtual component.
38 AllComponents = -100, // Do not isolate a single component; use the entire tuple value.
39 Requested = -101 // Use whatever component(s) a filter was requested to process.
40};
41
42VTK_ABI_NAMESPACE_END
43
44namespace vtk
45{
46
47VTK_ABI_NAMESPACE_BEGIN
48
50int VTKCOMMONCORE_EXPORT ArrayComponents(const std::string& enumerantStr);
51
55std::string VTKCOMMONCORE_EXPORT to_string(vtkArrayComponents enumerant);
56
58template <typename T>
59T VTK_ALWAYS_EXPORT to_enumerant(const std::string&);
60
62template <>
63inline vtkArrayComponents to_enumerant<vtkArrayComponents>(const std::string& enumerantStr)
64{
65 return static_cast<vtkArrayComponents>(ArrayComponents(enumerantStr));
66}
67
69
89 vtkAbstractArray* array, int compOrNorm);
90
92 vtkDataArray* array, int compOrNorm)
93{
94 // This variant only handles input data arrays, but returns a vtkDataArray
95 // rather than forcing you to cast it afterward.
96 auto intermediate = ComponentOrNormAsArray(array, compOrNorm);
97 vtkSmartPointer<vtkDataArray> result = vtkDataArray::SafeDownCast(intermediate.GetPointer());
98 return result;
99}
101
102VTK_ABI_NAMESPACE_END
103
104} // vtk namespace
105
106#endif // vtkArrayComponents_h
107// VTK-HeaderTest-Exclude: vtkArrayComponents.h
Abstract superclass for all arrays.
abstract superclass for arrays of numeric data
Hold a reference to a vtkObjectBase instance.
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
vtkSmartPointer< vtkAbstractArray > VTKCOMMONCORE_EXPORT ComponentOrNormAsArray(vtkAbstractArray *array, int compOrNorm)
Return a new array with a single component whose tuple-values are either a component of the input arr...
vtkArrayComponents to_enumerant< vtkArrayComponents >(const std::string &enumerantStr)
A specialization of the generic template above.
int VTKCOMMONCORE_EXPORT ArrayComponents(const std::string &enumerantStr)
Given a string, return an "array component" enumerant.
T VTK_ALWAYS_EXPORT to_enumerant(const std::string &)
A generic template to convert strings to enumerant values.
std::string VTKCOMMONCORE_EXPORT to_string(vtkArrayComponents enumerant)
Given an enumerant, return a human-presentable string with its value.
vtkSmartPointer< vtkDataArray > VTKCOMMONCORE_EXPORT ComponentOrNormAsDataArray(vtkDataArray *array, int compOrNorm)
Return a new array with a single component whose tuple-values are either a component of the input arr...
vtkArrayComponents
An enumeration for specifying components of a vtkAbstractArray's tuples.
@ AllComponents
@ Requested
@ LInfNorm
#define VTK_ALWAYS_EXPORT
Definition vtkCompiler.h:65