VTK
|
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 "vtkFiltersFlowPathsModule.h" // For export macro 00089 #include "vtkPolyDataAlgorithm.h" 00090 00091 #include "vtkInitialValueProblemSolver.h" // Needed for constants 00092 00093 class vtkCompositeDataSet; 00094 class vtkDataArray; 00095 class vtkDoubleArray; 00096 class vtkExecutive; 00097 class vtkGenericCell; 00098 class vtkIdList; 00099 class vtkIntArray; 00100 class vtkAbstractInterpolatedVelocityField; 00101 00102 class VTKFILTERSFLOWPATHS_EXPORT vtkStreamTracer : public vtkPolyDataAlgorithm 00103 { 00104 public: 00105 vtkTypeMacro(vtkStreamTracer,vtkPolyDataAlgorithm); 00106 void PrintSelf(ostream& os, vtkIndent indent); 00107 00113 static vtkStreamTracer *New(); 00114 00116 00119 vtkSetVector3Macro(StartPosition, double); 00120 vtkGetVector3Macro(StartPosition, double); 00122 00124 00128 void SetSourceData(vtkDataSet *source); 00129 vtkDataSet *GetSource(); 00131 00134 void SetSourceConnection(vtkAlgorithmOutput* algOutput); 00135 00136 //BTX 00137 // The previously-supported TIME_UNIT is excluded in this current 00138 // enumeration definition because the underlying step size is ALWAYS in 00139 // arc length unit (LENGTH_UNIT) while the 'real' time interval (virtual 00140 // for steady flows) that a particle actually takes to trave in a single 00141 // step is obtained by dividing the arc length by the LOCAL speed. The 00142 // overall elapsed time (i.e., the life span) of the particle is the sum 00143 // of those individual step-wise time intervals. The arc-length-to-time 00144 // conversion only occurs for vorticity computation and for generating a 00145 // point data array named 'IntegrationTime'. 00146 enum Units 00147 { 00148 LENGTH_UNIT = 1, 00149 CELL_LENGTH_UNIT = 2 00150 }; 00151 00152 enum Solvers 00153 { 00154 RUNGE_KUTTA2, 00155 RUNGE_KUTTA4, 00156 RUNGE_KUTTA45, 00157 NONE, 00158 UNKNOWN 00159 }; 00160 00161 enum ReasonForTermination 00162 { 00163 OUT_OF_DOMAIN = vtkInitialValueProblemSolver::OUT_OF_DOMAIN, 00164 NOT_INITIALIZED = vtkInitialValueProblemSolver::NOT_INITIALIZED , 00165 UNEXPECTED_VALUE = vtkInitialValueProblemSolver::UNEXPECTED_VALUE, 00166 OUT_OF_LENGTH = 4, 00167 OUT_OF_STEPS = 5, 00168 STAGNATION = 6 00169 }; 00170 //ETX 00171 00173 00179 void SetIntegrator(vtkInitialValueProblemSolver *); 00180 vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver ); 00181 void SetIntegratorType(int type); 00182 int GetIntegratorType(); 00183 void SetIntegratorTypeToRungeKutta2() 00184 {this->SetIntegratorType(RUNGE_KUTTA2);}; 00185 void SetIntegratorTypeToRungeKutta4() 00186 {this->SetIntegratorType(RUNGE_KUTTA4);}; 00187 void SetIntegratorTypeToRungeKutta45() 00188 {this->SetIntegratorType(RUNGE_KUTTA45);}; 00190 00193 void SetInterpolatorTypeToDataSetPointLocator(); 00194 00197 void SetInterpolatorTypeToCellLocator(); 00198 00200 00201 vtkSetMacro(MaximumPropagation, double); 00202 vtkGetMacro(MaximumPropagation, double); 00204 00206 00210 void SetIntegrationStepUnit( int unit ); 00211 int GetIntegrationStepUnit() { return this->IntegrationStepUnit; } 00213 00215 00219 vtkSetMacro(InitialIntegrationStep, double); 00220 vtkGetMacro(InitialIntegrationStep, double); 00222 00224 00227 vtkSetMacro(MinimumIntegrationStep, double); 00228 vtkGetMacro(MinimumIntegrationStep, double); 00230 00232 00235 vtkSetMacro(MaximumIntegrationStep, double); 00236 vtkGetMacro(MaximumIntegrationStep, double); 00238 00240 00242 vtkSetMacro(MaximumError, double); 00243 vtkGetMacro(MaximumError, double); 00245 00247 00248 vtkSetMacro(MaximumNumberOfSteps, vtkIdType); 00249 vtkGetMacro(MaximumNumberOfSteps, vtkIdType); 00251 00253 00255 vtkSetMacro(TerminalSpeed, double); 00256 vtkGetMacro(TerminalSpeed, double); 00258 00259 //BTX 00260 enum 00261 { 00262 FORWARD, 00263 BACKWARD, 00264 BOTH 00265 }; 00266 00267 enum 00268 { 00269 INTERPOLATOR_WITH_DATASET_POINT_LOCATOR, 00270 INTERPOLATOR_WITH_CELL_LOCATOR 00271 }; 00272 //ETX 00273 00275 00277 vtkSetClampMacro(IntegrationDirection, int, FORWARD, BOTH); 00278 vtkGetMacro(IntegrationDirection, int); 00279 void SetIntegrationDirectionToForward() 00280 {this->SetIntegrationDirection(FORWARD);}; 00281 void SetIntegrationDirectionToBackward() 00282 {this->SetIntegrationDirection(BACKWARD);}; 00283 void SetIntegrationDirectionToBoth() 00284 {this->SetIntegrationDirection(BOTH);}; 00286 00288 00290 vtkSetMacro(ComputeVorticity, bool); 00291 vtkGetMacro(ComputeVorticity, bool); 00293 00295 00297 vtkSetMacro(RotationScale, double); 00298 vtkGetMacro(RotationScale, double); 00300 00303 void SetInterpolatorPrototype( vtkAbstractInterpolatedVelocityField * ivf ); 00304 00314 void SetInterpolatorType( int interpType ); 00315 00316 protected: 00317 00318 vtkStreamTracer(); 00319 ~vtkStreamTracer(); 00320 00321 // Create a default executive. 00322 virtual vtkExecutive* CreateDefaultExecutive(); 00323 00324 // hide the superclass' AddInput() from the user and the compiler 00325 void AddInput(vtkDataObject *) 00326 { vtkErrorMacro( << "AddInput() must be called with a vtkDataSet not a vtkDataObject."); }; 00327 00328 virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00329 virtual int FillInputPortInformation(int, vtkInformation *); 00330 00331 void CalculateVorticity( vtkGenericCell* cell, double pcoords[3], 00332 vtkDoubleArray* cellVectors, double vorticity[3] ); 00333 void Integrate(vtkPointData *inputData, 00334 vtkPolyData* output, 00335 vtkDataArray* seedSource, 00336 vtkIdList* seedIds, 00337 vtkIntArray* integrationDirections, 00338 double lastPoint[3], 00339 vtkAbstractInterpolatedVelocityField* func, 00340 int maxCellSize, 00341 int vecType, 00342 const char *vecFieldName, 00343 double& propagation, 00344 vtkIdType& numSteps); 00345 void SimpleIntegrate(double seed[3], 00346 double lastPoint[3], 00347 double stepSize, 00348 vtkAbstractInterpolatedVelocityField* func); 00349 int CheckInputs(vtkAbstractInterpolatedVelocityField*& func, 00350 int* maxCellSize); 00351 void GenerateNormals(vtkPolyData* output, double* firstNormal, const char *vecName); 00352 00353 bool GenerateNormalsInIntegrate; 00354 00355 // starting from global x-y-z position 00356 double StartPosition[3]; 00357 00358 static const double EPSILON; 00359 double TerminalSpeed; 00360 00361 double LastUsedStepSize; 00362 00363 //BTX 00364 struct IntervalInformation 00365 { 00366 double Interval; 00367 int Unit; 00368 }; 00369 00370 double MaximumPropagation; 00371 double MinimumIntegrationStep; 00372 double MaximumIntegrationStep; 00373 double InitialIntegrationStep; 00374 00375 void ConvertIntervals( double& step, double& minStep, double& maxStep, 00376 int direction, double cellLength ); 00377 static double ConvertToLength( double interval, int unit, double cellLength ); 00378 static double ConvertToLength( IntervalInformation& interval, double cellLength ); 00379 00380 //ETX 00381 00382 int SetupOutput(vtkInformation* inInfo, 00383 vtkInformation* outInfo); 00384 void InitializeSeeds(vtkDataArray*& seeds, 00385 vtkIdList*& seedIds, 00386 vtkIntArray*& integrationDirections, 00387 vtkDataSet *source); 00388 00389 int IntegrationStepUnit; 00390 int IntegrationDirection; 00391 00392 // Prototype showing the integrator type to be set by the user. 00393 vtkInitialValueProblemSolver* Integrator; 00394 00395 double MaximumError; 00396 vtkIdType MaximumNumberOfSteps; 00397 00398 bool ComputeVorticity; 00399 double RotationScale; 00400 00401 vtkAbstractInterpolatedVelocityField * InterpolatorPrototype; 00402 00403 vtkCompositeDataSet* InputData; 00404 bool HasMatchingPointAttributes; //does the point data in the multiblocks have the same attributes? 00405 00406 friend class PStreamTracerUtils; 00407 00408 private: 00409 vtkStreamTracer(const vtkStreamTracer&); // Not implemented. 00410 void operator=(const vtkStreamTracer&); // Not implemented. 00411 }; 00412 00413 00414 #endif