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
63 #ifndef vtkArrayCalculator_h
64 #define vtkArrayCalculator_h
65 
66 #include "vtkDataObject.h" // For attribute types
67 #include "vtkFiltersCoreModule.h" // For export macro
69 #include "vtkTuple.h" // needed for vtkTuple
70 #include <vector> // needed for vector
71 
72 VTK_ABI_NAMESPACE_BEGIN
73 class vtkDataSet;
74 
75 class VTKFILTERSCORE_EXPORT vtkArrayCalculator : public vtkPassInputTypeAlgorithm
76 {
77 public:
79  void PrintSelf(ostream& os, vtkIndent indent) override;
80 
81  static vtkArrayCalculator* New();
82 
84 
87  vtkSetStringMacro(Function);
88  vtkGetStringMacro(Function);
90 
92 
102  void AddScalarArrayName(const char* arrayName, int component = 0);
103  void AddVectorArrayName(
104  const char* arrayName, int component0 = 0, int component1 = 1, int component2 = 2);
106 
108 
114  void AddScalarVariable(const char* variableName, const char* arrayName, int component = 0);
115  void AddVectorVariable(const char* variableName, const char* arrayName, int component0 = 0,
116  int component1 = 1, int component2 = 2);
118 
120 
126  void AddCoordinateScalarVariable(const char* variableName, int component = 0);
127  void AddCoordinateVectorVariable(
128  const char* variableName, int component0 = 0, int component1 = 1, int component2 = 2);
130 
132 
138  vtkSetStringMacro(ResultArrayName);
139  vtkGetStringMacro(ResultArrayName);
141 
143 
147  vtkGetMacro(ResultArrayType, int);
148  vtkSetMacro(ResultArrayType, int);
150 
152 
158  vtkGetMacro(CoordinateResults, vtkTypeBool);
159  vtkSetMacro(CoordinateResults, vtkTypeBool);
160  vtkBooleanMacro(CoordinateResults, vtkTypeBool);
162 
164 
169  vtkGetMacro(ResultNormals, bool);
170  vtkSetMacro(ResultNormals, bool);
171  vtkBooleanMacro(ResultNormals, bool);
173 
175 
180  vtkGetMacro(ResultTCoords, bool);
181  vtkSetMacro(ResultTCoords, bool);
182  vtkBooleanMacro(ResultTCoords, bool);
184 
188  const char* GetAttributeTypeAsString();
189 
190  static const int DEFAULT_ATTRIBUTE_TYPE = -1;
192 
198  vtkSetMacro(AttributeType, int);
199  vtkGetMacro(AttributeType, int);
200  void SetAttributeTypeToDefault() { this->SetAttributeType(DEFAULT_ATTRIBUTE_TYPE); }
201  void SetAttributeTypeToPointData() { this->SetAttributeType(vtkDataObject::POINT); }
202  void SetAttributeTypeToCellData() { this->SetAttributeType(vtkDataObject::CELL); }
203  void SetAttributeTypeToEdgeData() { this->SetAttributeType(vtkDataObject::EDGE); }
204  void SetAttributeTypeToVertexData() { this->SetAttributeType(vtkDataObject::VERTEX); }
205  void SetAttributeTypeToRowData() { this->SetAttributeType(vtkDataObject::ROW); }
207 
211  void RemoveAllVariables();
212 
216  virtual void RemoveScalarVariables();
217 
221  virtual void RemoveVectorVariables();
222 
226  virtual void RemoveCoordinateScalarVariables();
227 
231  virtual void RemoveCoordinateVectorVariables();
232 
234 
237  const std::vector<std::string>& GetScalarArrayNames() { return this->ScalarArrayNames; }
238  std::string GetScalarArrayName(int i);
239  const std::vector<std::string>& GetVectorArrayNames() { return this->VectorArrayNames; }
240  std::string GetVectorArrayName(int i);
241  const std::vector<std::string>& GetScalarVariableNames() { return this->ScalarVariableNames; }
242  std::string GetScalarVariableName(int i);
243  const std::vector<std::string>& GetVectorVariableNames() { return this->VectorVariableNames; }
244  std::string GetVectorVariableName(int i);
245  const std::vector<int>& GetSelectedScalarComponents() { return this->SelectedScalarComponents; }
246  int GetSelectedScalarComponent(int i);
247  const std::vector<vtkTuple<int, 3>>& GetSelectedVectorComponents()
248  {
249  return this->SelectedVectorComponents;
250  }
251  vtkTuple<int, 3> GetSelectedVectorComponents(int i);
252  int GetNumberOfScalarArrays() { return static_cast<int>(this->ScalarArrayNames.size()); }
253  int GetNumberOfVectorArrays() { return static_cast<int>(this->VectorArrayNames.size()); }
255 
257 
263  vtkSetMacro(ReplaceInvalidValues, vtkTypeBool);
264  vtkGetMacro(ReplaceInvalidValues, vtkTypeBool);
265  vtkBooleanMacro(ReplaceInvalidValues, vtkTypeBool);
266  vtkSetMacro(ReplacementValue, double);
267  vtkGetMacro(ReplacementValue, double);
269 
271 
276  vtkSetMacro(IgnoreMissingArrays, bool);
277  vtkGetMacro(IgnoreMissingArrays, bool);
278  vtkBooleanMacro(IgnoreMissingArrays, bool);
280 
285  {
286  FunctionParser, // vtkFunctionParser
287  ExprTkFunctionParser, // vtkExprTkFunctionParser
288  NumberOfFunctionParserTypes
289  };
290 
292 
296  vtkSetEnumMacro(FunctionParserType, FunctionParserTypes);
298  {
299  this->FunctionParserType = FunctionParserTypes::FunctionParser;
300  this->Modified();
301  }
303  {
304  this->FunctionParserType = FunctionParserTypes::ExprTkFunctionParser;
305  this->Modified();
306  }
307  vtkGetEnumMacro(FunctionParserType, FunctionParserTypes);
309 
314  vtkDataSet* GetDataSetOutput();
315 
316 protected:
318  ~vtkArrayCalculator() override;
319 
320  int FillInputPortInformation(int, vtkInformation*) override;
321 
323 
327  int GetAttributeTypeFromInput(vtkDataObject* input);
328 
336  static std::string CheckValidVariableName(const char* variableName);
337 
339 
340  char* Function;
342  std::vector<std::string> ScalarArrayNames;
343  std::vector<std::string> VectorArrayNames;
344  std::vector<std::string> ScalarVariableNames;
345  std::vector<std::string> VectorVariableNames;
347  std::vector<int> SelectedScalarComponents;
348  std::vector<vtkTuple<int, 3>> SelectedVectorComponents;
349 
353 
357  std::vector<std::string> CoordinateScalarVariableNames;
358  std::vector<std::string> CoordinateVectorVariableNames;
360  std::vector<vtkTuple<int, 3>> SelectedCoordinateVectorComponents;
361 
363 
364 private:
365  vtkArrayCalculator(const vtkArrayCalculator&) = delete;
366  void operator=(const vtkArrayCalculator&) = delete;
367 
368  // Do the bulk of the work
369  template <typename TFunctionParser>
370  int ProcessDataObject(vtkDataObject* input, vtkDataObject* output);
371 };
372 
373 VTK_ABI_NAMESPACE_END
374 #endif
vtkTypeBool ReplaceInvalidValues
const std::vector< vtkTuple< int, 3 > > & GetSelectedVectorComponents()
Methods to get information about the current variables.
std::vector< std::string > ScalarArrayNames
const std::vector< std::string > & GetScalarVariableNames()
Methods to get information about the current variables.
Superclass for algorithms that produce output of the same type as input.
Store vtkAlgorithm input/output information.
perform mathematical operations on data in field data arrays
abstract class to specify dataset behavior
Definition: vtkDataSet.h:52
void SetAttributeTypeToVertexData()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
void SetFunctionParserTypeToFunctionParser()
Set/Get the FunctionParser type that will be used.
void SetAttributeTypeToDefault()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
void SetAttributeTypeToPointData()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
const std::vector< int > & GetSelectedScalarComponents()
Methods to get information about the current variables.
void SetAttributeTypeToCellData()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
int GetNumberOfVectorArrays()
Methods to get information about the current variables.
std::vector< std::string > CoordinateVectorVariableNames
int vtkTypeBool
Definition: vtkABI.h:64
const std::vector< std::string > & GetVectorVariableNames()
Methods to get information about the current variables.
void SetFunctionParserTypeToExprTkFunctionParser()
Set/Get the FunctionParser type that will be used.
std::vector< std::string > VectorVariableNames
a simple class to control print indentation
Definition: vtkIndent.h:28
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
int GetNumberOfScalarArrays()
Methods to get information about the current variables.
virtual void Modified()
Update the modification time for this object.
std::vector< std::string > CoordinateScalarVariableNames
std::vector< std::string > ScalarVariableNames
FunctionParserTypes FunctionParserType
std::vector< vtkTuple< int, 3 > > SelectedVectorComponents
const std::vector< std::string > & GetVectorArrayNames()
Methods to get information about the current variables.
std::vector< vtkTuple< int, 3 > > SelectedCoordinateVectorComponents
FunctionParserTypes
Enum that includes the types of parsers that can be used.
std::vector< std::string > VectorArrayNames
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetAttributeTypeToEdgeData()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
const std::vector< std::string > & GetScalarArrayNames()
Methods to get information about the current variables.
Store zero or more vtkInformation instances.
vtkTypeBool CoordinateResults
general representation of visualization data
Definition: vtkDataObject.h:54
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called within ProcessRequest when a request asks the algorithm to do its work.
void SetAttributeTypeToRowData()
Control which AttributeType the filter operates on (point data or cell data for vtkDataSets).
std::vector< int > SelectedScalarComponents
static vtkPassInputTypeAlgorithm * New()
std::vector< int > SelectedCoordinateScalarComponents