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

vtkStreamer.h

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