Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound 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   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 =========================================================================*/
00083 #ifndef __vtkStreamTracer_h
00084 #define __vtkStreamTracer_h
00085 
00086 #include "vtkDataSetToPolyDataFilter.h"
00087 
00088 #include "vtkInitialValueProblemSolver.h" // Needed for constants
00089 
00090 class vtkDataArray;
00091 class vtkFloatArray;
00092 class vtkGenericCell;
00093 class vtkIdList;
00094 class vtkIntArray;
00095 class vtkInterpolatedVelocityField;
00096 
00097 class VTK_GRAPHICS_EXPORT vtkStreamTracer : public vtkDataSetToPolyDataFilter
00098 {
00099 public:
00100   vtkTypeRevisionMacro(vtkStreamTracer,vtkDataSetToPolyDataFilter);
00101   void PrintSelf(ostream& os, vtkIndent indent);
00102 
00107   static vtkStreamTracer *New();
00108   
00110 
00113   vtkSetVector3Macro(StartPosition, float);
00114   vtkGetVector3Macro(StartPosition, float);
00116 
00118 
00119   void SetSource(vtkDataSet *source);
00120   vtkDataSet *GetSource();
00122 
00123 //BTX
00124   enum Units
00125   {
00126     TIME_UNIT,
00127     LENGTH_UNIT,
00128     CELL_LENGTH_UNIT
00129   };
00130 
00131   enum Solvers
00132   {
00133     RUNGE_KUTTA2,
00134     RUNGE_KUTTA4,
00135     RUNGE_KUTTA45,
00136     NONE,
00137     UNKNOWN
00138   };
00139 
00140   enum ReasonForTermination
00141   {
00142     OUT_OF_DOMAIN = vtkInitialValueProblemSolver::OUT_OF_DOMAIN,
00143     NOT_INITIALIZED = vtkInitialValueProblemSolver::NOT_INITIALIZED ,
00144     UNEXPECTED_VALUE = vtkInitialValueProblemSolver::UNEXPECTED_VALUE,
00145     OUT_OF_TIME = 4,
00146     OUT_OF_STEPS = 5,
00147     STAGNATION = 6
00148   };
00149 //ETX
00150 
00152 
00158   void SetIntegrator(vtkInitialValueProblemSolver *);
00159   vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00160   void SetIntegratorType(int type);
00161   int GetIntegratorType();
00162   void SetIntegratorTypeToRungeKutta2()
00163     {this->SetIntegratorType(RUNGE_KUTTA2);};
00164   void SetIntegratorTypeToRungeKutta4()
00165     {this->SetIntegratorType(RUNGE_KUTTA4);};
00166   void SetIntegratorTypeToRungeKutta45()
00167     {this->SetIntegratorType(RUNGE_KUTTA45);};
00169 
00171 
00173   void SetMaximumPropagation(int unit, float max);
00174   void SetMaximumPropagation(float max);
00175   void SetMaximumPropagationUnit(int unit);
00176   int GetMaximumPropagationUnit();
00177   float GetMaximumPropagation();
00178   void SetMaximumPropagationUnitToTimeUnit()
00179     {this->SetMaximumPropagationUnit(TIME_UNIT);};
00180   void SetMaximumPropagationUnitToLengthUnit()
00181     {this->SetMaximumPropagationUnit(LENGTH_UNIT);};
00182   void SetMaximumPropagationUnitToCellLengthUnit()
00183     {this->SetMaximumPropagationUnit(CELL_LENGTH_UNIT);};          
00185 
00187 
00190   void SetMinimumIntegrationStep(int unit, float step);
00191   void SetMinimumIntegrationStepUnit(int unit);
00192   void SetMinimumIntegrationStep(float step);
00193   int GetMinimumIntegrationStepUnit();
00194   float GetMinimumIntegrationStep();
00195   void SetMinimumIntegrationStepUnitToTimeUnit()
00196     {this->SetMinimumIntegrationStepUnit(TIME_UNIT);};
00197   void SetMinimumIntegrationStepUnitToLengthUnit()
00198     {this->SetMinimumIntegrationStepUnit(LENGTH_UNIT);};
00199   void SetMinimumIntegrationStepUnitToCellLengthUnit()
00200     {this->SetMinimumIntegrationStepUnit(CELL_LENGTH_UNIT);};
00202 
00204 
00207   void SetMaximumIntegrationStep(int unit, float step);
00208   void SetMaximumIntegrationStepUnit(int unit);
00209   void SetMaximumIntegrationStep(float step);
00210   int GetMaximumIntegrationStepUnit();
00211   float GetMaximumIntegrationStep();
00212   void SetMaximumIntegrationStepUnitToTimeUnit()
00213     {this->SetMaximumIntegrationStepUnit(TIME_UNIT);};
00214   void SetMaximumIntegrationStepUnitToLengthUnit()
00215     {this->SetMaximumIntegrationStepUnit(LENGTH_UNIT);};
00216   void SetMaximumIntegrationStepUnitToCellLengthUnit()
00217     {this->SetMaximumIntegrationStepUnit(CELL_LENGTH_UNIT);};
00219 
00221 
00224   void SetInitialIntegrationStep(int unit, float step);
00225   void SetInitialIntegrationStepUnit(int unit);
00226   void SetInitialIntegrationStep(float step);
00227   int GetInitialIntegrationStepUnit();
00228   float GetInitialIntegrationStep();
00229   void SetInitialIntegrationStepUnitToTimeUnit()
00230     {this->SetInitialIntegrationStepUnit(TIME_UNIT);};
00231   void SetInitialIntegrationStepUnitToLengthUnit()
00232     {this->SetInitialIntegrationStepUnit(LENGTH_UNIT);};
00233   void SetInitialIntegrationStepUnitToCellLengthUnit()
00234     {this->SetInitialIntegrationStepUnit(CELL_LENGTH_UNIT);};
00236 
00238 
00241   vtkSetMacro(MaximumError, float);
00242   vtkGetMacro(MaximumError, float);
00244 
00246 
00247   vtkSetMacro(MaximumNumberOfSteps, vtkIdType);
00248   vtkGetMacro(MaximumNumberOfSteps, vtkIdType);
00250 
00252 
00254   vtkSetMacro(TerminalSpeed, float);
00255   vtkGetMacro(TerminalSpeed, float);
00257 
00258 //BTX
00259   enum
00260   {
00261     FORWARD,
00262     BACKWARD,
00263     BOTH
00264   };
00265 //ETX
00266 
00268 
00270   vtkSetClampMacro(IntegrationDirection, int, FORWARD, BOTH);
00271   vtkGetMacro(IntegrationDirection, int);
00272   void SetIntegrationDirectionToForward()
00273     {this->SetIntegrationDirection(FORWARD);};
00274   void SetIntegrationDirectionToBackward()
00275     {this->SetIntegrationDirection(BACKWARD);};
00276   void SetIntegrationDirectionToBoth()
00277     {this->SetIntegrationDirection(BOTH);};  
00279 
00281 
00283   vtkSetMacro(ComputeVorticity, int);
00284   vtkGetMacro(ComputeVorticity, int);
00285   vtkBooleanMacro(ComputeVorticity, int);
00287 
00289 
00291   vtkSetMacro(RotationScale, float);
00292   vtkGetMacro(RotationScale, float);
00294 
00296   void AddInput(vtkDataSet *in);
00297 
00298 protected:
00299 
00300   vtkStreamTracer();
00301   ~vtkStreamTracer();
00302 
00303   // hide the superclass' AddInput() from the user and the compiler
00304   void AddInput(vtkDataObject *) 
00305     { vtkErrorMacro( << "AddInput() must be called with a vtkDataSet not a vtkDataObject."); };
00306   
00307   void Execute();
00308   void CalculateVorticity( vtkGenericCell* cell, float pcoords[3],
00309                            vtkFloatArray* cellVectors, float vorticity[3] );
00310   void Integrate(vtkPolyData* output,
00311                  vtkDataArray* seedSource, 
00312                  vtkIdList* seedIds,
00313                  vtkIntArray* integrationDirections,
00314                  float lastPoint[3]);
00315   int CheckInputs(vtkInterpolatedVelocityField*& func,
00316                   int* maxCellSize);
00317 
00318   vtkSetStringMacro(InputVectorsSelection);
00319   char *InputVectorsSelection;
00320 
00321 
00322   // starting from global x-y-z position
00323   float StartPosition[3];
00324 
00325   static const float EPSILON;
00326   float TerminalSpeed;
00327 
00328 //BTX
00329   struct IntervalInformation
00330   {
00331     float Interval;
00332     int Unit;
00333   };
00334 
00335   IntervalInformation MaximumPropagation;
00336   IntervalInformation MinimumIntegrationStep;
00337   IntervalInformation MaximumIntegrationStep;
00338   IntervalInformation InitialIntegrationStep;
00339 
00340   void SetIntervalInformation(int unit, float interval,
00341                               IntervalInformation& currentValues);
00342   void SetIntervalInformation(int unit,IntervalInformation& currentValues);
00343   static float ConvertToTime(IntervalInformation& interval,
00344                              float cellLength, float speed);
00345   static float ConvertToLength(IntervalInformation& interval,
00346                                float cellLength, float speed);
00347   static float ConvertToCellLength(IntervalInformation& interval,
00348                                    float cellLength, float speed);
00349   static float ConvertToUnit(IntervalInformation& interval, int unit,
00350                              float cellLength, float speed);
00351   void ConvertIntervals(float& step, float& minStep, float& maxStep,
00352                         int direction, float cellLength, float speed);
00353 //ETX
00354 
00355   void InitializeSeeds(vtkDataArray*& seeds,
00356                        vtkIdList*& seedIds,
00357                        vtkIntArray*& integrationDirections);
00358   
00359   int IntegrationDirection;
00360 
00361   // Prototype showing the integrator type to be set by the user.
00362   vtkInitialValueProblemSolver* Integrator;
00363 
00364   float MaximumError;
00365   vtkIdType MaximumNumberOfSteps;
00366 
00367   int ComputeVorticity;
00368   float RotationScale;
00369 
00370 private:
00371   vtkStreamTracer(const vtkStreamTracer&);  // Not implemented.
00372   void operator=(const vtkStreamTracer&);  // Not implemented.
00373 };
00374 
00375 
00376 #endif
00377 
00378