VTK
vtkStreamer.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkStreamer.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
52 #ifndef __vtkStreamer_h
53 #define __vtkStreamer_h
54 
55 #include "vtkPolyDataAlgorithm.h"
56 
58 class vtkMultiThreader;
59 
60 #define VTK_INTEGRATE_FORWARD 0
61 #define VTK_INTEGRATE_BACKWARD 1
62 #define VTK_INTEGRATE_BOTH_DIRECTIONS 2
63 
65 {
66 public:
68  void PrintSelf(ostream& os, vtkIndent indent);
69 
73  void SetStartLocation(vtkIdType cellId, int subId, double pcoords[3]);
74 
76 
79  void SetStartLocation(vtkIdType cellId, int subId, double r, double s,
80  double t);
82 
85  vtkIdType GetStartLocation(int& subId, double pcoords[3]);
86 
90  void SetStartPosition(double x[3]);
91 
95  void SetStartPosition(double x, double y, double z);
96 
98  double *GetStartPosition();
99 
101 
102  void SetSource(vtkDataSet *source);
103  vtkDataSet *GetSource();
105 
107 
108  vtkSetClampMacro(MaximumPropagationTime,double,0.0,VTK_DOUBLE_MAX);
109  vtkGetMacro(MaximumPropagationTime,double);
111 
113 
114  vtkSetClampMacro(IntegrationDirection,int,
116  vtkGetMacro(IntegrationDirection,int);
117  void SetIntegrationDirectionToForward()
118  {this->SetIntegrationDirection(VTK_INTEGRATE_FORWARD);};
119  void SetIntegrationDirectionToBackward()
120  {this->SetIntegrationDirection(VTK_INTEGRATE_BACKWARD);};
121  void SetIntegrationDirectionToIntegrateBothDirections()
122  {this->SetIntegrationDirection(VTK_INTEGRATE_BOTH_DIRECTIONS);};
123  const char *GetIntegrationDirectionAsString();
125 
127 
129  vtkSetClampMacro(IntegrationStepLength,double,0.0000001,VTK_DOUBLE_MAX);
130  vtkGetMacro(IntegrationStepLength,double);
132 
134 
136  vtkSetMacro(SpeedScalars,int);
137  vtkGetMacro(SpeedScalars,int);
138  vtkBooleanMacro(SpeedScalars,int);
140 
142 
147  vtkSetMacro(OrientationScalars, int);
148  vtkGetMacro(OrientationScalars, int);
149  vtkBooleanMacro(OrientationScalars, int);
151 
153 
155  vtkSetClampMacro(TerminalSpeed,double,0.0,VTK_DOUBLE_MAX);
156  vtkGetMacro(TerminalSpeed,double);
158 
160 
165  vtkSetMacro(Vorticity,int);
166  vtkGetMacro(Vorticity,int);
167  vtkBooleanMacro(Vorticity,int);
169 
170  vtkSetMacro( NumberOfThreads, int );
171  vtkGetMacro( NumberOfThreads, int );
172 
173  vtkSetMacro( SavePointInterval, double );
174  vtkGetMacro( SavePointInterval, double );
175 
177 
181  void SetIntegrator(vtkInitialValueProblemSolver *);
182  vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
184 
186 
188  vtkSetMacro(Epsilon,double);
189  vtkGetMacro(Epsilon,double);
191 
192 protected:
194 
197  vtkStreamer();
198  ~vtkStreamer();
200 
201  // Integrate data
202  void Integrate(vtkDataSet *input, vtkDataSet *source);
203 
204  // Controls where streamlines start from (either position or location).
206 
207  // Starting from cell location
210  double StartPCoords[3];
211 
212  // starting from global x-y-z position
213  double StartPosition[3];
214 
215  //
216  // Special classes for manipulating data
217  //
218  //BTX - begin tcl exclude
219  //
220  class StreamPoint {
221  public:
222  double x[3]; // position
223  vtkIdType cellId; // cell
224  int subId; // cell sub id
225  double p[3]; // parametric coords in cell
226  double v[3]; // velocity
227  double speed; // velocity norm
228  double s; // scalar value
229  double t; // time travelled so far
230  double d; // distance travelled so far
231  double omega; // stream vorticity, if computed
232  double theta; // rotation angle, if vorticity is computed
233  };
234 
235  class StreamArray;
236  friend class StreamArray;
237  class StreamArray { //;prevent man page generation
238  public:
239  StreamArray();
241  {
242  if (this->Array)
243  {
244  delete [] this->Array;
245  }
246  };
247  vtkIdType GetNumberOfPoints() {return this->MaxId + 1;};
248  StreamPoint *GetStreamPoint(vtkIdType i) {return this->Array + i;};
249  vtkIdType InsertNextStreamPoint()
250  {
251  if ( ++this->MaxId >= this->Size )
252  {
253  this->Resize(this->MaxId);
254  }
255  return this->MaxId; //return offset from array
256  }
257  StreamPoint *Resize(vtkIdType sz); //reallocates data
258  void Reset() {this->MaxId = -1;};
259 
260  StreamPoint *Array; // pointer to data
261  vtkIdType MaxId; // maximum index inserted thus far
262  vtkIdType Size; // allocated size of data
263  vtkIdType Extend; // grow array by this amount
264  double Direction; // integration direction
265  };
266  //ETX
267  //
268 
269  //array of streamers
272 
273  // length of Streamer is generated by time, or by MaximumSteps
275 
276  // integration direction
278 
279  // the length (fraction of cell size) of integration steps
281 
282  // boolean controls whether vorticity is computed
284 
285  // terminal propagation speed
287 
288  // boolean controls whether data scalars or velocity magnitude are used
290 
291  // boolean controls whether data scalars or vorticity orientation are used
293 
294  // Prototype showing the integrator type to be set by the user.
296 
297  // A positive value, as small as possible for numerical comparison.
298  // The initial value is 1E-12.
299  double Epsilon;
300 
301  // Interval with which the stream points will be stored.
302  // Useful in reducing the memory footprint. Since the initial
303  // value is small, by default, it will store all/most points.
305 
306  static VTK_THREAD_RETURN_TYPE ThreadedIntegrate( void *arg );
307 
309 
311  vtkGetMacro( NumberOfStreamers, vtkIdType );
312  StreamArray *GetStreamers() { return this->Streamers; };
314 
315  void InitializeThreadedIntegrate();
318 
320 
321 private:
322  vtkStreamer(const vtkStreamer&); // Not implemented.
323  void operator=(const vtkStreamer&); // Not implemented.
324 };
325 
327 
329 {
331  {
332  return "IntegrateForward";
333  }
334  else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD )
335  {
336  return "IntegrateBackward";
337  }
338  else
339  {
340  return "IntegrateBothDirections";
341  }
342 }
344 
345 #endif