VTK  9.0.2
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 =========================================================================*/
61 #ifndef vtkArrayCalculator_h
62 #define vtkArrayCalculator_h
63 
64 #include "vtkDataObject.h" // For attribute types
65 #include "vtkFiltersCoreModule.h" // For export macro
67 
68 class vtkDataSet;
69 class vtkFunctionParser;
70 
71 #ifndef VTK_LEGACY_REMOVE
72 #define VTK_ATTRIBUTE_MODE_DEFAULT 0
73 #define VTK_ATTRIBUTE_MODE_USE_POINT_DATA 1
74 #define VTK_ATTRIBUTE_MODE_USE_CELL_DATA 2
75 #define VTK_ATTRIBUTE_MODE_USE_VERTEX_DATA 3
76 #define VTK_ATTRIBUTE_MODE_USE_EDGE_DATA 4
77 #endif
78 
79 class VTKFILTERSCORE_EXPORT vtkArrayCalculator : public vtkPassInputTypeAlgorithm
80 {
81 public:
83  void PrintSelf(ostream& os, vtkIndent indent) override;
84 
86 
88 
91  virtual void SetFunction(const char* function);
92  vtkGetStringMacro(Function);
94 
96 
102  void AddScalarArrayName(const char* arrayName, int component = 0);
104  const char* arrayName, int component0 = 0, int component1 = 1, int component2 = 2);
106 
108 
112  void AddScalarVariable(const char* variableName, const char* arrayName, int component = 0);
113  void AddVectorVariable(const char* variableName, const char* arrayName, int component0 = 0,
114  int component1 = 1, int component2 = 2);
116 
118 
122  void AddCoordinateScalarVariable(const char* variableName, int component = 0);
124  const char* variableName, int component0 = 0, int component1 = 1, int component2 = 2);
126 
128 
134  void SetResultArrayName(const char* name);
135  vtkGetStringMacro(ResultArrayName);
137 
139 
143  vtkGetMacro(ResultArrayType, int);
144  vtkSetMacro(ResultArrayType, int);
146 
148 
154  vtkGetMacro(CoordinateResults, vtkTypeBool);
155  vtkSetMacro(CoordinateResults, vtkTypeBool);
156  vtkBooleanMacro(CoordinateResults, vtkTypeBool);
158 
160 
165  vtkGetMacro(ResultNormals, bool);
166  vtkSetMacro(ResultNormals, bool);
167  vtkBooleanMacro(ResultNormals, bool);
169 
171 
176  vtkGetMacro(ResultTCoords, bool);
177  vtkSetMacro(ResultTCoords, bool);
178  vtkBooleanMacro(ResultTCoords, bool);
180 
182 
192 #ifndef VTK_LEGACY_REMOVE
193  VTK_LEGACY(void SetAttributeMode(int newMode);)
194  VTK_LEGACY(int GetAttributeMode();)
195  VTK_LEGACY(void SetAttributeModeToDefault()) { this->SetAttributeType(DEFAULT_ATTRIBUTE_TYPE); }
197  {
198  this->SetAttributeType(vtkDataObject::POINT);
199  }
200  VTK_LEGACY(void SetAttributeModeToUseCellData()) { this->SetAttributeType(vtkDataObject::CELL); }
202  {
203  this->SetAttributeType(vtkDataObject::VERTEX);
204  }
205  VTK_LEGACY(void SetAttributeModeToUseEdgeData()) { this->SetAttributeType(vtkDataObject::EDGE); }
206  VTK_LEGACY(const char* GetAttributeModeAsString());
207 #endif
209 
214 
215  static const int DEFAULT_ATTRIBUTE_TYPE = -1;
217 
223  vtkSetMacro(AttributeType, int);
224  vtkGetMacro(AttributeType, int);
225  void SetAttributeTypeToDefault() { this->SetAttributeType(DEFAULT_ATTRIBUTE_TYPE); }
226  void SetAttributeTypeToPointData() { this->SetAttributeType(vtkDataObject::POINT); }
227  void SetAttributeTypeToCellData() { this->SetAttributeType(vtkDataObject::CELL); }
228  void SetAttributeTypeToEdgeData() { this->SetAttributeType(vtkDataObject::EDGE); }
229  void SetAttributeTypeToVertexData() { this->SetAttributeType(vtkDataObject::VERTEX); }
230  void SetAttributeTypeToRowData() { this->SetAttributeType(vtkDataObject::ROW); }
232 
237 
241  virtual void RemoveScalarVariables();
242 
246  virtual void RemoveVectorVariables();
247 
252 
257 
259 
262  char** GetScalarArrayNames() { return this->ScalarArrayNames; }
263  char* GetScalarArrayName(int i);
264  char** GetVectorArrayNames() { return this->VectorArrayNames; }
265  char* GetVectorArrayName(int i);
266  char** GetScalarVariableNames() { return this->ScalarVariableNames; }
267  char* GetScalarVariableName(int i);
268  char** GetVectorVariableNames() { return this->VectorVariableNames; }
269  char* GetVectorVariableName(int i);
270  int* GetSelectedScalarComponents() { return this->SelectedScalarComponents; }
272  int** GetSelectedVectorComponents() { return this->SelectedVectorComponents; }
274  vtkGetMacro(NumberOfScalarArrays, int);
275  vtkGetMacro(NumberOfVectorArrays, int);
277 
279 
285  vtkSetMacro(ReplaceInvalidValues, vtkTypeBool);
286  vtkGetMacro(ReplaceInvalidValues, vtkTypeBool);
287  vtkBooleanMacro(ReplaceInvalidValues, vtkTypeBool);
288  vtkSetMacro(ReplacementValue, double);
289  vtkGetMacro(ReplacementValue, double);
291 
293 
299  vtkSetMacro(IgnoreMissingArrays, bool);
300  vtkGetMacro(IgnoreMissingArrays, bool);
301  vtkBooleanMacro(IgnoreMissingArrays, bool);
302 
308 
309 protected:
312 
314 
315  // Do the bulk of the work
317 
319 
324 
325  char* Function;
337 
341 
351 
353 
354 private:
355  vtkArrayCalculator(const vtkArrayCalculator&) = delete;
356  void operator=(const vtkArrayCalculator&) = delete;
357 };
358 
359 #endif
perform mathematical operations on data in field data arrays
void SetResultArrayName(const char *name)
Set the name of the array in which to store the result of evaluating this function.
char * GetVectorVariableName(int i)
int ProcessDataObject(vtkDataObject *input, vtkDataObject *output)
char ** GetScalarArrayNames()
Methods to get information about the current variables.
void RemoveAllVariables()
Remove all the variable names and their associated array names.
virtual void RemoveCoordinateVectorVariables()
Remove all the coordinate variables.
int ** GetSelectedVectorComponents()
char * GetScalarArrayName(int i)
void SetAttributeMode(int newMode)
Control whether the filter operates on point data or cell data.
vtkTypeBool ReplaceInvalidValues
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.
vtkTypeBool CoordinateResults
char ** CoordinateVectorVariableNames
vtkDataSet * GetDataSetOutput()
Returns the output of the filter downcast to a vtkDataSet or nullptr if the cast fails.
virtual void SetFunction(const char *function)
Set/Get the function to be evaluated.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int * SelectedCoordinateScalarComponents
int ** SelectedCoordinateVectorComponents
void AddVectorArrayName(const char *arrayName, int component0=0, int component1=1, int component2=2)
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 * GetSelectedVectorComponents(int i)
virtual void RemoveVectorVariables()
Remove all the scalar variable names and their associated array names.
char ** CoordinateScalarVariableNames
char * GetVectorArrayName(int i)
void SetAttributeModeToUseVertexData()
void AddVectorVariable(const char *variableName, const char *arrayName, int component0=0, int component1=1, int component2=2)
char * GetScalarVariableName(int i)
const char * GetAttributeTypeAsString()
Returns a string representation of the calculator's AttributeType.
char ** GetScalarVariableNames()
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)
vtkFunctionParser * FunctionParser
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called within ProcessRequest when a request asks the algorithm to do its work.
int GetSelectedScalarComponent(int i)
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.
~vtkArrayCalculator() override
virtual void RemoveCoordinateScalarVariables()
Remove all the coordinate variables.
const char * GetAttributeModeAsString()
static vtkArrayCalculator * New()
char ** GetVectorVariableNames()
general representation of visualization data
Definition: vtkDataObject.h:60
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
Parse and evaluate a mathematical expression.
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Superclass for algorithms that produce output of the same type as input.
@ component
Definition: vtkX3D.h:181
@ name
Definition: vtkX3D.h:225
int vtkTypeBool
Definition: vtkABI.h:69