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