VTK  9.6.1
vtkArrayCalculator.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
63
64#ifndef vtkArrayCalculator_h
65#define vtkArrayCalculator_h
66
67#include "vtkDataObject.h" // For attribute types
68#include "vtkFiltersCoreModule.h" // For export macro
70#include "vtkTuple.h" // needed for vtkTuple
71#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
72
73#include <vector> // needed for vector
74
75VTK_ABI_NAMESPACE_BEGIN
76class vtkDataSet;
77
79{
80public:
82 void PrintSelf(ostream& os, vtkIndent indent) override;
84
86
91 vtkSetStringMacro(Function);
92 vtkGetStringMacro(Function);
94
96
106 void AddScalarArrayName(const char* arrayName, int component = 0);
107 void AddVectorArrayName(const char* arrayName);
108 VTK_DEPRECATED_IN_9_6_0("Use AddVectorArrayName(const char* arrayName) instead")
110 const char* arrayName, int component0, int component1 = 1, int component2 = 2)
111 {
112 static_cast<void>(component0); // to avoid unused parameter warning
113 static_cast<void>(component1); // to avoid unused parameter warning
114 static_cast<void>(component2); // to avoid unused parameter warning
115 this->AddVectorArrayName(arrayName);
116 }
117
118
120
126 void AddScalarVariable(const char* variableName, const char* arrayName, int component = 0);
127 void AddVectorVariable(const char* variableName, const char* arrayName);
129 "Use AddVectorVariable(const char* variableName, const char* arrayName) instead")
130 void AddVectorVariable(const char* variableName, const char* arrayName, int component0,
131 int component1 = 1, int component2 = 2)
132 {
133 static_cast<void>(component0); // to avoid unused parameter warning
134 static_cast<void>(component1); // to avoid unused parameter warning
135 static_cast<void>(component2); // to avoid unused parameter warning
136 this->AddVectorVariable(variableName, arrayName);
137 }
138
139
141
147 void AddCoordinateScalarVariable(const char* variableName, int component = 0);
148 void AddCoordinateVectorVariable(const char* variableName);
149 VTK_DEPRECATED_IN_9_6_0("Use AddCoordinateVectorVariable(const char* variableName) instead")
151 const char* variableName, int component0, int component1 = 1, int component2 = 2)
152 {
153 static_cast<void>(component0); // to avoid unused parameter warning
154 static_cast<void>(component1); // to avoid unused parameter warning
155 static_cast<void>(component2); // to avoid unused parameter warning
156 this->AddCoordinateVectorVariable(variableName);
157 }
158
159
161
167 vtkSetStringMacro(ResultArrayName);
168 vtkGetStringMacro(ResultArrayName);
170
172
176 vtkGetMacro(ResultArrayType, int);
177 vtkSetMacro(ResultArrayType, int);
179
181
191
193
198 vtkGetMacro(ResultNormals, bool);
199 vtkSetMacro(ResultNormals, bool);
200 vtkBooleanMacro(ResultNormals, bool);
202
204
209 vtkGetMacro(ResultTCoords, bool);
210 vtkSetMacro(ResultTCoords, bool);
211 vtkBooleanMacro(ResultTCoords, bool);
213
218
219 static const int DEFAULT_ATTRIBUTE_TYPE = -1;
221
227 vtkSetMacro(AttributeType, int);
228 vtkGetMacro(AttributeType, int);
236
241
245 virtual void RemoveScalarVariables();
246
250 virtual void RemoveVectorVariables();
251
256
261
263
266 const std::vector<std::string>& GetScalarArrayNames() { return this->ScalarArrayNames; }
267 std::string GetScalarArrayName(int i);
268 const std::vector<std::string>& GetVectorArrayNames() { return this->VectorArrayNames; }
269 std::string GetVectorArrayName(int i);
270 const std::vector<std::string>& GetScalarVariableNames() { return this->ScalarVariableNames; }
271 std::string GetScalarVariableName(int i);
272 const std::vector<std::string>& GetVectorVariableNames() { return this->VectorVariableNames; }
273 std::string GetVectorVariableName(int i);
274 const std::vector<int>& GetSelectedScalarComponents() { return this->SelectedScalarComponents; }
276 VTK_DEPRECATED_IN_9_6_0("This method no longer returns valid data")
277 const std::vector<vtkTuple<int, 3>>& GetSelectedVectorComponents();
278 VTK_DEPRECATED_IN_9_6_0("This method no longer returns valid data")
279 vtkTuple<int, 3> GetSelectedVectorComponents(int) { return {}; }
280 int GetNumberOfScalarArrays() { return static_cast<int>(this->ScalarArrayNames.size()); }
281 int GetNumberOfVectorArrays() { return static_cast<int>(this->VectorArrayNames.size()); }
282 const std::vector<std::string>& GetCoordinateScalarVariableNames()
283 {
285 }
287 const std::vector<std::string>& GetCoordinateVectorVariableNames()
288 {
290 }
293 {
295 }
298 {
299 return static_cast<int>(this->CoordinateScalarVariableNames.size());
300 }
302 {
303 return static_cast<int>(this->CoordinateVectorVariableNames.size());
304 }
305
306
308
317 vtkSetMacro(ReplacementValue, double);
318 vtkGetMacro(ReplacementValue, double);
320
322
327 vtkSetMacro(IgnoreMissingArrays, bool);
328 vtkGetMacro(IgnoreMissingArrays, bool);
329 vtkBooleanMacro(IgnoreMissingArrays, bool);
331
336 {
337 FunctionParser, // vtkFunctionParser
338 ExprTkFunctionParser, // vtkExprTkFunctionParser
340 };
341
343
360
366
367protected:
370
372
374
379
387 static std::string CheckValidVariableName(const char* variableName);
388
390
391 char* Function;
393 std::vector<std::string> ScalarArrayNames;
394 std::vector<std::string> VectorArrayNames;
395 std::vector<std::string> ScalarVariableNames;
396 std::vector<std::string> VectorVariableNames;
398 std::vector<int> SelectedScalarComponents;
399
403
407 std::vector<std::string> CoordinateScalarVariableNames;
408 std::vector<std::string> CoordinateVectorVariableNames;
410
412
413private:
414 vtkArrayCalculator(const vtkArrayCalculator&) = delete;
415 void operator=(const vtkArrayCalculator&) = delete;
416
417 enum ResultTypes
418 {
419 SCALAR,
420 VECTOR
421 };
422
423 template <typename TFunctionParser, typename TResultArray>
424 class vtkArrayCalculatorFunctor;
425
426 template <typename TFunctionParser>
427 struct vtkArrayCalculatorWorker;
428
429 template <typename TFunctionParser>
430 vtkSmartPointer<TFunctionParser> InitializeFunctionParser(vtkDataObject* input) const;
431
432 // Do the bulk of the work
433 template <typename TFunctionParser>
434 int ProcessDataObject(vtkDataObject* input, vtkDataObject* output);
435};
436
437VTK_ABI_NAMESPACE_END
438#endif
FunctionParserTypes
Enum that includes the types of parsers that can be used.
void SetFunctionParserTypeToFunctionParser()
Set/Get the FunctionParser type that will be used.
const std::vector< std::string > & GetVectorArrayNames()
Methods to get information about the current variables.
void RemoveAllVariables()
Remove all the variable names and their associated array names.
const char * GetAttributeTypeAsString()
Returns a string representation of the calculator's AttributeType.
const std::vector< std::string > & GetCoordinateVectorVariableNames()
Methods to get information about the current variables.
void SetAttributeTypeToVertexData()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
virtual void RemoveCoordinateVectorVariables()
Remove all the coordinate variables.
std::string GetVectorVariableName(int i)
Methods to get information about the current variables.
void SetAttributeTypeToRowData()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
void AddCoordinateVectorVariable(const char *variableName)
Add a variable name, a corresponding array name, and which components of the array to use.
std::string GetCoordinateVectorVariableName(int i)
Methods to get information about the current variables.
const std::vector< vtkTuple< int, 3 > > & GetSelectedVectorComponents()
Methods to get information about the current variables.
void SetAttributeTypeToDefault()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
vtkSetEnumMacro(FunctionParserType, FunctionParserTypes)
Set/Get the FunctionParser type that will be used.
const std::vector< std::string > & GetScalarArrayNames()
Methods to get information about the current variables.
int GetNumberOfVectorArrays()
Methods to get information about the current variables.
vtkTypeBool ReplaceInvalidValues
const std::vector< int > & GetSelectedScalarComponents()
Methods to get information about the current variables.
std::vector< std::string > VectorVariableNames
void AddScalarVariable(const char *variableName, const char *arrayName, int component=0)
Add a variable name, a corresponding array name, and which components of the array to use.
const std::vector< std::string > & GetScalarVariableNames()
Methods to get information about the current variables.
void SetAttributeTypeToEdgeData()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
vtkDataSet * GetDataSetOutput()
Returns the output of the filter downcast to a vtkDataSet or nullptr if the cast fails.
virtual void SetAttributeType(int)
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
void AddVectorArrayName(const char *arrayName)
Add an array name to the list of arrays used in the function and specify which components of the arra...
void AddVectorVariable(const char *variableName, const char *arrayName)
Add a variable name, a corresponding array name, and which components of the array to use.
vtkGetEnumMacro(FunctionParserType, FunctionParserTypes)
Set/Get the FunctionParser type that will be used.
std::string GetScalarArrayName(int i)
Methods to get information about the current variables.
std::string GetScalarVariableName(int i)
Methods to get information about the current variables.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int GetNumberOfScalarArrays()
Methods to get information about the current variables.
static const int DEFAULT_ATTRIBUTE_TYPE
void AddCoordinateScalarVariable(const char *variableName, int component=0)
Add a variable name, a corresponding array name, and which components of the array to use.
int GetNumberOfCoordinateVectorVariables()
Methods to get information about the current variables.
virtual void RemoveVectorVariables()
Remove all the scalar variable names and their associated array names.
static std::string CheckValidVariableName(const char *variableName)
A variable name is valid if it's sanitized or enclosed in quotes.
void SetAttributeTypeToCellData()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
int GetAttributeTypeFromInput(vtkDataObject *input) const
Get the attribute type for the input.
std::vector< int > SelectedScalarComponents
FunctionParserTypes FunctionParserType
const std::vector< std::string > & GetVectorVariableNames()
Methods to get information about the current variables.
std::vector< std::string > CoordinateVectorVariableNames
int GetNumberOfCoordinateScalarVariables()
Methods to get information about the current variables.
std::vector< std::string > ScalarVariableNames
std::vector< int > SelectedCoordinateScalarComponents
void SetFunctionParserTypeToExprTkFunctionParser()
Set/Get the FunctionParser type that will be used.
int GetSelectedCoordinateScalarComponent(int i)
Methods to get information about the current variables.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called within ProcessRequest when a request asks the algorithm to do its work.
std::vector< std::string > ScalarArrayNames
int GetSelectedScalarComponent(int i)
Methods to get information about the current variables.
virtual void RemoveScalarVariables()
Remove all the scalar variable names and their associated array names.
const std::vector< std::string > & GetCoordinateScalarVariableNames()
Methods to get information about the current variables.
void AddScalarArrayName(const char *arrayName, int component=0)
Add an array name to the list of arrays used in the function and specify which components of the arra...
int FillInputPortInformation(int, vtkInformation *) override
void SetAttributeTypeToPointData()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
~vtkArrayCalculator() override
virtual void RemoveCoordinateScalarVariables()
Remove all the coordinate variables.
std::string GetCoordinateScalarVariableName(int i)
Methods to get information about the current variables.
std::vector< std::string > VectorArrayNames
std::string GetVectorArrayName(int i)
Methods to get information about the current variables.
const std::vector< int > & GetSelectedCoordinateScalarComponents()
Methods to get information about the current variables.
std::vector< std::string > CoordinateScalarVariableNames
static vtkArrayCalculator * New()
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:57
a simple class to control print indentation
Definition vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
virtual void Modified()
Update the modification time for this object.
Hold a reference to a vtkObjectBase instance.
templated base type for containers of constant size.
Definition vtkTuple.h:30
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DEPRECATED_IN_9_6_0(reason)
#define VTK_MARSHALAUTO