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 delete [] this->Array; 00248 }; 00249 vtkIdType GetNumberOfPoints() {return this->MaxId + 1;}; 00250 StreamPoint *GetStreamPoint(vtkIdType i) {return this->Array + i;}; 00251 vtkIdType InsertNextStreamPoint() 00252 { 00253 if ( ++this->MaxId >= this->Size ) 00254 { 00255 this->Resize(this->MaxId); 00256 } 00257 return this->MaxId; //return offset from array 00258 } 00259 StreamPoint *Resize(vtkIdType sz); //reallocates data 00260 void Reset() {this->MaxId = -1;}; 00261 00262 StreamPoint *Array; // pointer to data 00263 vtkIdType MaxId; // maximum index inserted thus far 00264 vtkIdType Size; // allocated size of data 00265 vtkIdType Extend; // grow array by this amount 00266 double Direction; // integration direction 00267 }; 00268 //ETX 00269 // 00270 00271 //array of streamers 00272 StreamArray *Streamers; 00273 vtkIdType NumberOfStreamers; 00274 00275 // length of Streamer is generated by time, or by MaximumSteps 00276 double MaximumPropagationTime; 00277 00278 // integration direction 00279 int IntegrationDirection; 00280 00281 // the length (fraction of cell size) of integration steps 00282 double IntegrationStepLength; 00283 00284 // boolean controls whether vorticity is computed 00285 int Vorticity; 00286 00287 // terminal propagation speed 00288 double TerminalSpeed; 00289 00290 // boolean controls whether data scalars or velocity magnitude are used 00291 int SpeedScalars; 00292 00293 // boolean controls whether data scalars or vorticity orientation are used 00294 int OrientationScalars; 00295 00296 // Prototype showing the integrator type to be set by the user. 00297 vtkInitialValueProblemSolver* Integrator; 00298 00299 // A positive value, as small as possible for numerical comparison. 00300 // The initial value is 1E-12. 00301 double Epsilon; 00302 00303 // Interval with which the stream points will be stored. 00304 // Useful in reducing the memory footprint. Since the initial 00305 // value is small, by default, it will store all/most points. 00306 double SavePointInterval; 00307 00308 static VTK_THREAD_RETURN_TYPE ThreadedIntegrate( void *arg ); 00309 00311 00313 vtkGetMacro( NumberOfStreamers, vtkIdType ); 00314 StreamArray *GetStreamers() { return this->Streamers; }; 00316 00317 void InitializeThreadedIntegrate(); 00318 vtkMultiThreader *Threader; 00319 int NumberOfThreads; 00320 00321 virtual int FillInputPortInformation(int port, vtkInformation *info); 00322 00323 private: 00324 vtkStreamer(const vtkStreamer&); // Not implemented. 00325 void operator=(const vtkStreamer&); // Not implemented. 00326 }; 00327 00329 00330 inline const char *vtkStreamer::GetIntegrationDirectionAsString() 00331 { 00332 if ( this->IntegrationDirection == VTK_INTEGRATE_FORWARD ) 00333 { 00334 return "IntegrateForward"; 00335 } 00336 else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD ) 00337 { 00338 return "IntegrateBackward"; 00339 } 00340 else 00341 { 00342 return "IntegrateBothDirections"; 00343 } 00344 } 00346 00347 #endif