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