VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkStreamer.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 =========================================================================*/ 00052 #ifndef __vtkStreamer_h 00053 #define __vtkStreamer_h 00054 00055 #include "vtkFiltersFlowPathsModule.h" // For export macro 00056 #include "vtkPolyDataAlgorithm.h" 00057 00058 class vtkInitialValueProblemSolver; 00059 class vtkMultiThreader; 00060 00061 #define VTK_INTEGRATE_FORWARD 0 00062 #define VTK_INTEGRATE_BACKWARD 1 00063 #define VTK_INTEGRATE_BOTH_DIRECTIONS 2 00064 00065 class VTKFILTERSFLOWPATHS_EXPORT vtkStreamer : public vtkPolyDataAlgorithm 00066 { 00067 public: 00068 vtkTypeMacro(vtkStreamer,vtkPolyDataAlgorithm); 00069 void PrintSelf(ostream& os, vtkIndent indent); 00070 00074 void SetStartLocation(vtkIdType cellId, int subId, double pcoords[3]); 00075 00077 00080 void SetStartLocation(vtkIdType cellId, int subId, double r, double s, 00081 double t); 00083 00086 vtkIdType GetStartLocation(int& subId, double pcoords[3]); 00087 00091 void SetStartPosition(double x[3]); 00092 00096 void SetStartPosition(double x, double y, double z); 00097 00099 double *GetStartPosition(); 00100 00102 00103 void SetSourceData(vtkDataSet *source); 00104 vtkDataSet *GetSource(); 00106 00109 void SetSourceConnection(vtkAlgorithmOutput* algOutput); 00110 00112 00113 vtkSetClampMacro(MaximumPropagationTime,double,0.0,VTK_DOUBLE_MAX); 00114 vtkGetMacro(MaximumPropagationTime,double); 00116 00118 00119 vtkSetClampMacro(IntegrationDirection,int, 00120 VTK_INTEGRATE_FORWARD,VTK_INTEGRATE_BOTH_DIRECTIONS); 00121 vtkGetMacro(IntegrationDirection,int); 00122 void SetIntegrationDirectionToForward() 00123 {this->SetIntegrationDirection(VTK_INTEGRATE_FORWARD);}; 00124 void SetIntegrationDirectionToBackward() 00125 {this->SetIntegrationDirection(VTK_INTEGRATE_BACKWARD);}; 00126 void SetIntegrationDirectionToIntegrateBothDirections() 00127 {this->SetIntegrationDirection(VTK_INTEGRATE_BOTH_DIRECTIONS);}; 00128 const char *GetIntegrationDirectionAsString(); 00130 00132 00134 vtkSetClampMacro(IntegrationStepLength,double,0.0000001,VTK_DOUBLE_MAX); 00135 vtkGetMacro(IntegrationStepLength,double); 00137 00139 00141 vtkSetMacro(SpeedScalars,int); 00142 vtkGetMacro(SpeedScalars,int); 00143 vtkBooleanMacro(SpeedScalars,int); 00145 00147 00152 vtkSetMacro(OrientationScalars, int); 00153 vtkGetMacro(OrientationScalars, int); 00154 vtkBooleanMacro(OrientationScalars, int); 00156 00158 00160 vtkSetClampMacro(TerminalSpeed,double,0.0,VTK_DOUBLE_MAX); 00161 vtkGetMacro(TerminalSpeed,double); 00163 00165 00170 vtkSetMacro(Vorticity,int); 00171 vtkGetMacro(Vorticity,int); 00172 vtkBooleanMacro(Vorticity,int); 00174 00175 vtkSetMacro( NumberOfThreads, int ); 00176 vtkGetMacro( NumberOfThreads, int ); 00177 00178 vtkSetMacro( SavePointInterval, double ); 00179 vtkGetMacro( SavePointInterval, double ); 00180 00182 00186 void SetIntegrator(vtkInitialValueProblemSolver *); 00187 vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver ); 00189 00191 00193 vtkSetMacro(Epsilon,double); 00194 vtkGetMacro(Epsilon,double); 00196 00197 protected: 00199 00202 vtkStreamer(); 00203 ~vtkStreamer(); 00205 00206 // Integrate data 00207 void Integrate(vtkDataSet *input, vtkDataSet *source); 00208 00209 // Controls where streamlines start from (either position or location). 00210 int StartFrom; 00211 00212 // Starting from cell location 00213 vtkIdType StartCell; 00214 int StartSubId; 00215 double StartPCoords[3]; 00216 00217 // starting from global x-y-z position 00218 double StartPosition[3]; 00219 00220 // 00221 // Special classes for manipulating data 00222 // 00223 //BTX - begin tcl exclude 00224 // 00225 class StreamPoint { 00226 public: 00227 double x[3]; // position 00228 vtkIdType cellId; // cell 00229 int subId; // cell sub id 00230 double p[3]; // parametric coords in cell 00231 double v[3]; // velocity 00232 double speed; // velocity norm 00233 double s; // scalar value 00234 double t; // time travelled so far 00235 double d; // distance travelled so far 00236 double omega; // stream vorticity, if computed 00237 double theta; // rotation angle, if vorticity is computed 00238 }; 00239 00240 class StreamArray; 00241 friend class StreamArray; 00242 class StreamArray { //;prevent man page generation 00243 public: 00244 StreamArray(); 00245 ~StreamArray() 00246 { 00247 if (this->Array) 00248 { 00249 delete [] this->Array; 00250 } 00251 }; 00252 vtkIdType GetNumberOfPoints() {return this->MaxId + 1;}; 00253 StreamPoint *GetStreamPoint(vtkIdType i) {return this->Array + i;}; 00254 vtkIdType InsertNextStreamPoint() 00255 { 00256 if ( ++this->MaxId >= this->Size ) 00257 { 00258 this->Resize(this->MaxId); 00259 } 00260 return this->MaxId; //return offset from array 00261 } 00262 StreamPoint *Resize(vtkIdType sz); //reallocates data 00263 void Reset() {this->MaxId = -1;}; 00264 00265 StreamPoint *Array; // pointer to data 00266 vtkIdType MaxId; // maximum index inserted thus far 00267 vtkIdType Size; // allocated size of data 00268 vtkIdType Extend; // grow array by this amount 00269 double Direction; // integration direction 00270 }; 00271 //ETX 00272 // 00273 00274 //array of streamers 00275 StreamArray *Streamers; 00276 vtkIdType NumberOfStreamers; 00277 00278 // length of Streamer is generated by time, or by MaximumSteps 00279 double MaximumPropagationTime; 00280 00281 // integration direction 00282 int IntegrationDirection; 00283 00284 // the length (fraction of cell size) of integration steps 00285 double IntegrationStepLength; 00286 00287 // boolean controls whether vorticity is computed 00288 int Vorticity; 00289 00290 // terminal propagation speed 00291 double TerminalSpeed; 00292 00293 // boolean controls whether data scalars or velocity magnitude are used 00294 int SpeedScalars; 00295 00296 // boolean controls whether data scalars or vorticity orientation are used 00297 int OrientationScalars; 00298 00299 // Prototype showing the integrator type to be set by the user. 00300 vtkInitialValueProblemSolver* Integrator; 00301 00302 // A positive value, as small as possible for numerical comparison. 00303 // The initial value is 1E-12. 00304 double Epsilon; 00305 00306 // Interval with which the stream points will be stored. 00307 // Useful in reducing the memory footprint. Since the initial 00308 // value is small, by default, it will store all/most points. 00309 double SavePointInterval; 00310 00311 static VTK_THREAD_RETURN_TYPE ThreadedIntegrate( void *arg ); 00312 00314 00316 vtkGetMacro( NumberOfStreamers, vtkIdType ); 00317 StreamArray *GetStreamers() { return this->Streamers; }; 00319 00320 void InitializeThreadedIntegrate(); 00321 vtkMultiThreader *Threader; 00322 int NumberOfThreads; 00323 00324 virtual int FillInputPortInformation(int port, vtkInformation *info); 00325 00326 private: 00327 vtkStreamer(const vtkStreamer&); // Not implemented. 00328 void operator=(const vtkStreamer&); // Not implemented. 00329 }; 00330 00332 00333 inline const char *vtkStreamer::GetIntegrationDirectionAsString() 00334 { 00335 if ( this->IntegrationDirection == VTK_INTEGRATE_FORWARD ) 00336 { 00337 return "IntegrateForward"; 00338 } 00339 else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD ) 00340 { 00341 return "IntegrateBackward"; 00342 } 00343 else 00344 { 00345 return "IntegrateBothDirections"; 00346 } 00347 } 00349 00350 #endif