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 =========================================================================*/
00080 #ifndef __vtkStreamer_h
00081 #define __vtkStreamer_h
00082 
00083 #include "vtkDataSetToPolyDataFilter.h"
00084 #include "vtkInitialValueProblemSolver.h"
00085 #include "vtkMultiThreader.h"
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   vtkIdType     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   vtkIdType GetNumberOfPoints() {return this->MaxId + 1;};
00121   vtkStreamPoint *GetStreamPoint(vtkIdType i) {return this->Array + i;};
00122   vtkIdType 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(vtkIdType sz); //reallocates data
00131   void Reset() {this->MaxId = -1;};
00132 
00133   vtkStreamPoint *Array;  // pointer to data
00134   vtkIdType MaxId;        // maximum index inserted thus far
00135   vtkIdType Size;         // allocated size of data
00136   vtkIdType Extend;       // grow array by this amount
00137   float Direction;        // integration direction
00138 };
00139 //ETX
00140 //
00141 
00142 class VTK_GRAPHICS_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(vtkIdType cellId, int subId, float pcoords[3]);
00157 
00159 
00162   void SetStartLocation(vtkIdType cellId, int subId, float r, float s,
00163                         float t);
00165 
00168   vtkIdType GetStartLocation(int& subId, float pcoords[3]);
00169 
00173   void SetStartPosition(float x[3]);
00174 
00178   void SetStartPosition(float x, float y, float z);
00179 
00181   float *GetStartPosition();
00182 
00184 
00185   void SetSource(vtkDataSet *source);
00186   vtkDataSet *GetSource();
00188   
00190 
00191   vtkSetClampMacro(MaximumPropagationTime,float,0.0,VTK_LARGE_FLOAT);
00192   vtkGetMacro(MaximumPropagationTime,float);
00194 
00196 
00197   vtkSetClampMacro(IntegrationDirection,int,
00198                    VTK_INTEGRATE_FORWARD,VTK_INTEGRATE_BOTH_DIRECTIONS);
00199   vtkGetMacro(IntegrationDirection,int);
00200   void SetIntegrationDirectionToForward()
00201     {this->SetIntegrationDirection(VTK_INTEGRATE_FORWARD);};
00202   void SetIntegrationDirectionToBackward()
00203     {this->SetIntegrationDirection(VTK_INTEGRATE_BACKWARD);};
00204   void SetIntegrationDirectionToIntegrateBothDirections()
00205     {this->SetIntegrationDirection(VTK_INTEGRATE_BOTH_DIRECTIONS);};
00206   const char *GetIntegrationDirectionAsString();
00208 
00210 
00212   vtkSetClampMacro(IntegrationStepLength,float,0.0000001,VTK_LARGE_FLOAT);
00213   vtkGetMacro(IntegrationStepLength,float);
00215 
00217 
00219   vtkSetMacro(SpeedScalars,int);
00220   vtkGetMacro(SpeedScalars,int);
00221   vtkBooleanMacro(SpeedScalars,int);
00223 
00225 
00230   vtkSetMacro(OrientationScalars, int);
00231   vtkGetMacro(OrientationScalars, int);
00232   vtkBooleanMacro(OrientationScalars, int);
00234 
00236 
00238   vtkSetClampMacro(TerminalSpeed,float,0.0,VTK_LARGE_FLOAT);
00239   vtkGetMacro(TerminalSpeed,float);
00241 
00243 
00248   vtkSetMacro(Vorticity,int);
00249   vtkGetMacro(Vorticity,int);
00250   vtkBooleanMacro(Vorticity,int);
00252 
00253   vtkSetMacro( NumberOfThreads, int );
00254   vtkGetMacro( NumberOfThreads, int );
00255 
00256   vtkSetMacro( SavePointInterval, float );
00257   vtkGetMacro( SavePointInterval, float );
00258 
00260 
00264   vtkSetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00265   vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
00267 
00268 protected:
00269 
00270   vtkStreamer();
00271   ~vtkStreamer();
00272 
00273   // Integrate data
00274   void Integrate();
00275 
00276   // Special method for computing streamer vorticity
00277   void ComputeVorticity();
00278 
00279   // Controls where streamlines start from (either position or location).
00280   int StartFrom;
00281 
00282   // Starting from cell location
00283   vtkIdType StartCell;
00284   int StartSubId;
00285   float StartPCoords[3];
00286 
00287   // starting from global x-y-z position
00288   float StartPosition[3];
00289 
00290   //array of streamers
00291   vtkStreamArray *Streamers;
00292   vtkIdType NumberOfStreamers;
00293 
00294   // length of Streamer is generated by time, or by MaximumSteps
00295   float MaximumPropagationTime;
00296 
00297   // integration direction
00298   int IntegrationDirection;
00299 
00300   // the length (fraction of cell size) of integration steps
00301   float IntegrationStepLength;
00302 
00303   // boolean controls whether vorticity is computed
00304   int Vorticity;
00305 
00306   // terminal propagation speed
00307   float TerminalSpeed;
00308 
00309   // boolean controls whether data scalars or velocity magnitude are used
00310   int SpeedScalars;
00311 
00312   // boolean controls whether data scalars or vorticity orientation are used
00313   int OrientationScalars;
00314 
00315   // Prototype showing the integrator type to be set by the user.
00316   vtkInitialValueProblemSolver* Integrator;
00317 
00318   // Interval with which the stream points will be stored.
00319   // Useful in reducing the memory footprint. Since the initial
00320   // value is small, by default, it will store all/most points.
00321   float SavePointInterval;
00322 
00323   static  VTK_THREAD_RETURN_TYPE ThreadedIntegrate( void *arg );
00324 
00326 
00328   vtkGetMacro( NumberOfStreamers, int );
00329   vtkStreamArray *GetStreamers() { return this->Streamers; };
00331 
00332   void InitializeThreadedIntegrate();
00333   vtkMultiThreader           *Threader;
00334   int                        NumberOfThreads;
00335 
00336 private:
00337   vtkStreamer(const vtkStreamer&);  // Not implemented.
00338   void operator=(const vtkStreamer&);  // Not implemented.
00339 };
00340 
00342 inline const char *vtkStreamer::GetIntegrationDirectionAsString(void)
00343 {
00344   if ( this->IntegrationDirection == VTK_INTEGRATE_FORWARD ) 
00345     {
00346     return "IntegrateForward";
00347     }
00348   else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD ) 
00349     {
00350     return "IntegrateBackward";
00351     }
00352   else 
00353     {
00354     return "IntegrateBothDirections";
00355     }
00356 }
00357 
00358 #endif
00359 
00360 

Generated on Thu Mar 28 14:19:22 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001