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
00080 #ifndef __vtkStreamer_h
00081 #define __vtkStreamer_h
00082
00083 #include "vtkDataSetToPolyDataFilter.h"
00084 #include "vtkInitialValueProblemSolver.h"
00085 #include "vtkMultiThreader.h"
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 vtkIdType 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 vtkIdType GetNumberOfPoints() {return this->MaxId + 1;};
00121 vtkStreamPoint *GetStreamPoint(vtkIdType i) {return this->Array + i;};
00122 vtkIdType InsertNextStreamPoint()
00123 {
00124 if ( ++this->MaxId >= this->Size )
00125 {
00126 this->Resize(this->MaxId);
00127 }
00128 return this->MaxId;
00129 }
00130 vtkStreamPoint *Resize(vtkIdType sz);
00131 void Reset() {this->MaxId = -1;};
00132
00133 vtkStreamPoint *Array;
00134 vtkIdType MaxId;
00135 vtkIdType Size;
00136 vtkIdType Extend;
00137 float Direction;
00138 };
00139
00140
00141
00142 class VTK_GRAPHICS_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(vtkIdType cellId, int subId, float pcoords[3]);
00157
00159
00162 void SetStartLocation(vtkIdType cellId, int subId, float r, float s,
00163 float t);
00165
00168 vtkIdType GetStartLocation(int& subId, float pcoords[3]);
00169
00173 void SetStartPosition(float x[3]);
00174
00178 void SetStartPosition(float x, float y, float z);
00179
00181 float *GetStartPosition();
00182
00184
00185 void SetSource(vtkDataSet *source);
00186 vtkDataSet *GetSource();
00188
00190
00191 vtkSetClampMacro(MaximumPropagationTime,float,0.0,VTK_LARGE_FLOAT);
00192 vtkGetMacro(MaximumPropagationTime,float);
00194
00196
00197 vtkSetClampMacro(IntegrationDirection,int,
00198 VTK_INTEGRATE_FORWARD,VTK_INTEGRATE_BOTH_DIRECTIONS);
00199 vtkGetMacro(IntegrationDirection,int);
00200 void SetIntegrationDirectionToForward()
00201 {this->SetIntegrationDirection(VTK_INTEGRATE_FORWARD);};
00202 void SetIntegrationDirectionToBackward()
00203 {this->SetIntegrationDirection(VTK_INTEGRATE_BACKWARD);};
00204 void SetIntegrationDirectionToIntegrateBothDirections()
00205 {this->SetIntegrationDirection(VTK_INTEGRATE_BOTH_DIRECTIONS);};
00206 const char *GetIntegrationDirectionAsString();
00208
00210
00212 vtkSetClampMacro(IntegrationStepLength,float,0.0000001,VTK_LARGE_FLOAT);
00213 vtkGetMacro(IntegrationStepLength,float);
00215
00217
00219 vtkSetMacro(SpeedScalars,int);
00220 vtkGetMacro(SpeedScalars,int);
00221 vtkBooleanMacro(SpeedScalars,int);
00223
00225
00230 vtkSetMacro(OrientationScalars, int);
00231 vtkGetMacro(OrientationScalars, int);
00232 vtkBooleanMacro(OrientationScalars, int);
00234
00236
00238 vtkSetClampMacro(TerminalSpeed,float,0.0,VTK_LARGE_FLOAT);
00239 vtkGetMacro(TerminalSpeed,float);
00241
00243
00248 vtkSetMacro(Vorticity,int);
00249 vtkGetMacro(Vorticity,int);
00250 vtkBooleanMacro(Vorticity,int);
00252
00253 vtkSetMacro( NumberOfThreads, int );
00254 vtkGetMacro( NumberOfThreads, int );
00255
00256 vtkSetMacro( SavePointInterval, float );
00257 vtkGetMacro( SavePointInterval, float );
00258
00260
00264 vtkSetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00265 vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00267
00268 protected:
00269
00270 vtkStreamer();
00271 ~vtkStreamer();
00272
00273
00274 void Integrate();
00275
00276
00277 void ComputeVorticity();
00278
00279
00280 int StartFrom;
00281
00282
00283 vtkIdType StartCell;
00284 int StartSubId;
00285 float StartPCoords[3];
00286
00287
00288 float StartPosition[3];
00289
00290
00291 vtkStreamArray *Streamers;
00292 vtkIdType NumberOfStreamers;
00293
00294
00295 float MaximumPropagationTime;
00296
00297
00298 int IntegrationDirection;
00299
00300
00301 float IntegrationStepLength;
00302
00303
00304 int Vorticity;
00305
00306
00307 float TerminalSpeed;
00308
00309
00310 int SpeedScalars;
00311
00312
00313 int OrientationScalars;
00314
00315
00316 vtkInitialValueProblemSolver* Integrator;
00317
00318
00319
00320
00321 float SavePointInterval;
00322
00323 static VTK_THREAD_RETURN_TYPE ThreadedIntegrate( void *arg );
00324
00326
00328 vtkGetMacro( NumberOfStreamers, int );
00329 vtkStreamArray *GetStreamers() { return this->Streamers; };
00331
00332 void InitializeThreadedIntegrate();
00333 vtkMultiThreader *Threader;
00334 int NumberOfThreads;
00335
00336 private:
00337 vtkStreamer(const vtkStreamer&);
00338 void operator=(const vtkStreamer&);
00339 };
00340
00342 inline const char *vtkStreamer::GetIntegrationDirectionAsString(void)
00343 {
00344 if ( this->IntegrationDirection == VTK_INTEGRATE_FORWARD )
00345 {
00346 return "IntegrateForward";
00347 }
00348 else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD )
00349 {
00350 return "IntegrateBackward";
00351 }
00352 else
00353 {
00354 return "IntegrateBothDirections";
00355 }
00356 }
00357
00358 #endif
00359
00360