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);
118  {this->SetIntegrationDirection(VTK_INTEGRATE_FORWARD);};
120  {this->SetIntegrationDirection(VTK_INTEGRATE_BACKWARD);};
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;};
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
vtkInitialValueProblemSolver * Integrator
Definition: vtkStreamer.h:295
vtkIdType GetNumberOfPoints()
Definition: vtkStreamer.h:247
#define VTK_GRAPHICS_EXPORT
virtual int FillInputPortInformation(int port, vtkInformation *info)
int OrientationScalars
Definition: vtkStreamer.h:292
StreamPoint * GetStreamPoint(vtkIdType i)
Definition: vtkStreamer.h:248
#define VTK_DOUBLE_MAX
Definition: vtkType.h:133
vtkMultiThreader * Threader
Definition: vtkStreamer.h:316
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:58
void SetIntegrationDirectionToBackward()
Definition: vtkStreamer.h:119
#define VTK_INTEGRATE_BOTH_DIRECTIONS
Definition: vtkStreamer.h:62
A class for performing multithreaded execution.
int IntegrationDirection
Definition: vtkStreamer.h:277
int vtkIdType
Definition: vtkType.h:255
vtkIdType NumberOfStreamers
Definition: vtkStreamer.h:271
#define VTK_INTEGRATE_FORWARD
Definition: vtkStreamer.h:60
int SpeedScalars
Definition: vtkStreamer.h:289
void PrintSelf(ostream &os, vtkIndent indent)
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:37
abstract object implements integration of massless particle through vector field
Definition: vtkStreamer.h:64
int NumberOfThreads
Definition: vtkStreamer.h:317
double MaximumPropagationTime
Definition: vtkStreamer.h:274
double IntegrationStepLength
Definition: vtkStreamer.h:280
StreamArray * GetStreamers()
Definition: vtkStreamer.h:312
void SetIntegrationDirectionToForward()
Definition: vtkStreamer.h:117
vtkIdType StartCell
Definition: vtkStreamer.h:208
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
double SavePointInterval
Definition: vtkStreamer.h:304
double Epsilon
Definition: vtkStreamer.h:299
#define VTK_THREAD_RETURN_TYPE
double TerminalSpeed
Definition: vtkStreamer.h:286
const char * GetIntegrationDirectionAsString()
Definition: vtkStreamer.h:328
StreamArray * Streamers
Definition: vtkStreamer.h:270
vtkIdType InsertNextStreamPoint()
Definition: vtkStreamer.h:249
#define VTK_INTEGRATE_BACKWARD
Definition: vtkStreamer.h:61
void SetIntegrationDirectionToIntegrateBothDirections()
Definition: vtkStreamer.h:121
Integrate a set of ordinary differential equations (initial value problem) in time.