VTK  9.1.0
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=========================================================================*/
72#ifndef vtkArrayCalculator_h
73#define vtkArrayCalculator_h
74
75#include "vtkDataObject.h" // For attribute types
76#include "vtkFiltersCoreModule.h" // For export macro
78#include "vtkTuple.h" // needed for vtkTuple
79#include <vector> // needed for vector
80
81class vtkDataSet;
82
83class VTKFILTERSCORE_EXPORT vtkArrayCalculator : public vtkPassInputTypeAlgorithm
84{
85public:
87 void PrintSelf(ostream& os, vtkIndent indent) override;
88
90
92
95 vtkSetStringMacro(Function);
96 vtkGetStringMacro(Function);
98
100
110 void AddScalarArrayName(const char* arrayName, int component = 0);
112 const char* arrayName, int component0 = 0, int component1 = 1, int component2 = 2);
114
116
122 void AddScalarVariable(const char* variableName, const char* arrayName, int component = 0);
123 void AddVectorVariable(const char* variableName, const char* arrayName, int component0 = 0,
124 int component1 = 1, int component2 = 2);
126
128
134 void AddCoordinateScalarVariable(const char* variableName, int component = 0);
136 const char* variableName, int component0 = 0, int component1 = 1, int component2 = 2);
138
140
146 vtkSetStringMacro(ResultArrayName);
147 vtkGetStringMacro(ResultArrayName);
149
151
155 vtkGetMacro(ResultArrayType, int);
156 vtkSetMacro(ResultArrayType, int);
158
160
166 vtkGetMacro(CoordinateResults, vtkTypeBool);
167 vtkSetMacro(CoordinateResults, vtkTypeBool);
168 vtkBooleanMacro(CoordinateResults, vtkTypeBool);
170
172
177 vtkGetMacro(ResultNormals, bool);
178 vtkSetMacro(ResultNormals, bool);
179 vtkBooleanMacro(ResultNormals, bool);
181
183
188 vtkGetMacro(ResultTCoords, bool);
189 vtkSetMacro(ResultTCoords, bool);
190 vtkBooleanMacro(ResultTCoords, bool);
192
197
198 static const int DEFAULT_ATTRIBUTE_TYPE = -1;
200
206 vtkSetMacro(AttributeType, int);
207 vtkGetMacro(AttributeType, int);
208 void SetAttributeTypeToDefault() { this->SetAttributeType(DEFAULT_ATTRIBUTE_TYPE); }
209 void SetAttributeTypeToPointData() { this->SetAttributeType(vtkDataObject::POINT); }
210 void SetAttributeTypeToCellData() { this->SetAttributeType(vtkDataObject::CELL); }
211 void SetAttributeTypeToEdgeData() { this->SetAttributeType(vtkDataObject::EDGE); }
212 void SetAttributeTypeToVertexData() { this->SetAttributeType(vtkDataObject::VERTEX); }
213 void SetAttributeTypeToRowData() { this->SetAttributeType(vtkDataObject::ROW); }
215
220
224 virtual void RemoveScalarVariables();
225
229 virtual void RemoveVectorVariables();
230
235
240
242
245 const std::vector<std::string>& GetScalarArrayNames() { return this->ScalarArrayNames; }
247 const std::vector<std::string>& GetVectorArrayNames() { return this->VectorArrayNames; }
249 const std::vector<std::string>& GetScalarVariableNames() { return this->ScalarVariableNames; }
251 const std::vector<std::string>& GetVectorVariableNames() { return this->VectorVariableNames; }
253 const std::vector<int>& GetSelectedScalarComponents() { return this->SelectedScalarComponents; }
255 const std::vector<vtkTuple<int, 3>>& GetSelectedVectorComponents()
256 {
257 return this->SelectedVectorComponents;
258 }
260 int GetNumberOfScalarArrays() { return static_cast<int>(this->ScalarArrayNames.size()); }
261 int GetNumberOfVectorArrays() { return static_cast<int>(this->VectorArrayNames.size()); }
263
265
271 vtkSetMacro(ReplaceInvalidValues, vtkTypeBool);
272 vtkGetMacro(ReplaceInvalidValues, vtkTypeBool);
273 vtkBooleanMacro(ReplaceInvalidValues, vtkTypeBool);
274 vtkSetMacro(ReplacementValue, double);
275 vtkGetMacro(ReplacementValue, double);
277
279
284 vtkSetMacro(IgnoreMissingArrays, bool);
285 vtkGetMacro(IgnoreMissingArrays, bool);
286 vtkBooleanMacro(IgnoreMissingArrays, bool);
288
293 {
294 FunctionParser, // vtkFunctionParser
295 ExprTkFunctionParser, // vtkExprTkFunctionParser
296 NumberOfFunctionParserTypes
297 };
298
300
306 {
307 this->FunctionParserType = FunctionParserTypes::FunctionParser;
308 this->Modified();
309 }
311 {
312 this->FunctionParserType = FunctionParserTypes::ExprTkFunctionParser;
313 this->Modified();
314 }
317
323
324protected:
327
329
331
336
344 static std::string CheckValidVariableName(const char* variableName);
345
347
348 char* Function;
350 std::vector<std::string> ScalarArrayNames;
351 std::vector<std::string> VectorArrayNames;
352 std::vector<std::string> ScalarVariableNames;
353 std::vector<std::string> VectorVariableNames;
355 std::vector<int> SelectedScalarComponents;
356 std::vector<vtkTuple<int, 3>> SelectedVectorComponents;
357
361
365 std::vector<std::string> CoordinateScalarVariableNames;
366 std::vector<std::string> CoordinateVectorVariableNames;
368 std::vector<vtkTuple<int, 3>> SelectedCoordinateVectorComponents;
369
371
372private:
373 vtkArrayCalculator(const vtkArrayCalculator&) = delete;
374 void operator=(const vtkArrayCalculator&) = delete;
375
376 // Do the bulk of the work
377 template <typename TFunctionParser>
378 int ProcessDataObject(vtkDataObject* input, vtkDataObject* output);
379};
380
381#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.
vtkTypeBool CoordinateResults
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
Definition: vtkDataObject.h:60
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
a simple class to control print indentation
Definition: vtkIndent.h:34
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.
@ component
Definition: vtkX3D.h:181
@ string
Definition: vtkX3D.h:496
int vtkTypeBool
Definition: vtkABI.h:69