00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00082 #ifndef __vtkStreamTracer_h
00083 #define __vtkStreamTracer_h
00084
00085 #include "vtkPolyDataAlgorithm.h"
00086
00087 #include "vtkInitialValueProblemSolver.h"
00088
00089 class vtkCompositeDataSet;
00090 class vtkDataArray;
00091 class vtkDoubleArray;
00092 class vtkExecutive;
00093 class vtkGenericCell;
00094 class vtkIdList;
00095 class vtkIntArray;
00096 class vtkAbstractInterpolatedVelocityField;
00097
00098 class VTK_GRAPHICS_EXPORT vtkStreamTracer : public vtkPolyDataAlgorithm
00099 {
00100 public:
00101 vtkTypeRevisionMacro(vtkStreamTracer,vtkPolyDataAlgorithm);
00102 void PrintSelf(ostream& os, vtkIndent indent);
00103
00109 static vtkStreamTracer *New();
00110
00112
00115 vtkSetVector3Macro(StartPosition, double);
00116 vtkGetVector3Macro(StartPosition, double);
00118
00120
00122 void SetSource(vtkDataSet *source);
00123 vtkDataSet *GetSource();
00125
00128 void SetSourceConnection(vtkAlgorithmOutput* algOutput);
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 enum Units
00141 {
00142 LENGTH_UNIT = 1,
00143 CELL_LENGTH_UNIT = 2
00144 };
00145
00146 enum Solvers
00147 {
00148 RUNGE_KUTTA2,
00149 RUNGE_KUTTA4,
00150 RUNGE_KUTTA45,
00151 NONE,
00152 UNKNOWN
00153 };
00154
00155 enum ReasonForTermination
00156 {
00157 OUT_OF_DOMAIN = vtkInitialValueProblemSolver::OUT_OF_DOMAIN,
00158 NOT_INITIALIZED = vtkInitialValueProblemSolver::NOT_INITIALIZED ,
00159 UNEXPECTED_VALUE = vtkInitialValueProblemSolver::UNEXPECTED_VALUE,
00160 OUT_OF_LENGTH = 4,
00161 OUT_OF_STEPS = 5,
00162 STAGNATION = 6
00163 };
00164
00165
00167
00173 void SetIntegrator(vtkInitialValueProblemSolver *);
00174 vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00175 void SetIntegratorType(int type);
00176 int GetIntegratorType();
00177 void SetIntegratorTypeToRungeKutta2()
00178 {this->SetIntegratorType(RUNGE_KUTTA2);};
00179 void SetIntegratorTypeToRungeKutta4()
00180 {this->SetIntegratorType(RUNGE_KUTTA4);};
00181 void SetIntegratorTypeToRungeKutta45()
00182 {this->SetIntegratorType(RUNGE_KUTTA45);};
00184
00187 void SetInterpolatorTypeToDataSetPointLocator();
00188
00191 void SetInterpolatorTypeToCellLocator();
00192
00194
00195 void SetMaximumPropagation(double max);
00196 double GetMaximumPropagation() { return this->MaximumPropagation; }
00198
00200
00204 void SetIntegrationStepUnit( int unit );
00205 int GetIntegrationStepUnit() { return this->IntegrationStepUnit; }
00207
00209
00213 void SetInitialIntegrationStep(double step);
00214 double GetInitialIntegrationStep() { return this->InitialIntegrationStep; }
00216
00218
00221 void SetMinimumIntegrationStep( double step );
00222 double GetMinimumIntegrationStep() { return this->MinimumIntegrationStep; }
00224
00226
00229 void SetMaximumIntegrationStep( double step );
00230 double GetMaximumIntegrationStep() { return this->MaximumIntegrationStep; }
00232
00234
00236 vtkSetMacro(MaximumError, double);
00237 vtkGetMacro(MaximumError, double);
00239
00241
00242 vtkSetMacro(MaximumNumberOfSteps, vtkIdType);
00243 vtkGetMacro(MaximumNumberOfSteps, vtkIdType);
00245
00247
00249 vtkSetMacro(TerminalSpeed, double);
00250 vtkGetMacro(TerminalSpeed, double);
00252
00253
00254 enum
00255 {
00256 FORWARD,
00257 BACKWARD,
00258 BOTH
00259 };
00260
00261 enum
00262 {
00263 INTERPOLATOR_WITH_DATASET_POINT_LOCATOR,
00264 INTERPOLATOR_WITH_CELL_LOCATOR
00265 };
00266
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, bool);
00285 vtkGetMacro(ComputeVorticity, bool);
00287
00289
00291 vtkSetMacro(RotationScale, double);
00292 vtkGetMacro(RotationScale, double);
00294
00297 void SetInterpolatorPrototype( vtkAbstractInterpolatedVelocityField * ivf );
00298
00308 void SetInterpolatorType( int interpType );
00309
00310 protected:
00311
00312 vtkStreamTracer();
00313 ~vtkStreamTracer();
00314
00315
00316 virtual vtkExecutive* CreateDefaultExecutive();
00317
00318
00319 void AddInput(vtkDataObject *)
00320 { vtkErrorMacro( << "AddInput() must be called with a vtkDataSet not a vtkDataObject."); };
00321
00322 virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00323 virtual int FillInputPortInformation(int, vtkInformation *);
00324
00325 void CalculateVorticity( vtkGenericCell* cell, double pcoords[3],
00326 vtkDoubleArray* cellVectors, double vorticity[3] );
00327 void Integrate(vtkDataSet *input,
00328 vtkPolyData* output,
00329 vtkDataArray* seedSource,
00330 vtkIdList* seedIds,
00331 vtkIntArray* integrationDirections,
00332 double lastPoint[3],
00333 vtkAbstractInterpolatedVelocityField* func,
00334 int maxCellSize,
00335 const char *vecFieldName,
00336 double& propagation,
00337 vtkIdType& numSteps);
00338 void SimpleIntegrate(double seed[3],
00339 double lastPoint[3],
00340 double stepSize,
00341 vtkAbstractInterpolatedVelocityField* func);
00342 int CheckInputs(vtkAbstractInterpolatedVelocityField*& func,
00343 int* maxCellSize);
00344 void GenerateNormals(vtkPolyData* output, double* firstNormal, const char *vecName);
00345
00346 bool GenerateNormalsInIntegrate;
00347
00348
00349 double StartPosition[3];
00350
00351 static const double EPSILON;
00352 double TerminalSpeed;
00353
00354 double LastUsedStepSize;
00355
00356
00357 struct IntervalInformation
00358 {
00359 double Interval;
00360 int Unit;
00361 };
00362
00363 double MaximumPropagation;
00364 double MinimumIntegrationStep;
00365 double MaximumIntegrationStep;
00366 double InitialIntegrationStep;
00367
00368 void ConvertIntervals( double& step, double& minStep, double& maxStep,
00369 int direction, double cellLength );
00370 static double ConvertToLength( double interval, int unit, double cellLength );
00371 static double ConvertToLength( IntervalInformation& interval, double cellLength );
00372
00373
00374
00375 int SetupOutput(vtkInformation* inInfo,
00376 vtkInformation* outInfo);
00377 void InitializeSeeds(vtkDataArray*& seeds,
00378 vtkIdList*& seedIds,
00379 vtkIntArray*& integrationDirections,
00380 vtkDataSet *source);
00381
00382 int IntegrationStepUnit;
00383 int IntegrationDirection;
00384
00385
00386 vtkInitialValueProblemSolver* Integrator;
00387
00388 double MaximumError;
00389 vtkIdType MaximumNumberOfSteps;
00390
00391 bool ComputeVorticity;
00392 double RotationScale;
00393
00394 vtkAbstractInterpolatedVelocityField * InterpolatorPrototype;
00395
00396 vtkCompositeDataSet* InputData;
00397
00398 private:
00399 vtkStreamTracer(const vtkStreamTracer&);
00400 void operator=(const vtkStreamTracer&);
00401 };
00402
00403
00404 #endif
00405
00406