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

Graphics/vtkStreamer.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkStreamer.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00071 #ifndef __vtkStreamer_h
00072 #define __vtkStreamer_h
00073 
00074 #include "vtkDataSetToPolyDataFilter.h"
00075 
00076 class vtkInitialValueProblemSolver;
00077 class vtkMultiThreader;
00078 
00079 #define VTK_INTEGRATE_FORWARD 0
00080 #define VTK_INTEGRATE_BACKWARD 1
00081 #define VTK_INTEGRATE_BOTH_DIRECTIONS 2
00082 
00083 class VTK_GRAPHICS_EXPORT vtkStreamer : public vtkDataSetToPolyDataFilter
00084 {
00085 public:
00086   vtkTypeRevisionMacro(vtkStreamer,vtkDataSetToPolyDataFilter);
00087   void PrintSelf(ostream& os, vtkIndent indent);
00088 
00092   void SetStartLocation(vtkIdType cellId, int subId, float pcoords[3]);
00093 
00095 
00098   void SetStartLocation(vtkIdType cellId, int subId, float r, float s,
00099                         float t);
00101 
00104   vtkIdType GetStartLocation(int& subId, float pcoords[3]);
00105 
00109   void SetStartPosition(float x[3]);
00110 
00114   void SetStartPosition(float x, float y, float z);
00115 
00117   float *GetStartPosition();
00118 
00120 
00121   void SetSource(vtkDataSet *source);
00122   vtkDataSet *GetSource();
00124 
00126 
00127   vtkSetClampMacro(MaximumPropagationTime,float,0.0,VTK_LARGE_FLOAT);
00128   vtkGetMacro(MaximumPropagationTime,float);
00130 
00132 
00133   vtkSetClampMacro(IntegrationDirection,int,
00134                    VTK_INTEGRATE_FORWARD,VTK_INTEGRATE_BOTH_DIRECTIONS);
00135   vtkGetMacro(IntegrationDirection,int);
00136   void SetIntegrationDirectionToForward()
00137     {this->SetIntegrationDirection(VTK_INTEGRATE_FORWARD);};
00138   void SetIntegrationDirectionToBackward()
00139     {this->SetIntegrationDirection(VTK_INTEGRATE_BACKWARD);};
00140   void SetIntegrationDirectionToIntegrateBothDirections()
00141     {this->SetIntegrationDirection(VTK_INTEGRATE_BOTH_DIRECTIONS);};
00142   const char *GetIntegrationDirectionAsString();
00144 
00146 
00148   vtkSetClampMacro(IntegrationStepLength,float,0.0000001,VTK_LARGE_FLOAT);
00149   vtkGetMacro(IntegrationStepLength,float);
00151 
00153 
00155   vtkSetMacro(SpeedScalars,int);
00156   vtkGetMacro(SpeedScalars,int);
00157   vtkBooleanMacro(SpeedScalars,int);
00159 
00161 
00166   vtkSetMacro(OrientationScalars, int);
00167   vtkGetMacro(OrientationScalars, int);
00168   vtkBooleanMacro(OrientationScalars, int);
00170 
00172 
00174   vtkSetClampMacro(TerminalSpeed,float,0.0,VTK_LARGE_FLOAT);
00175   vtkGetMacro(TerminalSpeed,float);
00177 
00179 
00184   vtkSetMacro(Vorticity,int);
00185   vtkGetMacro(Vorticity,int);
00186   vtkBooleanMacro(Vorticity,int);
00188 
00189   vtkSetMacro( NumberOfThreads, int );
00190   vtkGetMacro( NumberOfThreads, int );
00191 
00192   vtkSetMacro( SavePointInterval, float );
00193   vtkGetMacro( SavePointInterval, float );
00194 
00196 
00200   void SetIntegrator(vtkInitialValueProblemSolver *);
00201   vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00203 
00204 protected:
00206 
00209   vtkStreamer();
00210   ~vtkStreamer();
00212 
00213   // Integrate data
00214   void Integrate();
00215 
00216   // Special method for computing streamer vorticity
00217   void ComputeVorticity();
00218 
00219   // Controls where streamlines start from (either position or location).
00220   int StartFrom;
00221 
00222   // Starting from cell location
00223   vtkIdType StartCell;
00224   int StartSubId;
00225   float StartPCoords[3];
00226 
00227   // starting from global x-y-z position
00228   float StartPosition[3];
00229 
00230   //
00231   // Special classes for manipulating data
00232   //
00233   //BTX - begin tcl exclude
00234   //
00235   class StreamPoint {
00236   public:
00237     float   x[3];    // position 
00238     vtkIdType     cellId;  // cell
00239     int     subId;   // cell sub id
00240     float   p[3];    // parametric coords in cell 
00241     float   v[3];    // velocity 
00242     float   speed;   // velocity norm 
00243     float   s;       // scalar value 
00244     float   t;       // time travelled so far 
00245     float   d;       // distance travelled so far 
00246     float   omega;   // stream vorticity, if computed
00247     float   theta;    // rotation angle, if vorticity is computed
00248   };
00249 
00250   class StreamArray;
00251   friend class StreamArray;
00252   class StreamArray { //;prevent man page generation
00253   public:
00254     StreamArray();
00255     ~StreamArray()
00256       {
00257         if (this->Array)
00258           {
00259           delete [] this->Array;
00260           }
00261       };
00262     vtkIdType GetNumberOfPoints() {return this->MaxId + 1;};
00263     StreamPoint *GetStreamPoint(vtkIdType i) {return this->Array + i;};
00264     vtkIdType InsertNextStreamPoint() 
00265       {
00266         if ( ++this->MaxId >= this->Size )
00267           {
00268           this->Resize(this->MaxId);
00269           }
00270         return this->MaxId; //return offset from array
00271       }
00272     StreamPoint *Resize(vtkIdType sz); //reallocates data
00273     void Reset() {this->MaxId = -1;};
00274 
00275     StreamPoint *Array;  // pointer to data
00276     vtkIdType MaxId;        // maximum index inserted thus far
00277     vtkIdType Size;         // allocated size of data
00278     vtkIdType Extend;       // grow array by this amount
00279     float Direction;        // integration direction
00280   };
00281   //ETX
00282   //
00283 
00284   //array of streamers
00285   StreamArray *Streamers;
00286   vtkIdType NumberOfStreamers;
00287 
00288   // length of Streamer is generated by time, or by MaximumSteps
00289   float MaximumPropagationTime;
00290 
00291   // integration direction
00292   int IntegrationDirection;
00293 
00294   // the length (fraction of cell size) of integration steps
00295   float IntegrationStepLength;
00296 
00297   // boolean controls whether vorticity is computed
00298   int Vorticity;
00299 
00300   // terminal propagation speed
00301   float TerminalSpeed;
00302 
00303   // boolean controls whether data scalars or velocity magnitude are used
00304   int SpeedScalars;
00305 
00306   // boolean controls whether data scalars or vorticity orientation are used
00307   int OrientationScalars;
00308 
00309   // Prototype showing the integrator type to be set by the user.
00310   vtkInitialValueProblemSolver* Integrator;
00311 
00312   // Interval with which the stream points will be stored.
00313   // Useful in reducing the memory footprint. Since the initial
00314   // value is small, by default, it will store all/most points.
00315   float SavePointInterval;
00316 
00317   static  VTK_THREAD_RETURN_TYPE ThreadedIntegrate( void *arg );
00318 
00320 
00322   vtkGetMacro( NumberOfStreamers, int );
00323   StreamArray *GetStreamers() { return this->Streamers; };
00325 
00326   void InitializeThreadedIntegrate();
00327   vtkMultiThreader           *Threader;
00328   int                        NumberOfThreads;
00329 
00330 private:
00331   vtkStreamer(const vtkStreamer&);  // Not implemented.
00332   void operator=(const vtkStreamer&);  // Not implemented.
00333 };
00334 
00336 inline const char *vtkStreamer::GetIntegrationDirectionAsString(void)
00337 {
00338   if ( this->IntegrationDirection == VTK_INTEGRATE_FORWARD ) 
00339     {
00340     return "IntegrateForward";
00341     }
00342   else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD ) 
00343     {
00344     return "IntegrateBackward";
00345     }
00346   else 
00347     {
00348     return "IntegrateBothDirections";
00349     }
00350 }
00351 
00352 #endif
00353 
00354