00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00068 #ifndef __vtkGenericStreamTracer_h
00069 #define __vtkGenericStreamTracer_h
00070
00071 #include "vtkPolyDataAlgorithm.h"
00072
00073 #include "vtkInitialValueProblemSolver.h"
00074
00075 class vtkDataArray;
00076 class vtkGenericAdaptorCell;
00077 class vtkIdList;
00078 class vtkIntArray;
00079 class vtkGenericInterpolatedVelocityField;
00080 class vtkDataSet;
00081 class vtkGenericAttribute;
00082 class vtkGenericDataSet;
00083
00084 class VTK_GENERIC_FILTERING_EXPORT vtkGenericStreamTracer : public vtkPolyDataAlgorithm
00085 {
00086 public:
00087 vtkTypeRevisionMacro(vtkGenericStreamTracer,vtkPolyDataAlgorithm);
00088 void PrintSelf(ostream& os, vtkIndent indent);
00089
00094 static vtkGenericStreamTracer *New();
00095
00097
00100 vtkSetVector3Macro(StartPosition, double);
00101 vtkGetVector3Macro(StartPosition, double);
00103
00105
00106 void SetSource(vtkDataSet *source);
00107 vtkDataSet *GetSource();
00109
00110 int FillInputPortInformation(int port, vtkInformation* info);
00111
00112
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
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, double max);
00163 void SetMaximumPropagation(double max);
00164 void SetMaximumPropagationUnit(int unit);
00165 int GetMaximumPropagationUnit();
00166 double 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, double step);
00180 void SetMinimumIntegrationStepUnit(int unit);
00181 void SetMinimumIntegrationStep(double step);
00182 int GetMinimumIntegrationStepUnit();
00183 double 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, double step);
00197 void SetMaximumIntegrationStepUnit(int unit);
00198 void SetMaximumIntegrationStep(double step);
00199 int GetMaximumIntegrationStepUnit();
00200 double 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, double step);
00214 void SetInitialIntegrationStepUnit(int unit);
00215 void SetInitialIntegrationStep(double step);
00216 int GetInitialIntegrationStepUnit();
00217 double 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, double);
00231 vtkGetMacro(MaximumError, double);
00233
00235
00236 vtkSetMacro(MaximumNumberOfSteps, vtkIdType);
00237 vtkGetMacro(MaximumNumberOfSteps, vtkIdType);
00239
00241
00243 vtkSetMacro(TerminalSpeed, double);
00244 vtkGetMacro(TerminalSpeed, double);
00246
00247
00248 enum
00249 {
00250 FORWARD,
00251 BACKWARD,
00252 BOTH
00253 };
00254
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, double);
00281 vtkGetMacro(RotationScale, double);
00283
00285
00288 vtkGetStringMacro(InputVectorsSelection);
00289 void SelectInputVectors(const char *fieldName)
00290 {this->SetInputVectorsSelection(fieldName);}
00292
00294 void AddInput(vtkGenericDataSet *in);
00295
00298 void SetInterpolatorPrototype(vtkGenericInterpolatedVelocityField* ivf);
00299
00300 protected:
00301 vtkGenericStreamTracer();
00302 ~vtkGenericStreamTracer();
00303
00304
00305 void AddInput(vtkDataObject *)
00306 { vtkErrorMacro( << "AddInput() must be called with a vtkGenericDataSet not a vtkDataObject."); };
00307
00308 int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00309
00311
00316 void CalculateVorticity(vtkGenericAdaptorCell* cell,
00317 double pcoords[3],
00318 vtkGenericAttribute *attribute,
00319 double vorticity[3]);
00321
00322 void Integrate(vtkGenericDataSet *input0,
00323 vtkPolyData* output,
00324 vtkDataArray* seedSource,
00325 vtkIdList* seedIds,
00326 vtkIntArray* integrationDirections,
00327 double lastPoint[3],
00328 vtkGenericInterpolatedVelocityField* func);
00329 void SimpleIntegrate(double seed[3],
00330 double lastPoint[3],
00331 double delt,
00332 vtkGenericInterpolatedVelocityField* func);
00333 int CheckInputs(vtkGenericInterpolatedVelocityField*& func,
00334 vtkInformationVector **inputVector);
00335 void GenerateNormals(vtkPolyData* output, double* firstNormal);
00336
00337 int GenerateNormalsInIntegrate;
00338
00339 vtkSetStringMacro(InputVectorsSelection);
00340 char *InputVectorsSelection;
00341
00342
00343
00344 double StartPosition[3];
00345
00346 static const double EPSILON;
00347 double TerminalSpeed;
00348
00349 double LastUsedTimeStep;
00350
00351
00352 struct IntervalInformation
00353 {
00354 double Interval;
00355 int Unit;
00356 };
00357
00358 IntervalInformation MaximumPropagation;
00359 IntervalInformation MinimumIntegrationStep;
00360 IntervalInformation MaximumIntegrationStep;
00361 IntervalInformation InitialIntegrationStep;
00362
00363 void SetIntervalInformation(int unit, double interval,
00364 IntervalInformation& currentValues);
00365 void SetIntervalInformation(int unit,IntervalInformation& currentValues);
00366 static double ConvertToTime(IntervalInformation& interval,
00367 double cellLength, double speed);
00368 static double ConvertToLength(IntervalInformation& interval,
00369 double cellLength, double speed);
00370 static double ConvertToCellLength(IntervalInformation& interval,
00371 double cellLength, double speed);
00372 static double ConvertToUnit(IntervalInformation& interval, int unit,
00373 double cellLength, double speed);
00374 void ConvertIntervals(double& step, double& minStep, double& maxStep,
00375 int direction, double cellLength, double speed);
00376
00377
00378 void InitializeSeeds(vtkDataArray*& seeds,
00379 vtkIdList*& seedIds,
00380 vtkIntArray*& integrationDirections);
00381
00382 int IntegrationDirection;
00383
00384
00385 vtkInitialValueProblemSolver* Integrator;
00386
00387 double MaximumError;
00388 vtkIdType MaximumNumberOfSteps;
00389
00390 int ComputeVorticity;
00391 double RotationScale;
00392
00393 vtkGenericInterpolatedVelocityField* InterpolatorPrototype;
00394
00395 private:
00396 vtkGenericStreamTracer(const vtkGenericStreamTracer&);
00397 void operator=(const vtkGenericStreamTracer&);
00398 };
00399
00400 #endif