VTK
dox/Graphics/vtkStreamTracer.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkStreamTracer.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 =========================================================================*/
00085 #ifndef __vtkStreamTracer_h
00086 #define __vtkStreamTracer_h
00087 
00088 #include "vtkPolyDataAlgorithm.h"
00089 
00090 #include "vtkInitialValueProblemSolver.h" // Needed for constants
00091 
00092 class vtkCompositeDataSet;
00093 class vtkDataArray;
00094 class vtkDoubleArray;
00095 class vtkExecutive;
00096 class vtkGenericCell;
00097 class vtkIdList;
00098 class vtkIntArray;
00099 class vtkAbstractInterpolatedVelocityField;
00100 
00101 class VTK_GRAPHICS_EXPORT vtkStreamTracer : public vtkPolyDataAlgorithm
00102 {
00103 public:
00104   vtkTypeMacro(vtkStreamTracer,vtkPolyDataAlgorithm);
00105   void PrintSelf(ostream& os, vtkIndent indent);
00106 
00112   static vtkStreamTracer *New();
00113 
00115 
00118   vtkSetVector3Macro(StartPosition, double);
00119   vtkGetVector3Macro(StartPosition, double);
00121 
00123 
00125   void SetSource(vtkDataSet *source);
00126   vtkDataSet *GetSource();
00128 
00131   void SetSourceConnection(vtkAlgorithmOutput* algOutput);
00132 
00133 //BTX
00134   // The previously-supported TIME_UNIT is excluded in this current
00135   // enumeration definition because the underlying step size is ALWAYS in
00136   // arc length unit (LENGTH_UNIT) while the 'real' time interval (virtual
00137   // for steady flows) that a particle actually takes to trave in a single
00138   // step is obtained by dividing the arc length by the LOCAL speed. The
00139   // overall elapsed time (i.e., the life span) of the particle is the sum
00140   // of those individual step-wise time intervals. The arc-length-to-time
00141   // convertion only occurs for vorticity computation and for generating a
00142   // point data array named 'IntegrationTime'.
00143   enum Units
00144   {
00145     LENGTH_UNIT = 1,
00146     CELL_LENGTH_UNIT = 2
00147   };
00148 
00149   enum Solvers
00150   {
00151     RUNGE_KUTTA2,
00152     RUNGE_KUTTA4,
00153     RUNGE_KUTTA45,
00154     NONE,
00155     UNKNOWN
00156   };
00157 
00158   enum ReasonForTermination
00159   {
00160     OUT_OF_DOMAIN = vtkInitialValueProblemSolver::OUT_OF_DOMAIN,
00161     NOT_INITIALIZED = vtkInitialValueProblemSolver::NOT_INITIALIZED ,
00162     UNEXPECTED_VALUE = vtkInitialValueProblemSolver::UNEXPECTED_VALUE,
00163     OUT_OF_LENGTH = 4,
00164     OUT_OF_STEPS = 5,
00165     STAGNATION = 6
00166   };
00167 //ETX
00168 
00170 
00176   void SetIntegrator(vtkInitialValueProblemSolver *);
00177   vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00178   void SetIntegratorType(int type);
00179   int GetIntegratorType();
00180   void SetIntegratorTypeToRungeKutta2()
00181     {this->SetIntegratorType(RUNGE_KUTTA2);};
00182   void SetIntegratorTypeToRungeKutta4()
00183     {this->SetIntegratorType(RUNGE_KUTTA4);};
00184   void SetIntegratorTypeToRungeKutta45()
00185     {this->SetIntegratorType(RUNGE_KUTTA45);};
00187 
00190   void SetInterpolatorTypeToDataSetPointLocator();
00191 
00194   void SetInterpolatorTypeToCellLocator();
00195 
00197 
00198   vtkSetMacro(MaximumPropagation, double);
00199   vtkGetMacro(MaximumPropagation, double);
00201 
00203 
00207   void SetIntegrationStepUnit( int unit );
00208   int  GetIntegrationStepUnit() { return this->IntegrationStepUnit; }
00210 
00212 
00216   vtkSetMacro(InitialIntegrationStep, double);
00217   vtkGetMacro(InitialIntegrationStep, double);
00219 
00221 
00224   vtkSetMacro(MinimumIntegrationStep, double);
00225   vtkGetMacro(MinimumIntegrationStep, double);
00227 
00229 
00232   vtkSetMacro(MaximumIntegrationStep, double);
00233   vtkGetMacro(MaximumIntegrationStep, double);
00235 
00237 
00239   vtkSetMacro(MaximumError, double);
00240   vtkGetMacro(MaximumError, double);
00242 
00244 
00245   vtkSetMacro(MaximumNumberOfSteps, vtkIdType);
00246   vtkGetMacro(MaximumNumberOfSteps, vtkIdType);
00248 
00250 
00252   vtkSetMacro(TerminalSpeed, double);
00253   vtkGetMacro(TerminalSpeed, double);
00255 
00256 //BTX
00257   enum
00258   {
00259     FORWARD,
00260     BACKWARD,
00261     BOTH
00262   };
00263 
00264   enum
00265   {
00266     INTERPOLATOR_WITH_DATASET_POINT_LOCATOR,
00267     INTERPOLATOR_WITH_CELL_LOCATOR
00268   };
00269 //ETX
00270 
00272 
00274   vtkSetClampMacro(IntegrationDirection, int, FORWARD, BOTH);
00275   vtkGetMacro(IntegrationDirection, int);
00276   void SetIntegrationDirectionToForward()
00277     {this->SetIntegrationDirection(FORWARD);};
00278   void SetIntegrationDirectionToBackward()
00279     {this->SetIntegrationDirection(BACKWARD);};
00280   void SetIntegrationDirectionToBoth()
00281     {this->SetIntegrationDirection(BOTH);};
00283 
00285 
00287   vtkSetMacro(ComputeVorticity, bool);
00288   vtkGetMacro(ComputeVorticity, bool);
00290 
00292 
00294   vtkSetMacro(RotationScale, double);
00295   vtkGetMacro(RotationScale, double);
00297 
00300   void SetInterpolatorPrototype( vtkAbstractInterpolatedVelocityField * ivf );
00301 
00311   void SetInterpolatorType( int interpType );
00312 
00313 protected:
00314 
00315   vtkStreamTracer();
00316   ~vtkStreamTracer();
00317 
00318   // Create a default executive.
00319   virtual vtkExecutive* CreateDefaultExecutive();
00320 
00321   // hide the superclass' AddInput() from the user and the compiler
00322   void AddInput(vtkDataObject *)
00323     { vtkErrorMacro( << "AddInput() must be called with a vtkDataSet not a vtkDataObject."); };
00324 
00325   virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00326   virtual int FillInputPortInformation(int, vtkInformation *);
00327 
00328   void CalculateVorticity( vtkGenericCell* cell, double pcoords[3],
00329                            vtkDoubleArray* cellVectors, double vorticity[3] );
00330   void Integrate(vtkDataSet *input,
00331                  vtkPolyData* output,
00332                  vtkDataArray* seedSource,
00333                  vtkIdList* seedIds,
00334                  vtkIntArray* integrationDirections,
00335                  double lastPoint[3],
00336                  vtkAbstractInterpolatedVelocityField* func,
00337                  int maxCellSize,
00338                  const char *vecFieldName,
00339                  double& propagation,
00340                  vtkIdType& numSteps);
00341   void SimpleIntegrate(double seed[3],
00342                        double lastPoint[3],
00343                        double stepSize,
00344                        vtkAbstractInterpolatedVelocityField* func);
00345   int CheckInputs(vtkAbstractInterpolatedVelocityField*& func,
00346                   int* maxCellSize);
00347   void GenerateNormals(vtkPolyData* output, double* firstNormal, const char *vecName);
00348 
00349   bool GenerateNormalsInIntegrate;
00350 
00351   // starting from global x-y-z position
00352   double StartPosition[3];
00353 
00354   static const double EPSILON;
00355   double TerminalSpeed;
00356 
00357   double LastUsedStepSize;
00358 
00359 //BTX
00360   struct IntervalInformation
00361   {
00362     double Interval;
00363     int Unit;
00364   };
00365 
00366   double MaximumPropagation;
00367   double MinimumIntegrationStep;
00368   double MaximumIntegrationStep;
00369   double InitialIntegrationStep;
00370 
00371   void ConvertIntervals( double& step, double& minStep, double& maxStep,
00372                         int direction, double cellLength );
00373   static double ConvertToLength( double interval, int unit, double cellLength );
00374   static double ConvertToLength( IntervalInformation& interval, double cellLength );
00375 
00376 //ETX
00377 
00378   int SetupOutput(vtkInformation* inInfo,
00379                   vtkInformation* outInfo);
00380   void InitializeSeeds(vtkDataArray*& seeds,
00381                        vtkIdList*& seedIds,
00382                        vtkIntArray*& integrationDirections,
00383                        vtkDataSet *source);
00384 
00385   int IntegrationStepUnit;
00386   int IntegrationDirection;
00387 
00388   // Prototype showing the integrator type to be set by the user.
00389   vtkInitialValueProblemSolver* Integrator;
00390 
00391   double MaximumError;
00392   vtkIdType MaximumNumberOfSteps;
00393 
00394   bool ComputeVorticity;
00395   double RotationScale;
00396 
00397   vtkAbstractInterpolatedVelocityField * InterpolatorPrototype;
00398 
00399   vtkCompositeDataSet* InputData;
00400 
00401 private:
00402   vtkStreamTracer(const vtkStreamTracer&);  // Not implemented.
00403   void operator=(const vtkStreamTracer&);  // Not implemented.
00404 };
00405 
00406 
00407 #endif
00408 
00409