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

vtkStreamTracer.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkStreamTracer.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 =========================================================================*/
00080 #ifndef __vtkStreamTracer_h
00081 #define __vtkStreamTracer_h
00082 
00083 #include "vtkDataSetToPolyDataFilter.h"
00084 
00085 #include "vtkInitialValueProblemSolver.h" // Needed for constants
00086 
00087 class vtkDataArray;
00088 class vtkDoubleArray;
00089 class vtkGenericCell;
00090 class vtkIdList;
00091 class vtkIntArray;
00092 class vtkInterpolatedVelocityField;
00093 
00094 class VTK_GRAPHICS_EXPORT vtkStreamTracer : public vtkDataSetToPolyDataFilter
00095 {
00096 public:
00097   vtkTypeRevisionMacro(vtkStreamTracer,vtkDataSetToPolyDataFilter);
00098   void PrintSelf(ostream& os, vtkIndent indent);
00099 
00104   static vtkStreamTracer *New();
00105   
00107 
00110   vtkSetVector3Macro(StartPosition, double);
00111   vtkGetVector3Macro(StartPosition, double);
00113 
00115 
00116   void SetSource(vtkDataSet *source);
00117   vtkDataSet *GetSource();
00119 
00120 //BTX
00121   enum Units
00122   {
00123     TIME_UNIT,
00124     LENGTH_UNIT,
00125     CELL_LENGTH_UNIT
00126   };
00127 
00128   enum Solvers
00129   {
00130     RUNGE_KUTTA2,
00131     RUNGE_KUTTA4,
00132     RUNGE_KUTTA45,
00133     NONE,
00134     UNKNOWN
00135   };
00136 
00137   enum ReasonForTermination
00138   {
00139     OUT_OF_DOMAIN = vtkInitialValueProblemSolver::OUT_OF_DOMAIN,
00140     NOT_INITIALIZED = vtkInitialValueProblemSolver::NOT_INITIALIZED ,
00141     UNEXPECTED_VALUE = vtkInitialValueProblemSolver::UNEXPECTED_VALUE,
00142     OUT_OF_TIME = 4,
00143     OUT_OF_STEPS = 5,
00144     STAGNATION = 6
00145   };
00146 //ETX
00147 
00149 
00155   void SetIntegrator(vtkInitialValueProblemSolver *);
00156   vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00157   void SetIntegratorType(int type);
00158   int GetIntegratorType();
00159   void SetIntegratorTypeToRungeKutta2()
00160     {this->SetIntegratorType(RUNGE_KUTTA2);};
00161   void SetIntegratorTypeToRungeKutta4()
00162     {this->SetIntegratorType(RUNGE_KUTTA4);};
00163   void SetIntegratorTypeToRungeKutta45()
00164     {this->SetIntegratorType(RUNGE_KUTTA45);};
00166 
00168 
00170   void SetMaximumPropagation(int unit, double max);
00171   void SetMaximumPropagation(double max);
00172   void SetMaximumPropagationUnit(int unit);
00173   int GetMaximumPropagationUnit();
00174   double GetMaximumPropagation();
00175   void SetMaximumPropagationUnitToTimeUnit()
00176     {this->SetMaximumPropagationUnit(TIME_UNIT);};
00177   void SetMaximumPropagationUnitToLengthUnit()
00178     {this->SetMaximumPropagationUnit(LENGTH_UNIT);};
00179   void SetMaximumPropagationUnitToCellLengthUnit()
00180     {this->SetMaximumPropagationUnit(CELL_LENGTH_UNIT);};          
00182 
00184 
00187   void SetMinimumIntegrationStep(int unit, double step);
00188   void SetMinimumIntegrationStepUnit(int unit);
00189   void SetMinimumIntegrationStep(double step);
00190   int GetMinimumIntegrationStepUnit();
00191   double GetMinimumIntegrationStep();
00192   void SetMinimumIntegrationStepUnitToTimeUnit()
00193     {this->SetMinimumIntegrationStepUnit(TIME_UNIT);};
00194   void SetMinimumIntegrationStepUnitToLengthUnit()
00195     {this->SetMinimumIntegrationStepUnit(LENGTH_UNIT);};
00196   void SetMinimumIntegrationStepUnitToCellLengthUnit()
00197     {this->SetMinimumIntegrationStepUnit(CELL_LENGTH_UNIT);};
00199 
00201 
00204   void SetMaximumIntegrationStep(int unit, double step);
00205   void SetMaximumIntegrationStepUnit(int unit);
00206   void SetMaximumIntegrationStep(double step);
00207   int GetMaximumIntegrationStepUnit();
00208   double GetMaximumIntegrationStep();
00209   void SetMaximumIntegrationStepUnitToTimeUnit()
00210     {this->SetMaximumIntegrationStepUnit(TIME_UNIT);};
00211   void SetMaximumIntegrationStepUnitToLengthUnit()
00212     {this->SetMaximumIntegrationStepUnit(LENGTH_UNIT);};
00213   void SetMaximumIntegrationStepUnitToCellLengthUnit()
00214     {this->SetMaximumIntegrationStepUnit(CELL_LENGTH_UNIT);};
00216 
00218 
00221   void SetInitialIntegrationStep(int unit, double step);
00222   void SetInitialIntegrationStepUnit(int unit);
00223   void SetInitialIntegrationStep(double step);
00224   int GetInitialIntegrationStepUnit();
00225   double GetInitialIntegrationStep();
00226   void SetInitialIntegrationStepUnitToTimeUnit()
00227     {this->SetInitialIntegrationStepUnit(TIME_UNIT);};
00228   void SetInitialIntegrationStepUnitToLengthUnit()
00229     {this->SetInitialIntegrationStepUnit(LENGTH_UNIT);};
00230   void SetInitialIntegrationStepUnitToCellLengthUnit()
00231     {this->SetInitialIntegrationStepUnit(CELL_LENGTH_UNIT);};
00233 
00235 
00238   vtkSetMacro(MaximumError, double);
00239   vtkGetMacro(MaximumError, double);
00241 
00243 
00244   vtkSetMacro(MaximumNumberOfSteps, vtkIdType);
00245   vtkGetMacro(MaximumNumberOfSteps, vtkIdType);
00247 
00249 
00251   vtkSetMacro(TerminalSpeed, double);
00252   vtkGetMacro(TerminalSpeed, double);
00254 
00255 //BTX
00256   enum
00257   {
00258     FORWARD,
00259     BACKWARD,
00260     BOTH
00261   };
00262 //ETX
00263 
00265 
00267   vtkSetClampMacro(IntegrationDirection, int, FORWARD, BOTH);
00268   vtkGetMacro(IntegrationDirection, int);
00269   void SetIntegrationDirectionToForward()
00270     {this->SetIntegrationDirection(FORWARD);};
00271   void SetIntegrationDirectionToBackward()
00272     {this->SetIntegrationDirection(BACKWARD);};
00273   void SetIntegrationDirectionToBoth()
00274     {this->SetIntegrationDirection(BOTH);};  
00276 
00278 
00280   vtkSetMacro(ComputeVorticity, int);
00281   vtkGetMacro(ComputeVorticity, int);
00282   vtkBooleanMacro(ComputeVorticity, int);
00284 
00286 
00288   vtkSetMacro(RotationScale, double);
00289   vtkGetMacro(RotationScale, double);
00291 
00293 
00296   vtkGetStringMacro(InputVectorsSelection);
00297   void SelectInputVectors(const char *fieldName) 
00298     {this->SetInputVectorsSelection(fieldName);}
00300   
00302   void AddInput(vtkDataSet *in);
00303 
00304   void SetInterpolatorPrototype(vtkInterpolatedVelocityField* ivf);
00305 
00306 protected:
00307 
00308   vtkStreamTracer();
00309   ~vtkStreamTracer();
00310 
00311   // hide the superclass' AddInput() from the user and the compiler
00312   void AddInput(vtkDataObject *) 
00313     { vtkErrorMacro( << "AddInput() must be called with a vtkDataSet not a vtkDataObject."); };
00314   
00315   void Execute();
00316   void CalculateVorticity( vtkGenericCell* cell, double pcoords[3],
00317                            vtkDoubleArray* cellVectors, double vorticity[3] );
00318   void Integrate(vtkPolyData* output,
00319                  vtkDataArray* seedSource, 
00320                  vtkIdList* seedIds,
00321                  vtkIntArray* integrationDirections,
00322                  double lastPoint[3],
00323                  vtkInterpolatedVelocityField* func,
00324                  int maxCellSize);
00325   void SimpleIntegrate(double seed[3], 
00326                        double lastPoint[3], 
00327                        double delt,
00328                        vtkInterpolatedVelocityField* func);
00329   int CheckInputs(vtkInterpolatedVelocityField*& func,
00330                   int* maxCellSize);
00331   void GenerateNormals(vtkPolyData* output, double* firstNormal);
00332 
00333   int GenerateNormalsInIntegrate;
00334 
00335   vtkSetStringMacro(InputVectorsSelection);
00336   char *InputVectorsSelection;
00337 
00338 
00339   // starting from global x-y-z position
00340   double StartPosition[3];
00341 
00342   static const double EPSILON;
00343   double TerminalSpeed;
00344 
00345   double LastUsedTimeStep;
00346 
00347 //BTX
00348   struct IntervalInformation
00349   {
00350     double Interval;
00351     int Unit;
00352   };
00353 
00354   IntervalInformation MaximumPropagation;
00355   IntervalInformation MinimumIntegrationStep;
00356   IntervalInformation MaximumIntegrationStep;
00357   IntervalInformation InitialIntegrationStep;
00358 
00359   void SetIntervalInformation(int unit, double interval,
00360                               IntervalInformation& currentValues);
00361   void SetIntervalInformation(int unit,IntervalInformation& currentValues);
00362   static double ConvertToTime(IntervalInformation& interval,
00363                              double cellLength, double speed);
00364   static double ConvertToLength(IntervalInformation& interval,
00365                                double cellLength, double speed);
00366   static double ConvertToCellLength(IntervalInformation& interval,
00367                                    double cellLength, double speed);
00368   static double ConvertToUnit(IntervalInformation& interval, int unit,
00369                              double cellLength, double speed);
00370   void ConvertIntervals(double& step, double& minStep, double& maxStep,
00371                         int direction, double cellLength, double speed);
00372 //ETX
00373 
00374   void InitializeSeeds(vtkDataArray*& seeds,
00375                        vtkIdList*& seedIds,
00376                        vtkIntArray*& integrationDirections);
00377   
00378   int IntegrationDirection;
00379 
00380   // Prototype showing the integrator type to be set by the user.
00381   vtkInitialValueProblemSolver* Integrator;
00382 
00383   double MaximumError;
00384   vtkIdType MaximumNumberOfSteps;
00385 
00386   int ComputeVorticity;
00387   double RotationScale;
00388 
00389   vtkInterpolatedVelocityField* InterpolatorPrototype;
00390 
00391 private:
00392   vtkStreamTracer(const vtkStreamTracer&);  // Not implemented.
00393   void operator=(const vtkStreamTracer&);  // Not implemented.
00394 };
00395 
00396 
00397 #endif
00398 
00399