VTK  9.5.20251103
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#ifndef vtkArrayCalculator_h
93#define vtkArrayCalculator_h
94
95#include "vtkDataObject.h" // For attribute types
96#include "vtkFiltersCoreModule.h" // For export macro
98#include "vtkTuple.h" // needed for vtkTuple
99#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
100#include <vector> // needed for vector
101
102VTK_ABI_NAMESPACE_BEGIN
103class vtkDataSet;
104
106{
107public:
109 void PrintSelf(ostream& os, vtkIndent indent) override;
110
112
114
117 vtkSetStringMacro(Function);
118 vtkGetStringMacro(Function);
120
122
132 void AddScalarArrayName(const char* arrayName, int component = 0);
134 const char* arrayName, int component0 = 0, int component1 = 1, int component2 = 2);
136
138
144 void AddScalarVariable(const char* variableName, const char* arrayName, int component = 0);
145 void AddVectorVariable(const char* variableName, const char* arrayName, int component0 = 0,
146 int component1 = 1, int component2 = 2);
148
150
156 void AddCoordinateScalarVariable(const char* variableName, int component = 0);
158 const char* variableName, int component0 = 0, int component1 = 1, int component2 = 2);
160
162
168 vtkSetStringMacro(ResultArrayName);
169 vtkGetStringMacro(ResultArrayName);
171
173
177 vtkGetMacro(ResultArrayType, int);
178 vtkSetMacro(ResultArrayType, int);
180
182
188 vtkGetMacro(CoordinateResults, vtkTypeBool);
189 vtkSetMacro(CoordinateResults, vtkTypeBool);
190 vtkBooleanMacro(CoordinateResults, vtkTypeBool);
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);
230 void SetAttributeTypeToDefault() { this->SetAttributeType(DEFAULT_ATTRIBUTE_TYPE); }
231 void SetAttributeTypeToPointData() { this->SetAttributeType(vtkDataObject::POINT); }
232 void SetAttributeTypeToCellData() { this->SetAttributeType(vtkDataObject::CELL); }
233 void SetAttributeTypeToEdgeData() { this->SetAttributeType(vtkDataObject::EDGE); }
234 void SetAttributeTypeToVertexData() { this->SetAttributeType(vtkDataObject::VERTEX); }
235 void SetAttributeTypeToRowData() { this->SetAttributeType(vtkDataObject::ROW); }
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 const std::vector<vtkTuple<int, 3>>& GetSelectedVectorComponents()
278 {
279 return this->SelectedVectorComponents;
280 }
282 int GetNumberOfScalarArrays() { return static_cast<int>(this->ScalarArrayNames.size()); }
283 int GetNumberOfVectorArrays() { return static_cast<int>(this->VectorArrayNames.size()); }
285
287
293 vtkSetMacro(ReplaceInvalidValues, vtkTypeBool);
294 vtkGetMacro(ReplaceInvalidValues, vtkTypeBool);
295 vtkBooleanMacro(ReplaceInvalidValues, vtkTypeBool);
296 vtkSetMacro(ReplacementValue, double);
297 vtkGetMacro(ReplacementValue, double);
299
301
306 vtkSetMacro(IgnoreMissingArrays, bool);
307 vtkGetMacro(IgnoreMissingArrays, bool);
308 vtkBooleanMacro(IgnoreMissingArrays, bool);
310
315 {
316 FunctionParser, // vtkFunctionParser
317 ExprTkFunctionParser, // vtkExprTkFunctionParser
318 NumberOfFunctionParserTypes
319 };
320
322
328 {
329 this->FunctionParserType = FunctionParserTypes::FunctionParser;
330 this->Modified();
331 }
333 {
334 this->FunctionParserType = FunctionParserTypes::ExprTkFunctionParser;
335 this->Modified();
336 }
339
345
346protected:
349
351
353
358
366 static std::string CheckValidVariableName(const char* variableName);
367
369
370 char* Function;
372 std::vector<std::string> ScalarArrayNames;
373 std::vector<std::string> VectorArrayNames;
374 std::vector<std::string> ScalarVariableNames;
375 std::vector<std::string> VectorVariableNames;
377 std::vector<int> SelectedScalarComponents;
378 std::vector<vtkTuple<int, 3>> SelectedVectorComponents;
379
383
387 std::vector<std::string> CoordinateScalarVariableNames;
388 std::vector<std::string> CoordinateVectorVariableNames;
390 std::vector<vtkTuple<int, 3>> SelectedCoordinateVectorComponents;
391
393
394private:
395 vtkArrayCalculator(const vtkArrayCalculator&) = delete;
396 void operator=(const vtkArrayCalculator&) = delete;
397
398 // Do the bulk of the work
399 template <typename TFunctionParser>
400 int ProcessDataObject(vtkDataObject* input, vtkDataObject* output);
401};
402
403VTK_ABI_NAMESPACE_END
404#endif
perform mathematical operations on data in field data arrays
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.
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).
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.
vtkTuple< int, 3 > GetSelectedVectorComponents(int i)
Methods to get information about the current variables.
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.
std::vector< vtkTuple< int, 3 > > SelectedVectorComponents
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.
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.
std::vector< vtkTuple< int, 3 > > SelectedCoordinateVectorComponents
void AddVectorArrayName(const char *arrayName, int component0=0, int component1=1, int component2=2)
Add an array name to the list of arrays used in the function and specify which components of the arra...
void AddCoordinateScalarVariable(const char *variableName, int component=0)
Add a variable name, a corresponding array name, and which components of the array to use.
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).
std::vector< int > SelectedScalarComponents
void AddVectorVariable(const char *variableName, const char *arrayName, int component0=0, int component1=1, int component2=2)
Add a variable name, a corresponding array name, and which components of the array to use.
FunctionParserTypes FunctionParserType
const std::vector< std::string > & GetVectorVariableNames()
Methods to get information about the current variables.
std::vector< std::string > CoordinateVectorVariableNames
int GetAttributeTypeFromInput(vtkDataObject *input)
Get the attribute type for the input.
void AddCoordinateVectorVariable(const char *variableName, int component0=0, int component1=1, int component2=2)
Add a variable name, a corresponding array name, and which components of the array to use.
std::vector< std::string > ScalarVariableNames
std::vector< int > SelectedCoordinateScalarComponents
void SetFunctionParserTypeToExprTkFunctionParser()
Set/Get the FunctionParser type that will be used.
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.
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::vector< std::string > VectorArrayNames
std::string GetVectorArrayName(int i)
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.
Superclass for algorithms that produce output of the same type as input.
templated base type for containers of constant size.
Definition vtkTuple.h:30
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_MARSHALAUTO