VTK  9.7.20260724
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);
138
140
146 void AddScalarVariable(const char* variableName, const char* arrayName, int component = 0);
147 void AddVectorVariable(const char* variableName, const char* arrayName);
149
151
157 void AddCoordinateScalarVariable(const char* variableName, int component = 0);
158 void AddCoordinateVectorVariable(const char* variableName);
160
162
168 vtkSetStringMacro(ResultArrayName);
169 vtkGetStringMacro(ResultArrayName);
171
173
177 vtkGetMacro(ResultArrayType, int);
178 vtkSetMacro(ResultArrayType, int);
180
182
192
194
199 vtkGetMacro(ResultNormals, bool);
200 vtkSetMacro(ResultNormals, bool);
201 vtkBooleanMacro(ResultNormals, bool);
203
205
210 vtkGetMacro(ResultTCoords, bool);
211 vtkSetMacro(ResultTCoords, bool);
212 vtkBooleanMacro(ResultTCoords, bool);
214
219
220 static const int DEFAULT_ATTRIBUTE_TYPE = -1;
222
228 vtkSetMacro(AttributeType, int);
229 vtkGetMacro(AttributeType, int);
237
242
246 virtual void RemoveScalarVariables();
247
251 virtual void RemoveVectorVariables();
252
257
262
264
267 const std::vector<std::string>& GetScalarArrayNames() { return this->ScalarArrayNames; }
268 std::string GetScalarArrayName(int i);
269 const std::vector<std::string>& GetVectorArrayNames() { return this->VectorArrayNames; }
270 std::string GetVectorArrayName(int i);
271 const std::vector<std::string>& GetScalarVariableNames() { return this->ScalarVariableNames; }
272 std::string GetScalarVariableName(int i);
273 const std::vector<std::string>& GetVectorVariableNames() { return this->VectorVariableNames; }
274 std::string GetVectorVariableName(int i);
275 const std::vector<int>& GetSelectedScalarComponents() { return this->SelectedScalarComponents; }
277 int GetNumberOfScalarArrays() { return static_cast<int>(this->ScalarArrayNames.size()); }
278 int GetNumberOfVectorArrays() { return static_cast<int>(this->VectorArrayNames.size()); }
279 const std::vector<std::string>& GetCoordinateScalarVariableNames()
280 {
282 }
284 const std::vector<std::string>& GetCoordinateVectorVariableNames()
285 {
287 }
290 {
292 }
295 {
296 return static_cast<int>(this->CoordinateScalarVariableNames.size());
297 }
299 {
300 return static_cast<int>(this->CoordinateVectorVariableNames.size());
301 }
302
303
305
314 vtkSetMacro(ReplacementValue, double);
315 vtkGetMacro(ReplacementValue, double);
317
319
324 vtkSetMacro(IgnoreMissingArrays, bool);
325 vtkGetMacro(IgnoreMissingArrays, bool);
326 vtkBooleanMacro(IgnoreMissingArrays, bool);
328
333 {
334 FunctionParser, // vtkFunctionParser
335 ExprTkFunctionParser, // vtkExprTkFunctionParser
337 };
338
340
357
363
364protected:
367
369
371
376
384 static std::string CheckValidVariableName(const char* variableName);
385
387
388 char* Function;
390 std::vector<std::string> ScalarArrayNames;
391 std::vector<std::string> VectorArrayNames;
392 std::vector<std::string> ScalarVariableNames;
393 std::vector<std::string> VectorVariableNames;
395 std::vector<int> SelectedScalarComponents;
396
400
404 std::vector<std::string> CoordinateScalarVariableNames;
405 std::vector<std::string> CoordinateVectorVariableNames;
407
409
410private:
411 vtkArrayCalculator(const vtkArrayCalculator&) = delete;
412 void operator=(const vtkArrayCalculator&) = delete;
413
414 enum ResultTypes
415 {
416 SCALAR,
417 VECTOR
418 };
419
420 template <typename TFunctionParser, typename TResultArray>
421 class vtkArrayCalculatorFunctor;
422
423 template <typename TFunctionParser>
424 struct vtkArrayCalculatorWorker;
425
426 template <typename TFunctionParser>
427 vtkSmartPointer<TFunctionParser> InitializeFunctionParser(vtkDataObject* input) const;
428
429 // Do the bulk of the work
430 template <typename TFunctionParser>
431 int ProcessDataObject(vtkDataObject* input, vtkDataObject* output);
432};
433
434VTK_ABI_NAMESPACE_END
435#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.
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:165
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.
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_MARSHALAUTO