VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkImageMathematics.h,v $ 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00027 #ifndef __vtkImageMathematics_h 00028 #define __vtkImageMathematics_h 00029 00030 00031 // Operation options. 00032 #define VTK_ADD 0 00033 #define VTK_SUBTRACT 1 00034 #define VTK_MULTIPLY 2 00035 #define VTK_DIVIDE 3 00036 #define VTK_INVERT 4 00037 #define VTK_SIN 5 00038 #define VTK_COS 6 00039 #define VTK_EXP 7 00040 #define VTK_LOG 8 00041 #define VTK_ABS 9 00042 #define VTK_SQR 10 00043 #define VTK_SQRT 11 00044 #define VTK_MIN 12 00045 #define VTK_MAX 13 00046 #define VTK_ATAN 14 00047 #define VTK_ATAN2 15 00048 #define VTK_MULTIPLYBYK 16 00049 #define VTK_ADDC 17 00050 #define VTK_CONJUGATE 18 00051 #define VTK_COMPLEX_MULTIPLY 19 00052 #define VTK_REPLACECBYK 20 00053 00054 #include "vtkThreadedImageAlgorithm.h" 00055 00056 class VTK_IMAGING_EXPORT vtkImageMathematics : public vtkThreadedImageAlgorithm 00057 { 00058 public: 00059 static vtkImageMathematics *New(); 00060 vtkTypeRevisionMacro(vtkImageMathematics,vtkThreadedImageAlgorithm); 00061 void PrintSelf(ostream& os, vtkIndent indent); 00062 00064 00065 vtkSetMacro(Operation,int); 00066 vtkGetMacro(Operation,int); 00067 void SetOperationToAdd() {this->SetOperation(VTK_ADD);}; 00068 void SetOperationToSubtract() {this->SetOperation(VTK_SUBTRACT);}; 00069 void SetOperationToMultiply() {this->SetOperation(VTK_MULTIPLY);}; 00070 void SetOperationToDivide() {this->SetOperation(VTK_DIVIDE);}; 00071 void SetOperationToConjugate() {this->SetOperation(VTK_CONJUGATE);}; 00072 void SetOperationToComplexMultiply() 00073 {this->SetOperation(VTK_COMPLEX_MULTIPLY);}; 00075 00076 void SetOperationToInvert() {this->SetOperation(VTK_INVERT);}; 00077 void SetOperationToSin() {this->SetOperation(VTK_SIN);}; 00078 void SetOperationToCos() {this->SetOperation(VTK_COS);}; 00079 void SetOperationToExp() {this->SetOperation(VTK_EXP);}; 00080 void SetOperationToLog() {this->SetOperation(VTK_LOG);}; 00081 void SetOperationToAbsoluteValue() {this->SetOperation(VTK_ABS);}; 00082 void SetOperationToSquare() {this->SetOperation(VTK_SQR);}; 00083 void SetOperationToSquareRoot() {this->SetOperation(VTK_SQRT);}; 00084 void SetOperationToMin() {this->SetOperation(VTK_MIN);}; 00085 void SetOperationToMax() {this->SetOperation(VTK_MAX);}; 00086 00087 void SetOperationToATAN() {this->SetOperation(VTK_ATAN);}; 00088 void SetOperationToATAN2() {this->SetOperation(VTK_ATAN2);}; 00089 void SetOperationToMultiplyByK() {this->SetOperation(VTK_MULTIPLYBYK);}; 00090 void SetOperationToAddConstant() {this->SetOperation(VTK_ADDC);}; 00091 void SetOperationToReplaceCByK() {this->SetOperation(VTK_REPLACECBYK);}; 00092 vtkSetMacro(ConstantK,double); 00093 vtkGetMacro(ConstantK,double); 00094 vtkSetMacro(ConstantC,double); 00095 vtkGetMacro(ConstantC,double); 00096 00097 // How to handle divide by zero 00098 vtkSetMacro(DivideByZeroToC,int); 00099 vtkGetMacro(DivideByZeroToC,int); 00100 vtkBooleanMacro(DivideByZeroToC,int); 00101 00103 00104 virtual void SetInput1(vtkDataObject *in) { this->SetInput(0,in); } 00105 virtual void SetInput2(vtkDataObject *in) { this->SetInput(1,in); } 00107 00108 protected: 00109 vtkImageMathematics(); 00110 ~vtkImageMathematics() {}; 00111 00112 int Operation; 00113 double ConstantK; 00114 double ConstantC; 00115 int DivideByZeroToC; 00116 00117 virtual int RequestInformation (vtkInformation *, 00118 vtkInformationVector **, 00119 vtkInformationVector *); 00120 00121 virtual void ThreadedRequestData(vtkInformation *request, 00122 vtkInformationVector **inputVector, 00123 vtkInformationVector *outputVector, 00124 vtkImageData ***inData, 00125 vtkImageData **outData, 00126 int extent[6], int threadId); 00127 00128 virtual int FillInputPortInformation(int port, vtkInformation* info); 00129 00130 private: 00131 vtkImageMathematics(const vtkImageMathematics&); // Not implemented. 00132 void operator=(const vtkImageMathematics&); // Not implemented. 00133 }; 00134 00135 #endif 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148