Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

dox/Graphics/vtkStreamer.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkStreamer.h,v $ 00005 Language: C++ 00006 00007 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserved. 00009 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notice for more information. 00014 00015 =========================================================================*/ 00056 #ifndef __vtkStreamer_h 00057 #define __vtkStreamer_h 00058 00059 #include "vtkDataSetToPolyDataFilter.h" 00060 00061 class vtkInitialValueProblemSolver; 00062 class vtkMultiThreader; 00063 00064 #define VTK_INTEGRATE_FORWARD 0 00065 #define VTK_INTEGRATE_BACKWARD 1 00066 #define VTK_INTEGRATE_BOTH_DIRECTIONS 2 00067 00068 class VTK_GRAPHICS_EXPORT vtkStreamer : public vtkDataSetToPolyDataFilter 00069 { 00070 public: 00071 vtkTypeRevisionMacro(vtkStreamer,vtkDataSetToPolyDataFilter); 00072 void PrintSelf(ostream& os, vtkIndent indent); 00073 00077 void SetStartLocation(vtkIdType cellId, int subId, float pcoords[3]); 00078 00080 00083 void SetStartLocation(vtkIdType cellId, int subId, float r, float s, 00084 float t); 00086 00089 vtkIdType GetStartLocation(int& subId, float pcoords[3]); 00090 00094 void SetStartPosition(float x[3]); 00095 00099 void SetStartPosition(float x, float y, float z); 00100 00102 float *GetStartPosition(); 00103 00105 00106 void SetSource(vtkDataSet *source); 00107 vtkDataSet *GetSource(); 00109 00111 00112 vtkSetClampMacro(MaximumPropagationTime,float,0.0,VTK_LARGE_FLOAT); 00113 vtkGetMacro(MaximumPropagationTime,float); 00115 00117 00118 vtkSetClampMacro(IntegrationDirection,int, 00119 VTK_INTEGRATE_FORWARD,VTK_INTEGRATE_BOTH_DIRECTIONS); 00120 vtkGetMacro(IntegrationDirection,int); 00121 void SetIntegrationDirectionToForward() 00122 {this->SetIntegrationDirection(VTK_INTEGRATE_FORWARD);}; 00123 void SetIntegrationDirectionToBackward() 00124 {this->SetIntegrationDirection(VTK_INTEGRATE_BACKWARD);}; 00125 void SetIntegrationDirectionToIntegrateBothDirections() 00126 {this->SetIntegrationDirection(VTK_INTEGRATE_BOTH_DIRECTIONS);}; 00127 const char *GetIntegrationDirectionAsString(); 00129 00131 00133 vtkSetClampMacro(IntegrationStepLength,float,0.0000001,VTK_LARGE_FLOAT); 00134 vtkGetMacro(IntegrationStepLength,float); 00136 00138 00140 vtkSetMacro(SpeedScalars,int); 00141 vtkGetMacro(SpeedScalars,int); 00142 vtkBooleanMacro(SpeedScalars,int); 00144 00146 00151 vtkSetMacro(OrientationScalars, int); 00152 vtkGetMacro(OrientationScalars, int); 00153 vtkBooleanMacro(OrientationScalars, int); 00155 00157 00159 vtkSetClampMacro(TerminalSpeed,float,0.0,VTK_LARGE_FLOAT); 00160 vtkGetMacro(TerminalSpeed,float); 00162 00164 00169 vtkSetMacro(Vorticity,int); 00170 vtkGetMacro(Vorticity,int); 00171 vtkBooleanMacro(Vorticity,int); 00173 00174 vtkSetMacro( NumberOfThreads, int ); 00175 vtkGetMacro( NumberOfThreads, int ); 00176 00177 vtkSetMacro( SavePointInterval, float ); 00178 vtkGetMacro( SavePointInterval, float ); 00179 00181 00185 void SetIntegrator(vtkInitialValueProblemSolver *); 00186 vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver ); 00188 00189 protected: 00191 00194 vtkStreamer(); 00195 ~vtkStreamer(); 00197 00198 // Integrate data 00199 void Integrate(); 00200 00201 // Special method for computing streamer vorticity 00202 void ComputeVorticity(); 00203 00204 // Controls where streamlines start from (either position or location). 00205 int StartFrom; 00206 00207 // Starting from cell location 00208 vtkIdType StartCell; 00209 int StartSubId; 00210 float StartPCoords[3]; 00211 00212 // starting from global x-y-z position 00213 float StartPosition[3]; 00214 00215 // 00216 // Special classes for manipulating data 00217 // 00218 //BTX - begin tcl exclude 00219 // 00220 class StreamPoint { 00221 public: 00222 float x[3]; // position 00223 vtkIdType cellId; // cell 00224 int subId; // cell sub id 00225 float p[3]; // parametric coords in cell 00226 float v[3]; // velocity 00227 float speed; // velocity norm 00228 float s; // scalar value 00229 float t; // time travelled so far 00230 float d; // distance travelled so far 00231 float omega; // stream vorticity, if computed 00232 float theta; // rotation angle, if vorticity is computed 00233 }; 00234 00235 class StreamArray; 00236 friend class StreamArray; 00237 class StreamArray { //;prevent man page generation 00238 public: 00239 StreamArray(); 00240 ~StreamArray() 00241 { 00242 if (this->Array) 00243 { 00244 delete [] this->Array; 00245 } 00246 }; 00247 vtkIdType GetNumberOfPoints() {return this->MaxId + 1;}; 00248 StreamPoint *GetStreamPoint(vtkIdType i) {return this->Array + i;}; 00249 vtkIdType InsertNextStreamPoint() 00250 { 00251 if ( ++this->MaxId >= this->Size ) 00252 { 00253 this->Resize(this->MaxId); 00254 } 00255 return this->MaxId; //return offset from array 00256 } 00257 StreamPoint *Resize(vtkIdType sz); //reallocates data 00258 void Reset() {this->MaxId = -1;}; 00259 00260 StreamPoint *Array; // pointer to data 00261 vtkIdType MaxId; // maximum index inserted thus far 00262 vtkIdType Size; // allocated size of data 00263 vtkIdType Extend; // grow array by this amount 00264 float Direction; // integration direction 00265 }; 00266 //ETX 00267 // 00268 00269 //array of streamers 00270 StreamArray *Streamers; 00271 vtkIdType NumberOfStreamers; 00272 00273 // length of Streamer is generated by time, or by MaximumSteps 00274 float MaximumPropagationTime; 00275 00276 // integration direction 00277 int IntegrationDirection; 00278 00279 // the length (fraction of cell size) of integration steps 00280 float IntegrationStepLength; 00281 00282 // boolean controls whether vorticity is computed 00283 int Vorticity; 00284 00285 // terminal propagation speed 00286 float TerminalSpeed; 00287 00288 // boolean controls whether data scalars or velocity magnitude are used 00289 int SpeedScalars; 00290 00291 // boolean controls whether data scalars or vorticity orientation are used 00292 int OrientationScalars; 00293 00294 // Prototype showing the integrator type to be set by the user. 00295 vtkInitialValueProblemSolver* Integrator; 00296 00297 // Interval with which the stream points will be stored. 00298 // Useful in reducing the memory footprint. Since the initial 00299 // value is small, by default, it will store all/most points. 00300 float SavePointInterval; 00301 00302 static VTK_THREAD_RETURN_TYPE ThreadedIntegrate( void *arg ); 00303 00305 00307 vtkGetMacro( NumberOfStreamers, int ); 00308 StreamArray *GetStreamers() { return this->Streamers; }; 00310 00311 void InitializeThreadedIntegrate(); 00312 vtkMultiThreader *Threader; 00313 int NumberOfThreads; 00314 00315 private: 00316 vtkStreamer(const vtkStreamer&); // Not implemented. 00317 void operator=(const vtkStreamer&); // Not implemented. 00318 }; 00319 00321 inline const char *vtkStreamer::GetIntegrationDirectionAsString(void) 00322 { 00323 if ( this->IntegrationDirection == VTK_INTEGRATE_FORWARD ) 00324 { 00325 return "IntegrateForward"; 00326 } 00327 else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD ) 00328 { 00329 return "IntegrateBackward"; 00330 } 00331 else 00332 { 00333 return "IntegrateBothDirections"; 00334 } 00335 } 00336 00337 #endif 00338 00339