VTK  9.7.1
vtkImageMathematics.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
16 #ifndef vtkImageMathematics_h
17 #define vtkImageMathematics_h
18 
19 // Operation options.
20 #define VTK_ADD 0
21 #define VTK_SUBTRACT 1
22 #define VTK_MULTIPLY 2
23 #define VTK_DIVIDE 3
24 #define VTK_INVERT 4
25 #define VTK_SIN 5
26 #define VTK_COS 6
27 #define VTK_EXP 7
28 #define VTK_LOG 8
29 #define VTK_ABS 9
30 #define VTK_SQR 10
31 #define VTK_SQRT 11
32 #define VTK_MIN 12
33 #define VTK_MAX 13
34 #define VTK_ATAN 14
35 #define VTK_ATAN2 15
36 #define VTK_MULTIPLYBYK 16
37 #define VTK_ADDC 17
38 #define VTK_CONJUGATE 18
39 #define VTK_COMPLEX_MULTIPLY 19
40 #define VTK_REPLACECBYK 20
41 
42 #include "vtkImagingMathModule.h" // For export macro
44 
45 VTK_ABI_NAMESPACE_BEGIN
46 // Excluded from JavaScript wrapping because it provides overloads for SetInputConnection which
47 // take precedence for all vtkAlgorithm(s)
50 {
51 public:
52  static vtkImageMathematics* New();
54  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
57 
60  vtkSetMacro(Operation, int);
61  vtkGetMacro(Operation, int);
63 
68  void SetOperationToAdd() { this->SetOperation(VTK_ADD); }
69 
74  void SetOperationToSubtract() { this->SetOperation(VTK_SUBTRACT); }
75 
80  void SetOperationToMultiply() { this->SetOperation(VTK_MULTIPLY); }
81 
86  void SetOperationToDivide() { this->SetOperation(VTK_DIVIDE); }
87 
88  void SetOperationToConjugate() { this->SetOperation(VTK_CONJUGATE); }
89 
90  void SetOperationToComplexMultiply() { this->SetOperation(VTK_COMPLEX_MULTIPLY); }
91 
96  void SetOperationToInvert() { this->SetOperation(VTK_INVERT); }
97 
102  void SetOperationToSin() { this->SetOperation(VTK_SIN); }
103 
108  void SetOperationToCos() { this->SetOperation(VTK_COS); }
109 
114  void SetOperationToExp() { this->SetOperation(VTK_EXP); }
115 
120  void SetOperationToLog() { this->SetOperation(VTK_LOG); }
121 
126  void SetOperationToAbsoluteValue() { this->SetOperation(VTK_ABS); }
127 
132  void SetOperationToSquare() { this->SetOperation(VTK_SQR); }
133 
138  void SetOperationToSquareRoot() { this->SetOperation(VTK_SQRT); }
139 
144  void SetOperationToMin() { this->SetOperation(VTK_MIN); }
145 
150  void SetOperationToMax() { this->SetOperation(VTK_MAX); }
151 
156  void SetOperationToATAN() { this->SetOperation(VTK_ATAN); }
157 
158  void SetOperationToATAN2() { this->SetOperation(VTK_ATAN2); }
159 
164  void SetOperationToMultiplyByK() { this->SetOperation(VTK_MULTIPLYBYK); }
165 
170  void SetOperationToAddConstant() { this->SetOperation(VTK_ADDC); }
171 
176  void SetOperationToReplaceCByK() { this->SetOperation(VTK_REPLACECBYK); }
177 
179 
182  vtkSetMacro(ConstantK, double);
183  vtkGetMacro(ConstantK, double);
185 
187 
190  vtkSetMacro(ConstantC, double);
191  vtkGetMacro(ConstantC, double);
193 
195 
198  vtkSetMacro(DivideByZeroToC, vtkTypeBool);
199  vtkGetMacro(DivideByZeroToC, vtkTypeBool);
200  vtkBooleanMacro(DivideByZeroToC, vtkTypeBool);
202 
204 
208  virtual void SetInput1Data(vtkDataObject* in) { this->SetInputData(0, in); }
209  virtual void SetInput2Data(vtkDataObject* in) { this->AddInputData(0, in); }
210  void SetInputConnection(int idx, vtkAlgorithmOutput* input) override;
212  {
213  this->SetInputConnection(0, input);
214  }
216 
223  virtual void ReplaceNthInputConnection(int idx, vtkAlgorithmOutput* input);
224 
226 
231  void SetInputData(int idx, vtkDataObject* input);
232  void SetInputData(vtkDataObject* input) { this->SetInputData(0, input); }
234 
236 
241  vtkDataObject* GetInput(int idx);
242  vtkDataObject* GetInput() { return this->GetInput(0); }
244 
251 
252 protected:
254  ~vtkImageMathematics() override = default;
255 
257  double ConstantK;
258  double ConstantC;
260 
262 
263  void ThreadedRequestData(vtkInformation* request, vtkInformationVector** inputVector,
264  vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData,
265  VTK_FUTURE_CONST int outExt[6], int threadId) override;
266 
267  int FillInputPortInformation(int port, vtkInformation* info) override;
268 
269 private:
270  vtkImageMathematics(const vtkImageMathematics&) = delete;
271  void operator=(const vtkImageMathematics&) = delete;
272 };
273 
274 VTK_ABI_NAMESPACE_END
275 #endif
int GetNumberOfInputConnections(int port)
Get the number of inputs currently connected to a port.
void SetOperationToATAN()
Set each pixel in the output image to the arctangent of the corresponding pixel in Input1...
void SetOperationToAdd()
Set each pixel in the output image to the sum of the corresponding pixels in Input1 and Input2...
void SetOperationToSquareRoot()
Set each pixel in the output image to the square root of the corresponding pixel in Input1...
void SetOperationToSin()
Set each pixel in the output image to the sine of the corresponding pixel in Input1.
#define VTK_SQR
void SetOperationToLog()
Set each pixel in the output image to the log of the corresponding pixel in Input1.
Store vtkAlgorithm input/output information.
#define VTK_SQRT
virtual void SetInput2Data(vtkDataObject *in)
Set the inputs to this filter.
#define VTK_ADDC
#define VTK_ADD
void SetOperationToMin()
Set each pixel in the output image to the minimum of the corresponding pixels in Input1 and Input2...
int GetNumberOfInputs()
Get the number of inputs to this filter.
void SetOperationToDivide()
Set each pixel in the output image to the quotient of the corresponding pixels in Input1 and Input2 (...
#define VTK_MAX
vtkDataObject * GetInput()
Get a data object for one of the input port connections.
#define VTK_COS
#define VTK_MULTIPLY
void SetInputData(vtkDataObject *)
Assign a data object as input.
void SetInputData(vtkDataObject *input)
Assign a data object as input.
#define VTK_ABS
Proxy object to connect input/output ports.
void SetOperationToAbsoluteValue()
Set each pixel in the output image to the absolute value of the corresponding pixel in Input1...
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_DIVIDE
Generic filter that has one input.
#define VTK_CONJUGATE
#define VTK_INVERT
#define VTK_SUBTRACT
#define VTK_MULTIPLYBYK
void SetInputConnection(vtkAlgorithmOutput *input) override
Set the inputs to this filter.
a simple class to control print indentation
Definition: vtkIndent.h:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
void SetOperationToSubtract()
Set each pixel in the output image to the difference of the corresponding pixels in Input1 and Input2...
void SetOperationToReplaceCByK()
Find every pixel in Input1 that equals ConstantC and set the corresponding pixels in the Output to Co...
virtual void SetInputConnection(int port, vtkAlgorithmOutput *input)
Set the connection for the given input port index.
void SetOperationToExp()
Set each pixel in the output image to the exponential of the corresponding pixel in Input1...
#define VTK_ATAN
void SetOperationToMultiplyByK()
Set each pixel in the output image to the product of ConstantK with the corresponding pixel in Input1...
virtual void ThreadedRequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector, vtkImageData ***inData, vtkImageData **outData, VTK_FUTURE_CONST int extent[6], int threadId)
If the subclass does not define an Execute method, then the task will be broken up, multiple threads will be spawned, and each thread will call this method.
#define VTK_REPLACECBYK
vtkDataObject * GetInput()
Get one input to this filter.
#define VTK_WRAPEXCLUDE_JAVASCRIPT
void SetOperationToSquare()
Set each pixel in the output image to the square of the corresponding pixel in Input1.
Add, subtract, multiply, divide, invert, sin, cos, exp, log.
void SetOperationToMax()
Set each pixel in the output image to the maximum of the corresponding pixels in Input1 and Input2...
#define VTK_MIN
int FillInputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
#define VTK_LOG
#define VTK_EXP
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_SIN
void SetOperationToInvert()
Set each pixel in the output image to 1 over the corresponding pixel in Input1 and Input2 (output = 1...
void SetOperationToMultiply()
Set each pixel in the output image to the product of the corresponding pixels in Input1 and Input2...
#define VTK_ATAN2
general representation of visualization data
Definition: vtkDataObject.h:55
void SetOperationToCos()
Set each pixel in the output image to the cosine of the corresponding pixel in Input1.
virtual void SetInput1Data(vtkDataObject *in)
Set the inputs to this filter.
#define VTK_COMPLEX_MULTIPLY
virtual void AddInputData(vtkDataObject *)
Assign a data object as input.
void SetOperationToAddConstant()
Set each pixel in the output image to the product of ConstantC with the corresponding pixel in Input1...