VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkAMRGaussianPulseSource.h 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 =========================================================================*/ 00029 #ifndef VTKAMRGAUSSIANPULSESOURCE_H_ 00030 #define VTKAMRGAUSSIANPULSESOURCE_H_ 00031 00032 #include "vtkFiltersAMRModule.h" // For export macro 00033 #include "vtkOverlappingAMRAlgorithm.h" 00034 00035 #include <cmath> // For std::exp 00036 00037 class vtkOverlappingAMR; 00038 class vtkUniformGrid; 00039 class vtkInformation; 00040 class vtkInformationVector; 00041 00042 class VTKFILTERSAMR_EXPORT vtkAMRGaussianPulseSource : 00043 public vtkOverlappingAMRAlgorithm 00044 { 00045 public: 00046 static vtkAMRGaussianPulseSource* New(); 00047 vtkTypeMacro(vtkAMRGaussianPulseSource, vtkOverlappingAMRAlgorithm); 00048 void PrintSelf(ostream& os, vtkIndent indent); 00049 00051 00052 vtkSetMacro(Dimension,int); 00054 00056 00057 vtkSetMacro(NumberOfLevels,int); 00059 00061 00062 void SetRefinementRatio(int r) 00063 {this->RefinmentRatio=r;this->Modified();} 00065 00067 00068 void SetRootSpacing(double h0) 00069 { 00070 this->RootSpacing[0]=this->RootSpacing[1]=this->RootSpacing[2]=h0; 00071 this->Modified(); 00072 } 00074 00076 00077 vtkSetVector3Macro(PulseOrigin,double); 00078 vtkGetVector3Macro(PulseOrigin,double); 00079 void SetXPulseOrigin(double f) 00080 {this->PulseOrigin[0]=f;this->Modified();} 00081 void SetYPulseOrigin(double f) 00082 {this->PulseOrigin[1]=f;this->Modified();} 00083 void SetZPulseOrigin(double f) 00084 {this->PulseOrigin[2]=f;this->Modified();} 00086 00088 00089 vtkSetVector3Macro(PulseWidth,double); 00090 vtkGetVector3Macro(PulseWidth,double); 00091 void SetXPulseWidth(double f) 00092 {this->PulseWidth[0]=f;this->Modified();} 00093 void SetYPulseWidth(double f) 00094 {this->PulseWidth[1]=f;this->Modified();} 00095 void SetZPulseWidth(double f) 00096 {this->PulseWidth[2]=f;this->Modified();} 00098 00100 00101 vtkSetMacro(PulseAmplitude,double); 00102 vtkGetMacro(PulseAmplitude,double); 00104 00105 protected: 00106 vtkAMRGaussianPulseSource(); 00107 virtual ~vtkAMRGaussianPulseSource(); 00108 00110 00112 virtual int RequestData(vtkInformation *request, 00113 vtkInformationVector **inputVector, 00114 vtkInformationVector *outputVector); 00116 00118 00120 double ComputePulseAt(const double x, const double y, const double z) 00121 { 00122 double xyz[3]; xyz[0]=x; xyz[1]=y; xyz[2]=z; 00123 return( this->ComputePulseAt(xyz) ); 00124 } 00125 double ComputePulseAt( double pt[3] ) 00126 { 00127 double pulse = 0.0; 00128 double r = 0.0; 00129 for( int i=0; i < this->Dimension; ++i ) 00130 { 00131 double d = pt[i]-this->PulseOrigin[i]; 00132 double d2 = d*d; 00133 double L2 = this->PulseWidth[i]*this->PulseWidth[i]; 00134 r += d2/L2; 00135 } 00136 pulse = this->PulseAmplitude*std::exp( -r ); 00137 return( pulse ); 00138 } 00140 00142 00144 void ComputeCellCenter(vtkUniformGrid *grid, 00145 vtkIdType cellIdx, 00146 double centroid[3] ); 00148 00150 void GeneratePulseField(vtkUniformGrid *grid); 00151 00154 vtkUniformGrid* GetGrid( double origin[3], double h[3], int ndim[3] ); 00155 00157 vtkUniformGrid* RefinePatch(vtkUniformGrid* parent, int patchExtent[6]); 00158 00160 00161 void Generate2DDataSet(vtkOverlappingAMR* amr); 00162 void Generate3DDataSet(vtkOverlappingAMR* amr); 00164 00165 double RootSpacing[3]; 00166 double PulseOrigin[3]; 00167 double PulseWidth[3]; 00168 double PulseAmplitude; 00169 int RefinmentRatio; 00170 int Dimension; 00171 int NumberOfLevels; 00172 00173 private: 00174 vtkAMRGaussianPulseSource(const vtkAMRGaussianPulseSource&); // Not implemented 00175 void operator=(const vtkAMRGaussianPulseSource&); // Not implemented 00176 }; 00177 00178 #endif /* VTKAMRGAUSSIANPULSESOURCE_H_ */