vtkPythonCalculator.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
3 // SPDX-License-Identifier: BSD-3-Clause
28 #ifndef vtkPythonCalculator_h
29 #define vtkPythonCalculator_h
30 
31 #include "vtkDataObject.h" // for FIELD_ASSOCIATION_POINTS
32 #include "vtkPVVTKExtensionsFiltersPythonModule.h" //needed for exports
33 #include "vtkProgrammableFilter.h"
34 
36 {
37 public:
39  void PrintSelf(ostream& os, vtkIndent indent) override;
40  static vtkPythonCalculator* New();
41 
43 
48  vtkSetMacro(ArrayAssociation, int);
49  vtkGetMacro(ArrayAssociation, int);
51 
53 
58  vtkSetMacro(Expression, std::string);
59  vtkGetMacro(Expression, std::string);
61 
63 
67  vtkSetMacro(MultilineExpression, std::string);
68  vtkGetMacro(MultilineExpression, std::string);
70 
72 
75  vtkSetStringMacro(ArrayName);
76  vtkGetStringMacro(ArrayName);
78 
80 
84  vtkGetMacro(ResultArrayType, int);
85  vtkSetMacro(ResultArrayType, int);
87 
89 
94  vtkGetMacro(UseMultilineExpression, bool);
95  vtkSetMacro(UseMultilineExpression, bool);
97 
101  static void ExecuteScript(void*);
102 
103 protected:
105  ~vtkPythonCalculator() override;
106 
110  void Exec(const std::string&);
111 
112  int FillOutputPortInformation(int port, vtkInformation* info) override;
113 
114  // overridden to allow multiple inputs to port 0
115  int FillInputPortInformation(int port, vtkInformation* info) override;
116 
117  // ovveridden to set a time range so the filter is updated when a timestep changes.
118  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
119  vtkInformationVector* outputVector) override;
120 
121  // overridden to allow string substitutions for the Expression
122  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
123  vtkInformationVector* outputVector) override;
124 
125  // Creates whatever output data set type is selected.
126  int RequestDataObject(vtkInformation* request, vtkInformationVector** inputVector,
127  vtkInformationVector* outputVector) override;
128 
129  std::string Expression;
130  std::string MultilineExpression;
131  bool UseMultilineExpression = false;
132 
133  char* ArrayName = nullptr;
135  int ResultArrayType = VTK_DOUBLE;
136 
137 private:
138  vtkPythonCalculator(const vtkPythonCalculator&) = delete;
139  void operator=(const vtkPythonCalculator&) = delete;
140 };
141 
142 #endif
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
void PrintSelf(ostream &os, vtkIndent indent)
Evaluates a Python expression vtkPythonCalculator uses Python to calculate an expression.
virtual int FillInputPortInformation(int port, vtkInformation *info)
#define VTKPVVTKEXTENSIONSFILTERSPYTHON_EXPORT
#define VTK_DOUBLE
virtual int RequestDataObject(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
static vtkProgrammableFilter * New()
void operator=(const vtkObjectBase &)
virtual int FillOutputPortInformation(int port, vtkInformation *info)