Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkGenericStreamer.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkGenericStreamer.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 =========================================================================*/
00062 #ifndef __vtkGenericStreamer_h
00063 #define __vtkGenericStreamer_h
00064 
00065 #include "vtkGenericDataSetToPolyDataFilter.h"
00066 
00067 class vtkInitialValueProblemSolver;
00068 class vtkMultiThreader;
00069 class vtkDataSet;
00070 
00071 #define VTK_INTEGRATE_FORWARD 0
00072 #define VTK_INTEGRATE_BACKWARD 1
00073 #define VTK_INTEGRATE_BOTH_DIRECTIONS 2
00074 
00075 class VTK_GENERIC_FILTERING_EXPORT vtkGenericStreamer : public vtkGenericDataSetToPolyDataFilter
00076 {
00077 public:
00078   vtkTypeRevisionMacro(vtkGenericStreamer,vtkGenericDataSetToPolyDataFilter);
00079   void PrintSelf(ostream& os, vtkIndent indent);
00080 
00084   void SetStartLocation(vtkIdType cellId, int subId, double pcoords[3]);
00085 
00087 
00090   void SetStartLocation(vtkIdType cellId, int subId, double r, double s,
00091                         double t);
00093 
00096   vtkIdType GetStartLocation(int& subId, double pcoords[3]);
00097 
00101   void SetStartPosition(double x[3]);
00102 
00106   void SetStartPosition(double x, double y, double z);
00107 
00109   double *GetStartPosition();
00110 
00112 
00113   void SetSource(vtkDataSet *source);
00114   vtkDataSet *GetSource();
00116 
00118 
00119   vtkSetClampMacro(MaximumPropagationTime,double,0.0,VTK_DOUBLE_MAX);
00120   vtkGetMacro(MaximumPropagationTime,double);
00122 
00124 
00125   vtkSetClampMacro(IntegrationDirection,int,
00126                    VTK_INTEGRATE_FORWARD,VTK_INTEGRATE_BOTH_DIRECTIONS);
00127   vtkGetMacro(IntegrationDirection,int);
00128   void SetIntegrationDirectionToForward()
00129     {this->SetIntegrationDirection(VTK_INTEGRATE_FORWARD);};
00130   void SetIntegrationDirectionToBackward()
00131     {this->SetIntegrationDirection(VTK_INTEGRATE_BACKWARD);};
00132   void SetIntegrationDirectionToIntegrateBothDirections()
00133     {this->SetIntegrationDirection(VTK_INTEGRATE_BOTH_DIRECTIONS);};
00134   const char *GetIntegrationDirectionAsString();
00136 
00138 
00140   vtkSetClampMacro(IntegrationStepLength,double,0.0000001,VTK_DOUBLE_MAX);
00141   vtkGetMacro(IntegrationStepLength,double);
00143 
00145 
00147   vtkSetMacro(SpeedScalars,int);
00148   vtkGetMacro(SpeedScalars,int);
00149   vtkBooleanMacro(SpeedScalars,int);
00151 
00153 
00158   vtkSetMacro(OrientationScalars, int);
00159   vtkGetMacro(OrientationScalars, int);
00160   vtkBooleanMacro(OrientationScalars, int);
00162 
00164 
00166   vtkSetClampMacro(TerminalSpeed,double,0.0,VTK_DOUBLE_MAX);
00167   vtkGetMacro(TerminalSpeed,double);
00169 
00171 
00176   vtkSetMacro(Vorticity,int);
00177   vtkGetMacro(Vorticity,int);
00178   vtkBooleanMacro(Vorticity,int);
00180 
00181   vtkSetMacro( NumberOfThreads, int );
00182   vtkGetMacro( NumberOfThreads, int );
00183 
00184   vtkSetMacro( SavePointInterval, double );
00185   vtkGetMacro( SavePointInterval, double );
00186 
00188 
00192   void SetIntegrator(vtkInitialValueProblemSolver *);
00193   vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00195 
00196 protected:
00198 
00201   vtkGenericStreamer();
00202   ~vtkGenericStreamer();
00204 
00205   // Integrate data
00206   void Integrate();
00207 
00208   // Controls where streamlines start from (either position or location).
00209   int StartFrom;
00210 
00211   // Starting from cell location
00212   vtkIdType StartCell;
00213   int StartSubId;
00214   double StartPCoords[3];
00215 
00216   // starting from global x-y-z position
00217   double StartPosition[3];
00218 
00219   //
00220   // Special classes for manipulating data
00221   //
00222   //BTX - begin tcl exclude
00223   //
00224   class StreamPoint {
00225   public:
00226     double    x[3];    // position 
00227     vtkIdType cellId;  // cell
00228     int       subId;   // cell sub id
00229     double    p[3];    // parametric coords in cell 
00230     double    v[3];    // velocity 
00231     double    speed;   // velocity norm 
00232     double    s;       // scalar value 
00233     double    t;       // time travelled so far 
00234     double    d;       // distance travelled so far 
00235     double    omega;   // stream vorticity, if computed
00236     double    theta;   // rotation angle, if vorticity is computed
00237   };
00238 
00239   class StreamArray;
00240   friend class StreamArray;
00241   class StreamArray { //;prevent man page generation
00242   public:
00243     StreamArray();
00244     ~StreamArray()
00245       {
00246         if (this->Array)
00247           {
00248           delete [] this->Array;
00249           }
00250       };
00251     vtkIdType GetNumberOfPoints() {return this->MaxId + 1;};
00252     StreamPoint *GetStreamPoint(vtkIdType i) {return this->Array + i;};
00253     vtkIdType InsertNextStreamPoint() 
00254       {
00255         if ( ++this->MaxId >= this->Size )
00256           {
00257           this->Resize(this->MaxId);
00258           }
00259         return this->MaxId; //return offset from array
00260       }
00261     StreamPoint *Resize(vtkIdType sz); //reallocates data
00262     void Reset() {this->MaxId = -1;};
00263 
00264     StreamPoint *Array;     // pointer to data
00265     vtkIdType MaxId;        // maximum index inserted thus far
00266     vtkIdType Size;         // allocated size of data
00267     vtkIdType Extend;       // grow array by this amount
00268     double Direction;       // integration direction
00269   };
00270   //ETX
00271   //
00272 
00273   //array of streamers
00274   StreamArray *Streamers;
00275   vtkIdType NumberOfStreamers;
00276 
00277   // length of Streamer is generated by time, or by MaximumSteps
00278   double MaximumPropagationTime;
00279 
00280   // integration direction
00281   int IntegrationDirection;
00282 
00283   // the length (fraction of cell size) of integration steps
00284   double IntegrationStepLength;
00285 
00286   // boolean controls whether vorticity is computed
00287   int Vorticity;
00288 
00289   // terminal propagation speed
00290   double TerminalSpeed;
00291 
00292   // boolean controls whether data scalars or velocity magnitude are used
00293   int SpeedScalars;
00294 
00295   // boolean controls whether data scalars or vorticity orientation are used
00296   int OrientationScalars;
00297 
00298   // Prototype showing the integrator type to be set by the user.
00299   vtkInitialValueProblemSolver* Integrator;
00300 
00301   // Interval with which the stream points will be stored.
00302   // Useful in reducing the memory footprint. Since the initial
00303   // value is small, by default, it will store all/most points.
00304   double SavePointInterval;
00305 
00306   static VTK_THREAD_RETURN_TYPE ThreadedIntegrate( void *arg );
00307 
00309 
00311   vtkGetMacro( NumberOfStreamers, int );
00312   StreamArray *GetStreamers() { return this->Streamers; };
00314 
00315   void InitializeThreadedIntegrate();
00316   vtkMultiThreader           *Threader;
00317   int                        NumberOfThreads;
00318 
00319 private:
00320   vtkGenericStreamer(const vtkGenericStreamer&);  // Not implemented.
00321   void operator=(const vtkGenericStreamer&);  // Not implemented.
00322 };
00323 
00325 inline const char *vtkGenericStreamer::GetIntegrationDirectionAsString()
00326 {
00327   if ( this->IntegrationDirection == VTK_INTEGRATE_FORWARD ) 
00328     {
00329     return "IntegrateForward";
00330     }
00331   else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD ) 
00332     {
00333     return "IntegrateBackward";
00334     }
00335   else 
00336     {
00337     return "IntegrateBothDirections";
00338     }
00339 }
00340 
00341 #endif
00342 
00343