00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00085 #ifndef __vtkStreamTracer_h
00086 #define __vtkStreamTracer_h
00087
00088 #include "vtkPolyDataAlgorithm.h"
00089
00090 #include "vtkInitialValueProblemSolver.h"
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
00134
00135
00136
00137
00138
00139
00140
00141
00142
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
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
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
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
00319 virtual vtkExecutive* CreateDefaultExecutive();
00320
00321
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
00352 double StartPosition[3];
00353
00354 static const double EPSILON;
00355 double TerminalSpeed;
00356
00357 double LastUsedStepSize;
00358
00359
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
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
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&);
00403 void operator=(const vtkStreamTracer&);
00404 };
00405
00406
00407 #endif
00408
00409