VTK  9.2.6
vtkArrayCalculator.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkArrayCalculator.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
84#ifndef vtkArrayCalculator_h
85#define vtkArrayCalculator_h
86
87#include "vtkDataObject.h" // For attribute types
88#include "vtkFiltersCoreModule.h" // For export macro
90#include "vtkTuple.h" // needed for vtkTuple
91#include <vector> // needed for vector
92
93class vtkDataSet;
94
95class VTKFILTERSCORE_EXPORT vtkArrayCalculator : public vtkPassInputTypeAlgorithm
96{
97public:
99 void PrintSelf(ostream& os, vtkIndent indent) override;
100
102
104
107 vtkSetStringMacro(Function);
108 vtkGetStringMacro(Function);
110
112
122 void AddScalarArrayName(const char* arrayName, int component = 0);
124 const char* arrayName, int component0 = 0, int component1 = 1, int component2 = 2);
126
128
134 void AddScalarVariable(const char* variableName, const char* arrayName, int component = 0);
135 void AddVectorVariable(const char* variableName, const char* arrayName, int component0 = 0,
136 int component1 = 1, int component2 = 2);
138
140
146 void AddCoordinateScalarVariable(const char* variableName, int component = 0);
148 const char* variableName, int component0 = 0, int component1 = 1, int component2 = 2);
150
152
158 vtkSetStringMacro(ResultArrayName);
159 vtkGetStringMacro(ResultArrayName);
161
163
167 vtkGetMacro(ResultArrayType, int);
168 vtkSetMacro(ResultArrayType, int);
170
172
178 vtkGetMacro(CoordinateResults, vtkTypeBool);
179 vtkSetMacro(CoordinateResults, vtkTypeBool);
180 vtkBooleanMacro(CoordinateResults, vtkTypeBool);
182
184
189 vtkGetMacro(ResultNormals, bool);
190 vtkSetMacro(ResultNormals, bool);
191 vtkBooleanMacro(ResultNormals, bool);
193
195
200 vtkGetMacro(ResultTCoords, bool);
201 vtkSetMacro(ResultTCoords, bool);
202 vtkBooleanMacro(ResultTCoords, bool);
204
209
210 static const int DEFAULT_ATTRIBUTE_TYPE = -1;
212
218 vtkSetMacro(AttributeType, int);
219 vtkGetMacro(AttributeType, int);
220 void SetAttributeTypeToDefault() { this->SetAttributeType(DEFAULT_ATTRIBUTE_TYPE); }
221 void SetAttributeTypeToPointData() { this->SetAttributeType(vtkDataObject::POINT); }
222 void SetAttributeTypeToCellData() { this->SetAttributeType(vtkDataObject::CELL); }
223 void SetAttributeTypeToEdgeData() { this->SetAttributeType(vtkDataObject::EDGE); }
224 void SetAttributeTypeToVertexData() { this->SetAttributeType(vtkDataObject::VERTEX); }
225 void SetAttributeTypeToRowData() { this->SetAttributeType(vtkDataObject::ROW); }
227
232
236 virtual void RemoveScalarVariables();
237
241 virtual void RemoveVectorVariables();
242
247
252
254
257 const std::vector<std::string>& GetScalarArrayNames() { return this->ScalarArrayNames; }
258 std::string GetScalarArrayName(int i);
259 const std::vector<std::string>& GetVectorArrayNames() { return this->VectorArrayNames; }
260 std::string GetVectorArrayName(int i);
261 const std::vector<std::string>& GetScalarVariableNames() { return this->ScalarVariableNames; }
262 std::string GetScalarVariableName(int i);
263 const std::vector<std::string>& GetVectorVariableNames() { return this->VectorVariableNames; }
264 std::string GetVectorVariableName(int i);
265 const std::vector<int>& GetSelectedScalarComponents() { return this->SelectedScalarComponents; }
267 const std::vector<vtkTuple<int, 3>>& GetSelectedVectorComponents()
268 {
269 return this->SelectedVectorComponents;
270 }
272 int GetNumberOfScalarArrays() { return static_cast<int>(this->ScalarArrayNames.size()); }
273 int GetNumberOfVectorArrays() { return static_cast<int>(this->VectorArrayNames.size()); }
275
277
283 vtkSetMacro(ReplaceInvalidValues, vtkTypeBool);
284 vtkGetMacro(ReplaceInvalidValues, vtkTypeBool);
285 vtkBooleanMacro(ReplaceInvalidValues, vtkTypeBool);
286 vtkSetMacro(ReplacementValue, double);
287 vtkGetMacro(ReplacementValue, double);
289
291
296 vtkSetMacro(IgnoreMissingArrays, bool);
297 vtkGetMacro(IgnoreMissingArrays, bool);
298 vtkBooleanMacro(IgnoreMissingArrays, bool);
300
305 {
306 FunctionParser, // vtkFunctionParser
307 ExprTkFunctionParser, // vtkExprTkFunctionParser
308 NumberOfFunctionParserTypes
309 };
310
312
318 {
319 this->FunctionParserType = FunctionParserTypes::FunctionParser;
320 this->Modified();
321 }
323 {
324 this->FunctionParserType = FunctionParserTypes::ExprTkFunctionParser;
325 this->Modified();
326 }
329
335
336protected:
339
341
343
348
356 static std::string CheckValidVariableName(const char* variableName);
357
359
360 char* Function;
362 std::vector<std::string> ScalarArrayNames;
363 std::vector<std::string> VectorArrayNames;
364 std::vector<std::string> ScalarVariableNames;
365 std::vector<std::string> VectorVariableNames;
367 std::vector<int> SelectedScalarComponents;
368 std::vector<vtkTuple<int, 3>> SelectedVectorComponents;
369
373
377 std::vector<std::string> CoordinateScalarVariableNames;
378 std::vector<std::string> CoordinateVectorVariableNames;
380 std::vector<vtkTuple<int, 3>> SelectedCoordinateVectorComponents;
381
383
384private:
385 vtkArrayCalculator(const vtkArrayCalculator&) = delete;
386 void operator=(const vtkArrayCalculator&) = delete;
387
388 // Do the bulk of the work
389 template <typename TFunctionParser>
390 int ProcessDataObject(vtkDataObject* input, vtkDataObject* output);
391};
392
393#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:72
a simple class to control print indentation
Definition vtkIndent.h:49
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
virtual void Modified()
Update the modification time for this object.
Superclass for algorithms that produce output of the same type as input.
templated base type for containers of constant size.
Definition vtkTuple.h:38
int vtkTypeBool
Definition vtkABI.h:69