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

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 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 
00039 =========================================================================*/
00079 #ifndef __vtkStreamer_h
00080 #define __vtkStreamer_h
00081 
00082 #include "vtkDataSetToPolyDataFilter.h"
00083 #include "vtkInitialValueProblemSolver.h"
00084 
00085 class vtkMultiThreader;
00086 
00087 #define VTK_INTEGRATE_FORWARD 0
00088 #define VTK_INTEGRATE_BACKWARD 1
00089 #define VTK_INTEGRATE_BOTH_DIRECTIONS 2
00090 
00091 typedef struct _vtkStreamPoint {
00092   float   x[3];    // position 
00093   int     cellId;  // cell
00094   int     subId;   // cell sub id
00095   float   p[3];    // parametric coords in cell 
00096   float   v[3];    // velocity 
00097   float   speed;   // velocity norm 
00098   float   s;       // scalar value 
00099   float   t;       // time travelled so far 
00100   float   d;       // distance travelled so far 
00101   float   omega;   // stream vorticity, if computed
00102   float   theta;    // rotation angle, if vorticity is computed
00103 } vtkStreamPoint;
00104 
00105 //
00106 // Special classes for manipulating data
00107 //
00108 //BTX - begin tcl exclude
00109 //
00110 class vtkStreamArray { //;prevent man page generation
00111 public:
00112   vtkStreamArray();
00113   ~vtkStreamArray()
00114     {
00115     if (this->Array)
00116       {
00117       delete [] this->Array;
00118       }
00119     };
00120   int GetNumberOfPoints() {return this->MaxId + 1;};
00121   vtkStreamPoint *GetStreamPoint(int i) {return this->Array + i;};
00122   int InsertNextStreamPoint() 
00123     {
00124     if ( ++this->MaxId >= this->Size )
00125       {
00126       this->Resize(this->MaxId);
00127       }
00128     return this->MaxId; //return offset from array
00129     }
00130   vtkStreamPoint *Resize(int sz); //reallocates data
00131   void Reset() {this->MaxId = -1;};
00132 
00133   vtkStreamPoint *Array;  // pointer to data
00134   int MaxId;              // maximum index inserted thus far
00135   int Size;               // allocated size of data
00136   int Extend;             // grow array by this amount
00137   float Direction;        // integration direction
00138 };
00139 //ETX
00140 //
00141 
00142 class VTK_EXPORT vtkStreamer : public vtkDataSetToPolyDataFilter
00143 {
00144 public:
00145   vtkTypeMacro(vtkStreamer,vtkDataSetToPolyDataFilter);
00146   void PrintSelf(ostream& os, vtkIndent indent);
00147 
00151   static vtkStreamer *New();
00152   
00156   void SetStartLocation(int cellId, int subId, float pcoords[3]);
00157 
00161   void SetStartLocation(int cellId, int subId, float r, float s, float t);
00162 
00165   int GetStartLocation(int& subId, float pcoords[3]);
00166 
00170   void SetStartPosition(float x[3]);
00171 
00175   void SetStartPosition(float x, float y, float z);
00176 
00178   float *GetStartPosition();
00179 
00181   void SetSource(vtkDataSet *source);
00182   vtkDataSet *GetSource();
00183   
00185   vtkSetClampMacro(MaximumPropagationTime,float,0.0,VTK_LARGE_FLOAT);
00186   vtkGetMacro(MaximumPropagationTime,float);
00187 
00189   vtkSetClampMacro(IntegrationDirection,int,
00190                   VTK_INTEGRATE_FORWARD,VTK_INTEGRATE_BOTH_DIRECTIONS);
00191   vtkGetMacro(IntegrationDirection,int);
00192   void SetIntegrationDirectionToForward()
00193     {this->SetIntegrationDirection(VTK_INTEGRATE_FORWARD);};
00194   void SetIntegrationDirectionToBackward()
00195     {this->SetIntegrationDirection(VTK_INTEGRATE_BACKWARD);};
00196   void SetIntegrationDirectionToIntegrateBothDirections()
00197     {this->SetIntegrationDirection(VTK_INTEGRATE_BOTH_DIRECTIONS);};
00198   const char *GetIntegrationDirectionAsString();
00199 
00202   vtkSetClampMacro(IntegrationStepLength,float,0.0000001,VTK_LARGE_FLOAT);
00203   vtkGetMacro(IntegrationStepLength,float);
00204 
00207   vtkSetMacro(SpeedScalars,int);
00208   vtkGetMacro(SpeedScalars,int);
00209   vtkBooleanMacro(SpeedScalars,int);
00210 
00213   vtkSetClampMacro(TerminalSpeed,float,0.0,VTK_LARGE_FLOAT);
00214   vtkGetMacro(TerminalSpeed,float);
00215 
00221   vtkSetMacro(Vorticity,int);
00222   vtkGetMacro(Vorticity,int);
00223   vtkBooleanMacro(Vorticity,int);
00224 
00225   vtkSetMacro( NumberOfThreads, int );
00226   vtkGetMacro( NumberOfThreads, int );
00227 
00228   vtkSetMacro( SavePointInterval, float );
00229   vtkGetMacro( SavePointInterval, float );
00230 
00235   vtkSetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00236   vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00237 
00238 //BTX
00239 
00242   vtkGetMacro( NumberOfStreamers, int );
00243   vtkStreamArray *GetStreamers() { return this->Streamers; };
00244 
00245 //ETX
00246 
00247 protected:
00248   vtkStreamer();
00249   ~vtkStreamer();
00250   vtkStreamer(const vtkStreamer&) {};
00251   void operator=(const vtkStreamer&) {};
00252 
00253   // Integrate data
00254   void Integrate();
00255 
00256   // Special method for computing streamer vorticity
00257   void ComputeVorticity();
00258 
00259   // Controls where streamlines start from (either position or location).
00260   int StartFrom;
00261 
00262   // Starting from cell location
00263   int StartCell;
00264   int StartSubId;
00265   float StartPCoords[3];
00266 
00267   // starting from global x-y-z position
00268   float StartPosition[3];
00269 
00270   //array of streamers
00271   vtkStreamArray *Streamers;
00272   int NumberOfStreamers;
00273 
00274   // length of Streamer is generated by time, or by MaximumSteps
00275   float MaximumPropagationTime;
00276 
00277   // integration direction
00278   int IntegrationDirection;
00279 
00280   // the length (fraction of cell size) of integration steps
00281   float IntegrationStepLength;
00282 
00283   // boolean controls whether vorticity is computed
00284   int Vorticity;
00285 
00286   // terminal propagation speed
00287   float TerminalSpeed;
00288 
00289   // boolean controls whether data scalars or velocity magnitude are used
00290   int SpeedScalars;
00291 
00292   // Prototype showing the integrator type to be set by the user.
00293   vtkInitialValueProblemSolver* Integrator;
00294 
00295   // Interval with which the stream points will be stored.
00296   // Useful in reducing the memory footprint. Since the initial
00297   // value is small, by default, it will store all/most points.
00298   float SavePointInterval;
00299 
00300   void InitializeThreadedIntegrate();
00301   vtkMultiThreader           *Threader;
00302   int                        NumberOfThreads;
00303 
00304 };
00305 
00307 inline const char *vtkStreamer::GetIntegrationDirectionAsString(void)
00308 {
00309   if ( this->IntegrationDirection == VTK_INTEGRATE_FORWARD ) 
00310     {
00311     return "IntegrateForward";
00312     }
00313   else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD ) 
00314     {
00315     return "IntegrateBackward";
00316     }
00317   else 
00318     {
00319     return "IntegrateBothDirections";
00320     }
00321 }
00322 
00323 #endif
00324 
00325 

Generated on Wed Nov 21 12:27:03 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001