VTK
dox/Filters/Generic/vtkGenericStreamTracer.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkGenericStreamTracer.h
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 __vtkGenericStreamTracer_h
00069 #define __vtkGenericStreamTracer_h
00070 
00071 #include "vtkFiltersGenericModule.h" // For export macro
00072 #include "vtkPolyDataAlgorithm.h"
00073 
00074 #include "vtkInitialValueProblemSolver.h" // Needed for constants
00075 
00076 class vtkDataArray;
00077 class vtkGenericAdaptorCell;
00078 class vtkIdList;
00079 class vtkIntArray;
00080 class vtkGenericInterpolatedVelocityField;
00081 class vtkDataSet;
00082 class vtkGenericAttribute;
00083 class vtkGenericDataSet;
00084 
00085 class VTKFILTERSGENERIC_EXPORT vtkGenericStreamTracer : public vtkPolyDataAlgorithm
00086 {
00087 public:
00088   vtkTypeMacro(vtkGenericStreamTracer,vtkPolyDataAlgorithm);
00089   void PrintSelf(ostream& os, vtkIndent indent);
00090 
00095   static vtkGenericStreamTracer *New();
00096 
00098 
00101   vtkSetVector3Macro(StartPosition, double);
00102   vtkGetVector3Macro(StartPosition, double);
00104 
00106 
00107   void SetSourceData(vtkDataSet *source);
00108   vtkDataSet *GetSource();
00110 
00113   void SetSourceConnection(vtkAlgorithmOutput* algOutput);
00114 
00115   int FillInputPortInformation(int port, vtkInformation* info);
00116 
00117 //BTX
00118   enum Units
00119   {
00120     TIME_UNIT,
00121     LENGTH_UNIT,
00122     CELL_LENGTH_UNIT
00123   };
00124 
00125   enum Solvers
00126   {
00127     RUNGE_KUTTA2,
00128     RUNGE_KUTTA4,
00129     RUNGE_KUTTA45,
00130     NONE,
00131     UNKNOWN
00132   };
00133 
00134   enum ReasonForTermination
00135   {
00136     OUT_OF_DOMAIN = vtkInitialValueProblemSolver::OUT_OF_DOMAIN,
00137     NOT_INITIALIZED = vtkInitialValueProblemSolver::NOT_INITIALIZED ,
00138     UNEXPECTED_VALUE = vtkInitialValueProblemSolver::UNEXPECTED_VALUE,
00139     OUT_OF_TIME = 4,
00140     OUT_OF_STEPS = 5,
00141     STAGNATION = 6
00142   };
00143 //ETX
00144 
00146 
00152   void SetIntegrator(vtkInitialValueProblemSolver *);
00153   vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00154   void SetIntegratorType(int type);
00155   int GetIntegratorType();
00156   void SetIntegratorTypeToRungeKutta2()
00157     {this->SetIntegratorType(RUNGE_KUTTA2);};
00158   void SetIntegratorTypeToRungeKutta4()
00159     {this->SetIntegratorType(RUNGE_KUTTA4);};
00160   void SetIntegratorTypeToRungeKutta45()
00161     {this->SetIntegratorType(RUNGE_KUTTA45);};
00163 
00165 
00167   void SetMaximumPropagation(int unit, double max);
00168   void SetMaximumPropagation(double max);
00169   void SetMaximumPropagationUnit(int unit);
00170   int GetMaximumPropagationUnit();
00171   double GetMaximumPropagation();
00172   void SetMaximumPropagationUnitToTimeUnit()
00173     {this->SetMaximumPropagationUnit(TIME_UNIT);};
00174   void SetMaximumPropagationUnitToLengthUnit()
00175     {this->SetMaximumPropagationUnit(LENGTH_UNIT);};
00176   void SetMaximumPropagationUnitToCellLengthUnit()
00177     {this->SetMaximumPropagationUnit(CELL_LENGTH_UNIT);};
00179 
00181 
00184   void SetMinimumIntegrationStep(int unit, double step);
00185   void SetMinimumIntegrationStepUnit(int unit);
00186   void SetMinimumIntegrationStep(double step);
00187   int GetMinimumIntegrationStepUnit();
00188   double GetMinimumIntegrationStep();
00189   void SetMinimumIntegrationStepUnitToTimeUnit()
00190     {this->SetMinimumIntegrationStepUnit(TIME_UNIT);};
00191   void SetMinimumIntegrationStepUnitToLengthUnit()
00192     {this->SetMinimumIntegrationStepUnit(LENGTH_UNIT);};
00193   void SetMinimumIntegrationStepUnitToCellLengthUnit()
00194     {this->SetMinimumIntegrationStepUnit(CELL_LENGTH_UNIT);};
00196 
00198 
00201   void SetMaximumIntegrationStep(int unit, double step);
00202   void SetMaximumIntegrationStepUnit(int unit);
00203   void SetMaximumIntegrationStep(double step);
00204   int GetMaximumIntegrationStepUnit();
00205   double GetMaximumIntegrationStep();
00206   void SetMaximumIntegrationStepUnitToTimeUnit()
00207     {this->SetMaximumIntegrationStepUnit(TIME_UNIT);};
00208   void SetMaximumIntegrationStepUnitToLengthUnit()
00209     {this->SetMaximumIntegrationStepUnit(LENGTH_UNIT);};
00210   void SetMaximumIntegrationStepUnitToCellLengthUnit()
00211     {this->SetMaximumIntegrationStepUnit(CELL_LENGTH_UNIT);};
00213 
00215 
00218   void SetInitialIntegrationStep(int unit, double step);
00219   void SetInitialIntegrationStepUnit(int unit);
00220   void SetInitialIntegrationStep(double step);
00221   int GetInitialIntegrationStepUnit();
00222   double GetInitialIntegrationStep();
00223   void SetInitialIntegrationStepUnitToTimeUnit()
00224     {this->SetInitialIntegrationStepUnit(TIME_UNIT);};
00225   void SetInitialIntegrationStepUnitToLengthUnit()
00226     {this->SetInitialIntegrationStepUnit(LENGTH_UNIT);};
00227   void SetInitialIntegrationStepUnitToCellLengthUnit()
00228     {this->SetInitialIntegrationStepUnit(CELL_LENGTH_UNIT);};
00230 
00232 
00235   vtkSetMacro(MaximumError, double);
00236   vtkGetMacro(MaximumError, double);
00238 
00240 
00241   vtkSetMacro(MaximumNumberOfSteps, vtkIdType);
00242   vtkGetMacro(MaximumNumberOfSteps, vtkIdType);
00244 
00246 
00248   vtkSetMacro(TerminalSpeed, double);
00249   vtkGetMacro(TerminalSpeed, double);
00251 
00253 
00255   void SetIntegrationStepUnit(int unit)
00256     {
00257     this->SetInitialIntegrationStepUnit(unit);
00258     this->SetMinimumIntegrationStepUnit(unit);
00259     this->SetMaximumIntegrationStepUnit(unit);
00260     }
00262 
00263 //BTX
00264   enum
00265   {
00266     FORWARD,
00267     BACKWARD,
00268     BOTH
00269   };
00270 //ETX
00271 
00273 
00275   vtkSetClampMacro(IntegrationDirection, int, FORWARD, BOTH);
00276   vtkGetMacro(IntegrationDirection, int);
00277   void SetIntegrationDirectionToForward()
00278     {this->SetIntegrationDirection(FORWARD);};
00279   void SetIntegrationDirectionToBackward()
00280     {this->SetIntegrationDirection(BACKWARD);};
00281   void SetIntegrationDirectionToBoth()
00282     {this->SetIntegrationDirection(BOTH);};
00284 
00286 
00288   vtkSetMacro(ComputeVorticity, int);
00289   vtkGetMacro(ComputeVorticity, int);
00290   vtkBooleanMacro(ComputeVorticity, int);
00292 
00294 
00296   vtkSetMacro(RotationScale, double);
00297   vtkGetMacro(RotationScale, double);
00299 
00301 
00304   vtkGetStringMacro(InputVectorsSelection);
00305   void SelectInputVectors(const char *fieldName)
00306     {this->SetInputVectorsSelection(fieldName);}
00308 
00310   void AddInputData(vtkGenericDataSet *in);
00311 
00314   void SetInterpolatorPrototype(vtkGenericInterpolatedVelocityField* ivf);
00315 
00316 protected:
00317   vtkGenericStreamTracer();
00318   ~vtkGenericStreamTracer();
00319 
00320   // hide the superclass' AddInput() from the user and the compiler
00321   void AddInput(vtkDataObject *)
00322     { vtkErrorMacro( << "AddInput() must be called with a vtkGenericDataSet not a vtkDataObject."); };
00323 
00324   int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00325 
00327 
00332   void CalculateVorticity(vtkGenericAdaptorCell* cell,
00333                           double pcoords[3],
00334                           vtkGenericAttribute *attribute,
00335                           double vorticity[3]);
00337 
00338   void Integrate(vtkGenericDataSet *input0,
00339                  vtkPolyData* output,
00340                  vtkDataArray* seedSource,
00341                  vtkIdList* seedIds,
00342                  vtkIntArray* integrationDirections,
00343                  double lastPoint[3],
00344                  vtkGenericInterpolatedVelocityField* func);
00345   void SimpleIntegrate(double seed[3],
00346                        double lastPoint[3],
00347                        double delt,
00348                        vtkGenericInterpolatedVelocityField* func);
00349   int CheckInputs(vtkGenericInterpolatedVelocityField*& func,
00350     vtkInformationVector **inputVector);
00351   void GenerateNormals(vtkPolyData* output, double* firstNormal);
00352 
00353   int GenerateNormalsInIntegrate;
00354 
00355   vtkSetStringMacro(InputVectorsSelection);
00356   char *InputVectorsSelection;
00357 
00358 
00359   // starting from global x-y-z position
00360   double StartPosition[3];
00361 
00362   static const double EPSILON;
00363   double TerminalSpeed;
00364 
00365   double LastUsedTimeStep;
00366 
00367 //BTX
00368   struct IntervalInformation
00369   {
00370     double Interval;
00371     int Unit;
00372   };
00373 
00374   IntervalInformation MaximumPropagation;
00375   IntervalInformation MinimumIntegrationStep;
00376   IntervalInformation MaximumIntegrationStep;
00377   IntervalInformation InitialIntegrationStep;
00378 
00379   void SetIntervalInformation(int unit, double interval,
00380                               IntervalInformation& currentValues);
00381   void SetIntervalInformation(int unit,IntervalInformation& currentValues);
00382   static double ConvertToTime(IntervalInformation& interval,
00383                              double cellLength, double speed);
00384   static double ConvertToLength(IntervalInformation& interval,
00385                                double cellLength, double speed);
00386   static double ConvertToCellLength(IntervalInformation& interval,
00387                                    double cellLength, double speed);
00388   static double ConvertToUnit(IntervalInformation& interval, int unit,
00389                              double cellLength, double speed);
00390   void ConvertIntervals(double& step, double& minStep, double& maxStep,
00391                         int direction, double cellLength, double speed);
00392 //ETX
00393 
00394   void InitializeSeeds(vtkDataArray*& seeds,
00395                        vtkIdList*& seedIds,
00396                        vtkIntArray*& integrationDirections);
00397 
00398   int IntegrationDirection;
00399 
00400   // Prototype showing the integrator type to be set by the user.
00401   vtkInitialValueProblemSolver* Integrator;
00402 
00403   double MaximumError;
00404   vtkIdType MaximumNumberOfSteps;
00405 
00406   int ComputeVorticity;
00407   double RotationScale;
00408 
00409   vtkGenericInterpolatedVelocityField* InterpolatorPrototype;
00410 
00411 private:
00412   vtkGenericStreamTracer(const vtkGenericStreamTracer&);  // Not implemented.
00413   void operator=(const vtkGenericStreamTracer&);  // Not implemented.
00414 };
00415 
00416 #endif