00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00079 #ifndef __vtkStreamer_h
00080 #define __vtkStreamer_h
00081 
00082 #include "vtkDataSetToPolyDataFilter.h"
00083 #include "vtkInitialValueProblemSolver.h"
00084 
00085 class vtkMultiThreader;
00086 
00087 #define VTK_INTEGRATE_FORWARD 0
00088 #define VTK_INTEGRATE_BACKWARD 1
00089 #define VTK_INTEGRATE_BOTH_DIRECTIONS 2
00090 
00091 typedef struct _vtkStreamPoint {
00092   float   x[3];    
00093   int     cellId;  
00094   int     subId;   
00095   float   p[3];    
00096   float   v[3];    
00097   float   speed;   
00098   float   s;       
00099   float   t;       
00100   float   d;       
00101   float   omega;   
00102   float   theta;    
00103 } vtkStreamPoint;
00104 
00105 
00106 
00107 
00108 
00109 
00110 class vtkStreamArray { 
00111 public:
00112   vtkStreamArray();
00113   ~vtkStreamArray()
00114     {
00115     if (this->Array)
00116       {
00117       delete [] this->Array;
00118       }
00119     };
00120   int GetNumberOfPoints() {return this->MaxId + 1;};
00121   vtkStreamPoint *GetStreamPoint(int i) {return this->Array + i;};
00122   int InsertNextStreamPoint() 
00123     {
00124     if ( ++this->MaxId >= this->Size )
00125       {
00126       this->Resize(this->MaxId);
00127       }
00128     return this->MaxId; 
00129     }
00130   vtkStreamPoint *Resize(int sz); 
00131   void Reset() {this->MaxId = -1;};
00132 
00133   vtkStreamPoint *Array;  
00134   int MaxId;              
00135   int Size;               
00136   int Extend;             
00137   float Direction;        
00138 };
00139 
00140 
00141 
00142 class VTK_EXPORT vtkStreamer : public vtkDataSetToPolyDataFilter
00143 {
00144 public:
00145   vtkTypeMacro(vtkStreamer,vtkDataSetToPolyDataFilter);
00146   void PrintSelf(ostream& os, vtkIndent indent);
00147 
00151   static vtkStreamer *New();
00152   
00156   void SetStartLocation(int cellId, int subId, float pcoords[3]);
00157 
00161   void SetStartLocation(int cellId, int subId, float r, float s, float t);
00162 
00165   int GetStartLocation(int& subId, float pcoords[3]);
00166 
00170   void SetStartPosition(float x[3]);
00171 
00175   void SetStartPosition(float x, float y, float z);
00176 
00178   float *GetStartPosition();
00179 
00181   void SetSource(vtkDataSet *source);
00182   vtkDataSet *GetSource();
00183   
00185   vtkSetClampMacro(MaximumPropagationTime,float,0.0,VTK_LARGE_FLOAT);
00186   vtkGetMacro(MaximumPropagationTime,float);
00187 
00189   vtkSetClampMacro(IntegrationDirection,int,
00190                   VTK_INTEGRATE_FORWARD,VTK_INTEGRATE_BOTH_DIRECTIONS);
00191   vtkGetMacro(IntegrationDirection,int);
00192   void SetIntegrationDirectionToForward()
00193     {this->SetIntegrationDirection(VTK_INTEGRATE_FORWARD);};
00194   void SetIntegrationDirectionToBackward()
00195     {this->SetIntegrationDirection(VTK_INTEGRATE_BACKWARD);};
00196   void SetIntegrationDirectionToIntegrateBothDirections()
00197     {this->SetIntegrationDirection(VTK_INTEGRATE_BOTH_DIRECTIONS);};
00198   const char *GetIntegrationDirectionAsString();
00199 
00202   vtkSetClampMacro(IntegrationStepLength,float,0.0000001,VTK_LARGE_FLOAT);
00203   vtkGetMacro(IntegrationStepLength,float);
00204 
00207   vtkSetMacro(SpeedScalars,int);
00208   vtkGetMacro(SpeedScalars,int);
00209   vtkBooleanMacro(SpeedScalars,int);
00210 
00213   vtkSetClampMacro(TerminalSpeed,float,0.0,VTK_LARGE_FLOAT);
00214   vtkGetMacro(TerminalSpeed,float);
00215 
00221   vtkSetMacro(Vorticity,int);
00222   vtkGetMacro(Vorticity,int);
00223   vtkBooleanMacro(Vorticity,int);
00224 
00225   vtkSetMacro( NumberOfThreads, int );
00226   vtkGetMacro( NumberOfThreads, int );
00227 
00228   vtkSetMacro( SavePointInterval, float );
00229   vtkGetMacro( SavePointInterval, float );
00230 
00235   vtkSetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00236   vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00237 
00238 
00239 
00242   vtkGetMacro( NumberOfStreamers, int );
00243   vtkStreamArray *GetStreamers() { return this->Streamers; };
00244 
00245 
00246 
00247 protected:
00248   vtkStreamer();
00249   ~vtkStreamer();
00250   vtkStreamer(const vtkStreamer&) {};
00251   void operator=(const vtkStreamer&) {};
00252 
00253   
00254   void Integrate();
00255 
00256   
00257   void ComputeVorticity();
00258 
00259   
00260   int StartFrom;
00261 
00262   
00263   int StartCell;
00264   int StartSubId;
00265   float StartPCoords[3];
00266 
00267   
00268   float StartPosition[3];
00269 
00270   
00271   vtkStreamArray *Streamers;
00272   int NumberOfStreamers;
00273 
00274   
00275   float MaximumPropagationTime;
00276 
00277   
00278   int IntegrationDirection;
00279 
00280   
00281   float IntegrationStepLength;
00282 
00283   
00284   int Vorticity;
00285 
00286   
00287   float TerminalSpeed;
00288 
00289   
00290   int SpeedScalars;
00291 
00292   
00293   vtkInitialValueProblemSolver* Integrator;
00294 
00295   
00296   
00297   
00298   float SavePointInterval;
00299 
00300   void InitializeThreadedIntegrate();
00301   vtkMultiThreader           *Threader;
00302   int                        NumberOfThreads;
00303 
00304 };
00305 
00307 inline const char *vtkStreamer::GetIntegrationDirectionAsString(void)
00308 {
00309   if ( this->IntegrationDirection == VTK_INTEGRATE_FORWARD ) 
00310     {
00311     return "IntegrateForward";
00312     }
00313   else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD ) 
00314     {
00315     return "IntegrateBackward";
00316     }
00317   else 
00318     {
00319     return "IntegrateBothDirections";
00320     }
00321 }
00322 
00323 #endif
00324 
00325