VTK: Filters/Core/vtkArrayCalculator.h Source File

| VTK 9.3.1

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
72 #ifndef vtkArrayCalculator_h
73 #define vtkArrayCalculator_h
74
75 #include "vtkDataObject.h" // For attribute types
76 #include "vtkFiltersCoreModule.h" // For export macro
77 #include "vtkPassInputTypeAlgorithm.h"
78 #include "vtkTuple.h" // needed for vtkTuple
79 #include <vector> // needed for vector
80
81 VTK_ABI_NAMESPACE_BEGIN
82 class vtkDataSet;
83
84 class VTKFILTERSCORE_EXPORT vtkArrayCalculator : public vtkPassInputTypeAlgorithm
85 {
86 public:
87 vtkTypeMacro(vtkArrayCalculator, vtkPassInputTypeAlgorithm);
88 void PrintSelf(ostream& os, vtkIndent indent) override;
89
90 static vtkArrayCalculator* New();
91
93
96 vtkSetStringMacro(Function);
97 vtkGetStringMacro(Function);
99
101
111 void AddScalarArrayName(const char* arrayName, int component = 0);
112 void AddVectorArrayName(
113 const char* arrayName, int component0 = 0, int component1 = 1, int component2 = 2);
115
117
123 void AddScalarVariable(const char* variableName, const char* arrayName, int component = 0);
124 void AddVectorVariable(const char* variableName, const char* arrayName, int component0 = 0,
125 int component1 = 1, int component2 = 2);
127
129
135 void AddCoordinateScalarVariable(const char* variableName, int component = 0);
136 void AddCoordinateVectorVariable(
137 const char* variableName, int component0 = 0, int component1 = 1, int component2 = 2);
139
141
147 vtkSetStringMacro(ResultArrayName);
148 vtkGetStringMacro(ResultArrayName);
150
152
156 vtkGetMacro(ResultArrayType, int);
157 vtkSetMacro(ResultArrayType, int);
159
161
167 vtkGetMacro(CoordinateResults, vtkTypeBool);
168 vtkSetMacro(CoordinateResults, vtkTypeBool);
169 vtkBooleanMacro(CoordinateResults, vtkTypeBool);
171
173
178 vtkGetMacro(ResultNormals, bool);
179 vtkSetMacro(ResultNormals, bool);
180 vtkBooleanMacro(ResultNormals, bool);
182
184
189 vtkGetMacro(ResultTCoords, bool);
190 vtkSetMacro(ResultTCoords, bool);
191 vtkBooleanMacro(ResultTCoords, bool);
193
197 const char* GetAttributeTypeAsString();
198
199 static const int DEFAULT_ATTRIBUTE_TYPE = -1;
201
207 vtkSetMacro(AttributeType, int);
208 vtkGetMacro(AttributeType, int);
209 void SetAttributeTypeToDefault() { this->SetAttributeType(DEFAULT_ATTRIBUTE_TYPE); }
210 void SetAttributeTypeToPointData() { this->SetAttributeType(vtkDataObject::POINT); }
211 void SetAttributeTypeToCellData() { this->SetAttributeType(vtkDataObject::CELL); }
212 void SetAttributeTypeToEdgeData() { this->SetAttributeType(vtkDataObject::EDGE); }
213 void SetAttributeTypeToVertexData() { this->SetAttributeType(vtkDataObject::VERTEX); }
214 void SetAttributeTypeToRowData() { this->SetAttributeType(vtkDataObject::ROW); }
216
220 void RemoveAllVariables();
221
225 virtual void RemoveScalarVariables();
226
230 virtual void RemoveVectorVariables();
231
235 virtual void RemoveCoordinateScalarVariables();
236
240 virtual void RemoveCoordinateVectorVariables();
241
243
246 const std::vector<std::string>& GetScalarArrayNames() { return this->ScalarArrayNames; }
247 std::string GetScalarArrayName(int i);
248 const std::vector<std::string>& GetVectorArrayNames() { return this->VectorArrayNames; }
249 std::string GetVectorArrayName(int i);
250 const std::vector<std::string>& GetScalarVariableNames() { return this->ScalarVariableNames; }
251 std::string GetScalarVariableName(int i);
252 const std::vector<std::string>& GetVectorVariableNames() { return this->VectorVariableNames; }
253 std::string GetVectorVariableName(int i);
254 const std::vector<int>& GetSelectedScalarComponents() { return this->SelectedScalarComponents; }
255 int GetSelectedScalarComponent(int i);
256 const std::vector<vtkTuple<int, 3>>& GetSelectedVectorComponents()
257 {
258 return this->SelectedVectorComponents;
259 }
260 vtkTuple<int, 3> GetSelectedVectorComponents(int i);
261 int GetNumberOfScalarArrays() { return static_cast<int>(this->ScalarArrayNames.size()); }
262 int GetNumberOfVectorArrays() { return static_cast<int>(this->VectorArrayNames.size()); }
264
266
272 vtkSetMacro(ReplaceInvalidValues, vtkTypeBool);
273 vtkGetMacro(ReplaceInvalidValues, vtkTypeBool);
274 vtkBooleanMacro(ReplaceInvalidValues, vtkTypeBool);
275 vtkSetMacro(ReplacementValue, double);
276 vtkGetMacro(ReplacementValue, double);
278
280
285 vtkSetMacro(IgnoreMissingArrays, bool);
286 vtkGetMacro(IgnoreMissingArrays, bool);
287 vtkBooleanMacro(IgnoreMissingArrays, bool);
289
293 enum FunctionParserTypes
294 {
295 FunctionParser, // vtkFunctionParser
296 ExprTkFunctionParser, // vtkExprTkFunctionParser
297 NumberOfFunctionParserTypes
298 };
299
301
305 vtkSetEnumMacro(FunctionParserType, FunctionParserTypes);
306 void SetFunctionParserTypeToFunctionParser()
307 {
308 this->FunctionParserType = FunctionParserTypes::FunctionParser;
309 this->Modified();
310 }
311 void SetFunctionParserTypeToExprTkFunctionParser()
312 {
313 this->FunctionParserType = FunctionParserTypes::ExprTkFunctionParser;
314 this->Modified();
315 }
316 vtkGetEnumMacro(FunctionParserType, FunctionParserTypes);
318
323 vtkDataSet* GetDataSetOutput();
324
325 protected:
326 vtkArrayCalculator();
327 ~vtkArrayCalculator() override;
328
329 int FillInputPortInformation(int, vtkInformation*) override;
330
331 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
332
336 int GetAttributeTypeFromInput(vtkDataObject* input);
337
345 static std::string CheckValidVariableName(const char* variableName);
346
347 FunctionParserTypes FunctionParserType;
348
349 char* Function;
350 char* ResultArrayName;
351 std::vector<std::string> ScalarArrayNames;
352 std::vector<std::string> VectorArrayNames;
353 std::vector<std::string> ScalarVariableNames;
354 std::vector<std::string> VectorVariableNames;
355 int AttributeType;
356 std::vector<int> SelectedScalarComponents;
357 std::vector<vtkTuple<int, 3>> SelectedVectorComponents;
358
359 vtkTypeBool ReplaceInvalidValues;
360 double ReplacementValue;
361 bool IgnoreMissingArrays;
362
363 vtkTypeBool CoordinateResults;
364 bool ResultNormals;
365 bool ResultTCoords;
366 std::vector<std::string> CoordinateScalarVariableNames;
367 std::vector<std::string> CoordinateVectorVariableNames;
368 std::vector<int> SelectedCoordinateScalarComponents;
369 std::vector<vtkTuple<int, 3>> SelectedCoordinateVectorComponents;
370
371 int ResultArrayType;
372
373 private:
374 vtkArrayCalculator(const vtkArrayCalculator&) = delete;
375 void operator=(const vtkArrayCalculator&) = delete;
376
377 // Do the bulk of the work
378 template <typename TFunctionParser>
379 int ProcessDataObject(vtkDataObject* input, vtkDataObject* output);
380 };
381
382 VTK_ABI_NAMESPACE_END
383 #endif
vtkArrayCalculator
perform mathematical operations on data in field data arrays
Definition: vtkArrayCalculator.h:85
vtkArrayCalculator::ResultArrayType
int ResultArrayType
Definition: vtkArrayCalculator.h:371
vtkArrayCalculator::FunctionParserTypes
FunctionParserTypes
Enum that includes the types of parsers that can be used.
Definition: vtkArrayCalculator.h:294
vtkArrayCalculator::ExprTkFunctionParser
@ ExprTkFunctionParser
Definition: vtkArrayCalculator.h:296
vtkArrayCalculator::FunctionParser
@ FunctionParser
Definition: vtkArrayCalculator.h:295
vtkArrayCalculator::SetFunctionParserTypeToFunctionParser
void SetFunctionParserTypeToFunctionParser()
Set/Get the FunctionParser type that will be used.
Definition: vtkArrayCalculator.h:306
vtkArrayCalculator::RemoveAllVariables
void RemoveAllVariables()
Remove all the variable names and their associated array names.
vtkArrayCalculator::SetAttributeTypeToVertexData
void SetAttributeTypeToVertexData()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
Definition: vtkArrayCalculator.h:213
vtkArrayCalculator::RemoveCoordinateVectorVariables
virtual void RemoveCoordinateVectorVariables()
Remove all the coordinate variables.
vtkArrayCalculator::GetVectorVariableName
std::string GetVectorVariableName(int i)
Methods to get information about the current variables.
vtkArrayCalculator::SetAttributeTypeToRowData
void SetAttributeTypeToRowData()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
Definition: vtkArrayCalculator.h:214
vtkArrayCalculator::GetSelectedVectorComponents
vtkTuple< int, 3 > GetSelectedVectorComponents(int i)
Methods to get information about the current variables.
vtkArrayCalculator::SetAttributeTypeToDefault
void SetAttributeTypeToDefault()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
Definition: vtkArrayCalculator.h:209
vtkArrayCalculator::vtkSetEnumMacro
vtkSetEnumMacro(FunctionParserType, FunctionParserTypes)
Set/Get the FunctionParser type that will be used.
vtkArrayCalculator::GetNumberOfVectorArrays
int GetNumberOfVectorArrays()
Methods to get information about the current variables.
Definition: vtkArrayCalculator.h:262
vtkArrayCalculator::ReplaceInvalidValues
vtkTypeBool ReplaceInvalidValues
Definition: vtkArrayCalculator.h:359
vtkArrayCalculator::VectorVariableNames
std::vector< std::string > VectorVariableNames
Definition: vtkArrayCalculator.h:354
vtkArrayCalculator::AddScalarVariable
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.
vtkArrayCalculator::GetScalarVariableNames
const std::vector< std::string > & GetScalarVariableNames()
Methods to get information about the current variables.
Definition: vtkArrayCalculator.h:250
vtkArrayCalculator::ResultArrayName
char * ResultArrayName
Definition: vtkArrayCalculator.h:350
vtkArrayCalculator::IgnoreMissingArrays
bool IgnoreMissingArrays
Definition: vtkArrayCalculator.h:361
vtkArrayCalculator::CoordinateResults
vtkTypeBool CoordinateResults
Definition: vtkArrayCalculator.h:363
vtkArrayCalculator::SelectedVectorComponents
std::vector< vtkTuple< int, 3 > > SelectedVectorComponents
Definition: vtkArrayCalculator.h:357
vtkArrayCalculator::SetAttributeTypeToEdgeData
void SetAttributeTypeToEdgeData()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
Definition: vtkArrayCalculator.h:212
vtkArrayCalculator::GetDataSetOutput
vtkDataSet * GetDataSetOutput()
Returns the output of the filter downcast to a vtkDataSet or nullptr if the cast fails.
vtkArrayCalculator::vtkGetEnumMacro
vtkGetEnumMacro(FunctionParserType, FunctionParserTypes)
Set/Get the FunctionParser type that will be used.
vtkArrayCalculator::GetScalarArrayName
std::string GetScalarArrayName(int i)
Methods to get information about the current variables.
vtkArrayCalculator::GetScalarVariableName
std::string GetScalarVariableName(int i)
Methods to get information about the current variables.
vtkArrayCalculator::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkArrayCalculator::GetNumberOfScalarArrays
int GetNumberOfScalarArrays()
Methods to get information about the current variables.
Definition: vtkArrayCalculator.h:261
vtkArrayCalculator::SelectedCoordinateVectorComponents
std::vector< vtkTuple< int, 3 > > SelectedCoordinateVectorComponents
Definition: vtkArrayCalculator.h:369
vtkArrayCalculator::ReplacementValue
double ReplacementValue
Definition: vtkArrayCalculator.h:360
vtkArrayCalculator::GetSelectedScalarComponents
const std::vector< int > & GetSelectedScalarComponents()
Methods to get information about the current variables.
Definition: vtkArrayCalculator.h:254
vtkArrayCalculator::AddVectorArrayName
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...
vtkArrayCalculator::AddCoordinateScalarVariable
void AddCoordinateScalarVariable(const char *variableName, int component=0)
Add a variable name, a corresponding array name, and which components of the array to use.
vtkArrayCalculator::RemoveVectorVariables
virtual void RemoveVectorVariables()
Remove all the scalar variable names and their associated array names.
vtkArrayCalculator::Function
char * Function
Definition: vtkArrayCalculator.h:349
vtkArrayCalculator::CheckValidVariableName
static std::string CheckValidVariableName(const char *variableName)
A variable name is valid if it's sanitized or enclosed in quotes.
vtkArrayCalculator::SetAttributeTypeToCellData
void SetAttributeTypeToCellData()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
Definition: vtkArrayCalculator.h:211
vtkArrayCalculator::SelectedScalarComponents
std::vector< int > SelectedScalarComponents
Definition: vtkArrayCalculator.h:356
vtkArrayCalculator::AddVectorVariable
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.
vtkArrayCalculator::FunctionParserType
FunctionParserTypes FunctionParserType
Definition: vtkArrayCalculator.h:347
vtkArrayCalculator::GetAttributeTypeAsString
const char * GetAttributeTypeAsString()
Returns a string representation of the calculator's AttributeType.
vtkArrayCalculator::CoordinateVectorVariableNames
std::vector< std::string > CoordinateVectorVariableNames
Definition: vtkArrayCalculator.h:367
vtkArrayCalculator::GetAttributeTypeFromInput
int GetAttributeTypeFromInput(vtkDataObject *input)
Get the attribute type for the input.
vtkArrayCalculator::GetSelectedVectorComponents
const std::vector< vtkTuple< int, 3 > > & GetSelectedVectorComponents()
Methods to get information about the current variables.
Definition: vtkArrayCalculator.h:256
vtkArrayCalculator::AddCoordinateVectorVariable
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.
vtkArrayCalculator::ScalarVariableNames
std::vector< std::string > ScalarVariableNames
Definition: vtkArrayCalculator.h:353
vtkArrayCalculator::SelectedCoordinateScalarComponents
std::vector< int > SelectedCoordinateScalarComponents
Definition: vtkArrayCalculator.h:368
vtkArrayCalculator::SetFunctionParserTypeToExprTkFunctionParser
void SetFunctionParserTypeToExprTkFunctionParser()
Set/Get the FunctionParser type that will be used.
Definition: vtkArrayCalculator.h:311
vtkArrayCalculator::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called within ProcessRequest when a request asks the algorithm to do its work.
vtkArrayCalculator::ScalarArrayNames
std::vector< std::string > ScalarArrayNames
Definition: vtkArrayCalculator.h:351
vtkArrayCalculator::GetSelectedScalarComponent
int GetSelectedScalarComponent(int i)
Methods to get information about the current variables.
vtkArrayCalculator::GetVectorArrayNames
const std::vector< std::string > & GetVectorArrayNames()
Methods to get information about the current variables.
Definition: vtkArrayCalculator.h:248
vtkArrayCalculator::RemoveScalarVariables
virtual void RemoveScalarVariables()
Remove all the scalar variable names and their associated array names.
vtkArrayCalculator::AttributeType
int AttributeType
Definition: vtkArrayCalculator.h:355
vtkArrayCalculator::AddScalarArrayName
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...
vtkArrayCalculator::GetScalarArrayNames
const std::vector< std::string > & GetScalarArrayNames()
Methods to get information about the current variables.
Definition: vtkArrayCalculator.h:246
vtkArrayCalculator::FillInputPortInformation
int FillInputPortInformation(int, vtkInformation *) override
Fill the input port information objects for this algorithm.
vtkArrayCalculator::SetAttributeTypeToPointData
void SetAttributeTypeToPointData()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
Definition: vtkArrayCalculator.h:210
vtkArrayCalculator::~vtkArrayCalculator
~vtkArrayCalculator() override
vtkArrayCalculator::ResultNormals
bool ResultNormals
Definition: vtkArrayCalculator.h:364
vtkArrayCalculator::ResultTCoords
bool ResultTCoords
Definition: vtkArrayCalculator.h:365
vtkArrayCalculator::RemoveCoordinateScalarVariables
virtual void RemoveCoordinateScalarVariables()
Remove all the coordinate variables.
vtkArrayCalculator::vtkArrayCalculator
vtkArrayCalculator()
vtkArrayCalculator::GetVectorVariableNames
const std::vector< std::string > & GetVectorVariableNames()
Methods to get information about the current variables.
Definition: vtkArrayCalculator.h:252
vtkArrayCalculator::VectorArrayNames
std::vector< std::string > VectorArrayNames
Definition: vtkArrayCalculator.h:352
vtkArrayCalculator::GetVectorArrayName
std::string GetVectorArrayName(int i)
Methods to get information about the current variables.
vtkArrayCalculator::CoordinateScalarVariableNames
std::vector< std::string > CoordinateScalarVariableNames
Definition: vtkArrayCalculator.h:366
vtkArrayCalculator::New
static vtkArrayCalculator * New()
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:64
vtkDataObject::VERTEX
@ VERTEX
Definition: vtkDataObject.h:282
vtkDataObject::EDGE
@ EDGE
Definition: vtkDataObject.h:283
vtkDataObject::ROW
@ ROW
Definition: vtkDataObject.h:284
vtkDataObject::CELL
@ CELL
Definition: vtkDataObject.h:279
vtkDataObject::POINT
@ POINT
Definition: vtkDataObject.h:278
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:40
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:72
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkPassInputTypeAlgorithm
Superclass for algorithms that produce output of the same type as input.
Definition: vtkPassInputTypeAlgorithm.h:45
vtkTuple< int, 3 >
vtkX3D::component
@ component
Definition: vtkX3D.h:175
vtkX3D::string
@ string
Definition: vtkX3D.h:490
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:64
vtkDataObject.h
vtkPassInputTypeAlgorithm.h
vtkTuple.h