Graphics/vtkStreamer.h Source File

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