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

Graphics/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 =========================================================================*/
00068 #ifndef __vtkStreamTracer_h
00069 #define __vtkStreamTracer_h
00070 
00071 #include "vtkDataSetToPolyDataFilter.h"
00072 
00073 #include "vtkInitialValueProblemSolver.h" // Needed for constants
00074 
00075 class vtkDataArray;
00076 class vtkDoubleArray;
00077 class vtkGenericCell;
00078 class vtkIdList;
00079 class vtkIntArray;
00080 class vtkInterpolatedVelocityField;
00081 
00082 class VTK_GRAPHICS_EXPORT vtkStreamTracer : public vtkDataSetToPolyDataFilter
00083 {
00084 public:
00085   vtkTypeRevisionMacro(vtkStreamTracer,vtkDataSetToPolyDataFilter);
00086   void PrintSelf(ostream& os, vtkIndent indent);
00087 
00092   static vtkStreamTracer *New();
00093   
00095 
00098   vtkSetVector3Macro(StartPosition, double);
00099   vtkGetVector3Macro(StartPosition, double);
00101 
00103 
00104   void SetSource(vtkDataSet *source);
00105   vtkDataSet *GetSource();
00107 
00108 //BTX
00109   enum Units
00110   {
00111     TIME_UNIT,
00112     LENGTH_UNIT,
00113     CELL_LENGTH_UNIT
00114   };
00115 
00116   enum Solvers
00117   {
00118     RUNGE_KUTTA2,
00119     RUNGE_KUTTA4,
00120     RUNGE_KUTTA45,
00121     NONE,
00122     UNKNOWN
00123   };
00124 
00125   enum ReasonForTermination
00126   {
00127     OUT_OF_DOMAIN = vtkInitialValueProblemSolver::OUT_OF_DOMAIN,
00128     NOT_INITIALIZED = vtkInitialValueProblemSolver::NOT_INITIALIZED ,
00129     UNEXPECTED_VALUE = vtkInitialValueProblemSolver::UNEXPECTED_VALUE,
00130     OUT_OF_TIME = 4,
00131     OUT_OF_STEPS = 5,
00132     STAGNATION = 6
00133   };
00134 //ETX
00135 
00137 
00143   void SetIntegrator(vtkInitialValueProblemSolver *);
00144   vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00145   void SetIntegratorType(int type);
00146   int GetIntegratorType();
00147   void SetIntegratorTypeToRungeKutta2()
00148     {this->SetIntegratorType(RUNGE_KUTTA2);};
00149   void SetIntegratorTypeToRungeKutta4()
00150     {this->SetIntegratorType(RUNGE_KUTTA4);};
00151   void SetIntegratorTypeToRungeKutta45()
00152     {this->SetIntegratorType(RUNGE_KUTTA45);};
00154 
00156 
00158   void SetMaximumPropagation(int unit, double max);
00159   void SetMaximumPropagation(double max);
00160   void SetMaximumPropagationUnit(int unit);
00161   int GetMaximumPropagationUnit();
00162   double GetMaximumPropagation();
00163   void SetMaximumPropagationUnitToTimeUnit()
00164     {this->SetMaximumPropagationUnit(TIME_UNIT);};
00165   void SetMaximumPropagationUnitToLengthUnit()
00166     {this->SetMaximumPropagationUnit(LENGTH_UNIT);};
00167   void SetMaximumPropagationUnitToCellLengthUnit()
00168     {this->SetMaximumPropagationUnit(CELL_LENGTH_UNIT);};          
00170 
00172 
00175   void SetMinimumIntegrationStep(int unit, double step);
00176   void SetMinimumIntegrationStepUnit(int unit);
00177   void SetMinimumIntegrationStep(double step);
00178   int GetMinimumIntegrationStepUnit();
00179   double GetMinimumIntegrationStep();
00180   void SetMinimumIntegrationStepUnitToTimeUnit()
00181     {this->SetMinimumIntegrationStepUnit(TIME_UNIT);};
00182   void SetMinimumIntegrationStepUnitToLengthUnit()
00183     {this->SetMinimumIntegrationStepUnit(LENGTH_UNIT);};
00184   void SetMinimumIntegrationStepUnitToCellLengthUnit()
00185     {this->SetMinimumIntegrationStepUnit(CELL_LENGTH_UNIT);};
00187 
00189 
00192   void SetMaximumIntegrationStep(int unit, double step);
00193   void SetMaximumIntegrationStepUnit(int unit);
00194   void SetMaximumIntegrationStep(double step);
00195   int GetMaximumIntegrationStepUnit();
00196   double GetMaximumIntegrationStep();
00197   void SetMaximumIntegrationStepUnitToTimeUnit()
00198     {this->SetMaximumIntegrationStepUnit(TIME_UNIT);};
00199   void SetMaximumIntegrationStepUnitToLengthUnit()
00200     {this->SetMaximumIntegrationStepUnit(LENGTH_UNIT);};
00201   void SetMaximumIntegrationStepUnitToCellLengthUnit()
00202     {this->SetMaximumIntegrationStepUnit(CELL_LENGTH_UNIT);};
00204 
00206 
00209   void SetInitialIntegrationStep(int unit, double step);
00210   void SetInitialIntegrationStepUnit(int unit);
00211   void SetInitialIntegrationStep(double step);
00212   int GetInitialIntegrationStepUnit();
00213   double GetInitialIntegrationStep();
00214   void SetInitialIntegrationStepUnitToTimeUnit()
00215     {this->SetInitialIntegrationStepUnit(TIME_UNIT);};
00216   void SetInitialIntegrationStepUnitToLengthUnit()
00217     {this->SetInitialIntegrationStepUnit(LENGTH_UNIT);};
00218   void SetInitialIntegrationStepUnitToCellLengthUnit()
00219     {this->SetInitialIntegrationStepUnit(CELL_LENGTH_UNIT);};
00221 
00223 
00226   vtkSetMacro(MaximumError, double);
00227   vtkGetMacro(MaximumError, double);
00229 
00231 
00232   vtkSetMacro(MaximumNumberOfSteps, vtkIdType);
00233   vtkGetMacro(MaximumNumberOfSteps, vtkIdType);
00235 
00237 
00239   vtkSetMacro(TerminalSpeed, double);
00240   vtkGetMacro(TerminalSpeed, double);
00242 
00243 //BTX
00244   enum
00245   {
00246     FORWARD,
00247     BACKWARD,
00248     BOTH
00249   };
00250 //ETX
00251 
00253 
00255   vtkSetClampMacro(IntegrationDirection, int, FORWARD, BOTH);
00256   vtkGetMacro(IntegrationDirection, int);
00257   void SetIntegrationDirectionToForward()
00258     {this->SetIntegrationDirection(FORWARD);};
00259   void SetIntegrationDirectionToBackward()
00260     {this->SetIntegrationDirection(BACKWARD);};
00261   void SetIntegrationDirectionToBoth()
00262     {this->SetIntegrationDirection(BOTH);};  
00264 
00266 
00268   vtkSetMacro(ComputeVorticity, int);
00269   vtkGetMacro(ComputeVorticity, int);
00270   vtkBooleanMacro(ComputeVorticity, int);
00272 
00274 
00276   vtkSetMacro(RotationScale, double);
00277   vtkGetMacro(RotationScale, double);
00279 
00281 
00284   vtkGetStringMacro(InputVectorsSelection);
00285   void SelectInputVectors(const char *fieldName) 
00286     {this->SetInputVectorsSelection(fieldName);}
00288   
00290   void AddInput(vtkDataSet *in);
00291 
00292 protected:
00293 
00294   vtkStreamTracer();
00295   ~vtkStreamTracer();
00296 
00297   // hide the superclass' AddInput() from the user and the compiler
00298   void AddInput(vtkDataObject *) 
00299     { vtkErrorMacro( << "AddInput() must be called with a vtkDataSet not a vtkDataObject."); };
00300   
00301   void Execute();
00302   void CalculateVorticity( vtkGenericCell* cell, double pcoords[3],
00303                            vtkDoubleArray* cellVectors, double vorticity[3] );
00304   void Integrate(vtkPolyData* output,
00305                  vtkDataArray* seedSource, 
00306                  vtkIdList* seedIds,
00307                  vtkIntArray* integrationDirections,
00308                  double lastPoint[3],
00309                  vtkInterpolatedVelocityField* func,
00310                  int maxCellSize);
00311   void SimpleIntegrate(double seed[3], 
00312                        double lastPoint[3], 
00313                        double delt,
00314                        vtkInterpolatedVelocityField* func);
00315   int CheckInputs(vtkInterpolatedVelocityField*& func,
00316                   int* maxCellSize);
00317   void GenerateNormals(vtkPolyData* output, double* firstNormal);
00318 
00319   int GenerateNormalsInIntegrate;
00320 
00321   vtkSetStringMacro(InputVectorsSelection);
00322   char *InputVectorsSelection;
00323 
00324 
00325   // starting from global x-y-z position
00326   double StartPosition[3];
00327 
00328   static const double EPSILON;
00329   double TerminalSpeed;
00330 
00331   double LastUsedTimeStep;
00332 
00333 //BTX
00334   struct IntervalInformation
00335   {
00336     double Interval;
00337     int Unit;
00338   };
00339 
00340   IntervalInformation MaximumPropagation;
00341   IntervalInformation MinimumIntegrationStep;
00342   IntervalInformation MaximumIntegrationStep;
00343   IntervalInformation InitialIntegrationStep;
00344 
00345   void SetIntervalInformation(int unit, double interval,
00346                               IntervalInformation& currentValues);
00347   void SetIntervalInformation(int unit,IntervalInformation& currentValues);
00348   static double ConvertToTime(IntervalInformation& interval,
00349                              double cellLength, double speed);
00350   static double ConvertToLength(IntervalInformation& interval,
00351                                double cellLength, double speed);
00352   static double ConvertToCellLength(IntervalInformation& interval,
00353                                    double cellLength, double speed);
00354   static double ConvertToUnit(IntervalInformation& interval, int unit,
00355                              double cellLength, double speed);
00356   void ConvertIntervals(double& step, double& minStep, double& maxStep,
00357                         int direction, double cellLength, double speed);
00358 //ETX
00359 
00360   void InitializeSeeds(vtkDataArray*& seeds,
00361                        vtkIdList*& seedIds,
00362                        vtkIntArray*& integrationDirections);
00363   
00364   int IntegrationDirection;
00365 
00366   // Prototype showing the integrator type to be set by the user.
00367   vtkInitialValueProblemSolver* Integrator;
00368 
00369   double MaximumError;
00370   vtkIdType MaximumNumberOfSteps;
00371 
00372   int ComputeVorticity;
00373   double RotationScale;
00374 
00375 private:
00376   vtkStreamTracer(const vtkStreamTracer&);  // Not implemented.
00377   void operator=(const vtkStreamTracer&);  // Not implemented.
00378 };
00379 
00380 
00381 #endif
00382 
00383