VTK  9.6.20260111
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
92
93#ifndef vtkArrayCalculator_h
94#define vtkArrayCalculator_h
95
96#include "vtkDataObject.h" // For attribute types
97#include "vtkFiltersCoreModule.h" // For export macro
99#include "vtkTuple.h" // needed for vtkTuple
100#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
101
102#include <vector> // needed for vector
103
104VTK_ABI_NAMESPACE_BEGIN
105class vtkDataSet;
106
108{
109public:
111 void PrintSelf(ostream& os, vtkIndent indent) override;
113
115
120 vtkSetStringMacro(Function);
121 vtkGetStringMacro(Function);
123
125
135 void AddScalarArrayName(const char* arrayName, int component = 0);
136 void AddVectorArrayName(const char* arrayName);
137 VTK_DEPRECATED_IN_9_6_0("Use AddVectorArrayName(const char* arrayName) instead")
139 const char* arrayName, int component0, int component1 = 1, int component2 = 2)
140 {
141 static_cast<void>(component0); // to avoid unused parameter warning
142 static_cast<void>(component1); // to avoid unused parameter warning
143 static_cast<void>(component2); // to avoid unused parameter warning
144 this->AddVectorArrayName(arrayName);
145 }
146
147
149
155 void AddScalarVariable(const char* variableName, const char* arrayName, int component = 0);
156 void AddVectorVariable(const char* variableName, const char* arrayName);
158 "Use AddVectorVariable(const char* variableName, const char* arrayName) instead")
159 void AddVectorVariable(const char* variableName, const char* arrayName, int component0,
160 int component1 = 1, int component2 = 2)
161 {
162 static_cast<void>(component0); // to avoid unused parameter warning
163 static_cast<void>(component1); // to avoid unused parameter warning
164 static_cast<void>(component2); // to avoid unused parameter warning
165 this->AddVectorVariable(variableName, arrayName);
166 }
167
168
170
176 void AddCoordinateScalarVariable(const char* variableName, int component = 0);
177 void AddCoordinateVectorVariable(const char* variableName);
178 VTK_DEPRECATED_IN_9_6_0("Use AddCoordinateVectorVariable(const char* variableName) instead")
180 const char* variableName, int component0, int component1 = 1, int component2 = 2)
181 {
182 static_cast<void>(component0); // to avoid unused parameter warning
183 static_cast<void>(component1); // to avoid unused parameter warning
184 static_cast<void>(component2); // to avoid unused parameter warning
185 this->AddCoordinateVectorVariable(variableName);
186 }
187
188
190
196 vtkSetStringMacro(ResultArrayName);
197 vtkGetStringMacro(ResultArrayName);
199
201
205 vtkGetMacro(ResultArrayType, int);
206 vtkSetMacro(ResultArrayType, int);
208
210
220
222
227 vtkGetMacro(ResultNormals, bool);
228 vtkSetMacro(ResultNormals, bool);
229 vtkBooleanMacro(ResultNormals, bool);
231
233
238 vtkGetMacro(ResultTCoords, bool);
239 vtkSetMacro(ResultTCoords, bool);
240 vtkBooleanMacro(ResultTCoords, bool);
242
247
248 static const int DEFAULT_ATTRIBUTE_TYPE = -1;
250
256 vtkSetMacro(AttributeType, int);
257 vtkGetMacro(AttributeType, int);
265
270
274 virtual void RemoveScalarVariables();
275
279 virtual void RemoveVectorVariables();
280
285
290
292
295 const std::vector<std::string>& GetScalarArrayNames() { return this->ScalarArrayNames; }
296 std::string GetScalarArrayName(int i);
297 const std::vector<std::string>& GetVectorArrayNames() { return this->VectorArrayNames; }
298 std::string GetVectorArrayName(int i);
299 const std::vector<std::string>& GetScalarVariableNames() { return this->ScalarVariableNames; }
300 std::string GetScalarVariableName(int i);
301 const std::vector<std::string>& GetVectorVariableNames() { return this->VectorVariableNames; }
302 std::string GetVectorVariableName(int i);
303 const std::vector<int>& GetSelectedScalarComponents() { return this->SelectedScalarComponents; }
305 VTK_DEPRECATED_IN_9_6_0("This method no longer returns valid data")
306 const std::vector<vtkTuple<int, 3>>& GetSelectedVectorComponents();
307 VTK_DEPRECATED_IN_9_6_0("This method no longer returns valid data")
308 vtkTuple<int, 3> GetSelectedVectorComponents(int) { return {}; }
309 int GetNumberOfScalarArrays() { return static_cast<int>(this->ScalarArrayNames.size()); }
310 int GetNumberOfVectorArrays() { return static_cast<int>(this->VectorArrayNames.size()); }
311 const std::vector<std::string>& GetCoordinateScalarVariableNames()
312 {
314 }
316 const std::vector<std::string>& GetCoordinateVectorVariableNames()
317 {
319 }
322 {
324 }
327 {
328 return static_cast<int>(this->CoordinateScalarVariableNames.size());
329 }
331 {
332 return static_cast<int>(this->CoordinateVectorVariableNames.size());
333 }
334
335
337
346 vtkSetMacro(ReplacementValue, double);
347 vtkGetMacro(ReplacementValue, double);
349
351
356 vtkSetMacro(IgnoreMissingArrays, bool);
357 vtkGetMacro(IgnoreMissingArrays, bool);
358 vtkBooleanMacro(IgnoreMissingArrays, bool);
360
365 {
366 FunctionParser, // vtkFunctionParser
367 ExprTkFunctionParser, // vtkExprTkFunctionParser
369 };
370
372
389
395
396protected:
399
401
403
408
416 static std::string CheckValidVariableName(const char* variableName);
417
419
420 char* Function;
422 std::vector<std::string> ScalarArrayNames;
423 std::vector<std::string> VectorArrayNames;
424 std::vector<std::string> ScalarVariableNames;
425 std::vector<std::string> VectorVariableNames;
427 std::vector<int> SelectedScalarComponents;
428
432
436 std::vector<std::string> CoordinateScalarVariableNames;
437 std::vector<std::string> CoordinateVectorVariableNames;
439
441
442private:
443 vtkArrayCalculator(const vtkArrayCalculator&) = delete;
444 void operator=(const vtkArrayCalculator&) = delete;
445
446 enum ResultTypes
447 {
448 SCALAR,
449 VECTOR
450 };
451
452 template <typename TFunctionParser, typename TResultArray>
453 class vtkArrayCalculatorFunctor;
454
455 template <typename TFunctionParser>
456 struct vtkArrayCalculatorWorker;
457
458 template <typename TFunctionParser>
459 vtkSmartPointer<TFunctionParser> InitializeFunctionParser(vtkDataObject* input) const;
460
461 // Do the bulk of the work
462 template <typename TFunctionParser>
463 int ProcessDataObject(vtkDataObject* input, vtkDataObject* output);
464};
465
466VTK_ABI_NAMESPACE_END
467#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
Fill the input port information objects for this algorithm.
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:166
a simple class to control print indentation
Definition vtkIndent.h:108
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