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
22 #ifndef vtkPythonCalculator_h
23 #define vtkPythonCalculator_h
24 
25 #include "vtkDataObject.h" // for FIELD_ASSOCIATION_POINTS
26 #include "vtkPVVTKExtensionsFiltersPythonModule.h" //needed for exports
27 #include "vtkProgrammableFilter.h"
28 
30 {
31 public:
33  void PrintSelf(ostream& os, vtkIndent indent) override;
34  static vtkPythonCalculator* New();
35 
37 
42  vtkSetMacro(ArrayAssociation, int);
43  vtkGetMacro(ArrayAssociation, int);
45 
47 
52  vtkSetMacro(Expression, std::string);
53  vtkGetMacro(Expression, std::string);
55 
57 
61  vtkSetMacro(MultilineExpression, std::string);
62  vtkGetMacro(MultilineExpression, std::string);
64 
66 
69  vtkSetStringMacro(ArrayName);
70  vtkGetStringMacro(ArrayName);
72 
74 
78  vtkGetMacro(ResultArrayType, int);
79  vtkSetMacro(ResultArrayType, int);
81 
83 
88  vtkGetMacro(UseMultilineExpression, bool);
89  vtkSetMacro(UseMultilineExpression, bool);
91 
95  static void ExecuteScript(void*);
96 
97 protected:
99  ~vtkPythonCalculator() override;
100 
104  void Exec(const std::string&);
105 
106  int FillOutputPortInformation(int port, vtkInformation* info) override;
107 
108  // overridden to allow multiple inputs to port 0
109  int FillInputPortInformation(int port, vtkInformation* info) override;
110 
111  // overridden to allow string substitutions for the Expression
112  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
113  vtkInformationVector* outputVector) override;
114 
115  // Creates whatever output data set type is selected.
116  int RequestDataObject(vtkInformation* request, vtkInformationVector** inputVector,
117  vtkInformationVector* outputVector) override;
118 
119  std::string Expression;
120  std::string MultilineExpression;
121  bool UseMultilineExpression = false;
122 
123  char* ArrayName = nullptr;
125  int ResultArrayType = VTK_DOUBLE;
126 
127 private:
128  vtkPythonCalculator(const vtkPythonCalculator&) = delete;
129  void operator=(const vtkPythonCalculator&) = delete;
130 };
131 
132 #endif
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)