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 "vtkFiltersFlowPathsModule.h" // For export macro
56 #include "vtkPolyDataAlgorithm.h"
57 
59 class vtkMultiThreader;
60 
61 #define VTK_INTEGRATE_FORWARD 0
62 #define VTK_INTEGRATE_BACKWARD 1
63 #define VTK_INTEGRATE_BOTH_DIRECTIONS 2
64 
66 {
67 public:
69  void PrintSelf(ostream& os, vtkIndent indent);
70 
74  void SetStartLocation(vtkIdType cellId, int subId, double pcoords[3]);
75 
77 
80  void SetStartLocation(vtkIdType cellId, int subId, double r, double s,
81  double t);
83 
86  vtkIdType GetStartLocation(int& subId, double pcoords[3]);
87 
91  void SetStartPosition(double x[3]);
92 
96  void SetStartPosition(double x, double y, double z);
97 
99  double *GetStartPosition();
100 
102 
103  void SetSourceData(vtkDataSet *source);
104  vtkDataSet *GetSource();
106 
109  void SetSourceConnection(vtkAlgorithmOutput* algOutput);
110 
112 
113  vtkSetClampMacro(MaximumPropagationTime,double,0.0,VTK_DOUBLE_MAX);
114  vtkGetMacro(MaximumPropagationTime,double);
116 
118 
119  vtkSetClampMacro(IntegrationDirection,int,
121  vtkGetMacro(IntegrationDirection,int);
123  {this->SetIntegrationDirection(VTK_INTEGRATE_FORWARD);};
125  {this->SetIntegrationDirection(VTK_INTEGRATE_BACKWARD);};
127  {this->SetIntegrationDirection(VTK_INTEGRATE_BOTH_DIRECTIONS);};
128  const char *GetIntegrationDirectionAsString();
130 
132 
134  vtkSetClampMacro(IntegrationStepLength,double,0.0000001,VTK_DOUBLE_MAX);
135  vtkGetMacro(IntegrationStepLength,double);
137 
139 
141  vtkSetMacro(SpeedScalars,int);
142  vtkGetMacro(SpeedScalars,int);
143  vtkBooleanMacro(SpeedScalars,int);
145 
147 
152  vtkSetMacro(OrientationScalars, int);
153  vtkGetMacro(OrientationScalars, int);
154  vtkBooleanMacro(OrientationScalars, int);
156 
158 
160  vtkSetClampMacro(TerminalSpeed,double,0.0,VTK_DOUBLE_MAX);
161  vtkGetMacro(TerminalSpeed,double);
163 
165 
170  vtkSetMacro(Vorticity,int);
171  vtkGetMacro(Vorticity,int);
172  vtkBooleanMacro(Vorticity,int);
174 
175  vtkSetMacro( NumberOfThreads, int );
176  vtkGetMacro( NumberOfThreads, int );
177 
178  vtkSetMacro( SavePointInterval, double );
179  vtkGetMacro( SavePointInterval, double );
180 
182 
186  void SetIntegrator(vtkInitialValueProblemSolver *);
187  vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
189 
191 
193  vtkSetMacro(Epsilon,double);
194  vtkGetMacro(Epsilon,double);
196 
197 protected:
199 
202  vtkStreamer();
203  ~vtkStreamer();
205 
206  // Integrate data
207  void Integrate(vtkDataSet *input, vtkDataSet *source);
208 
209  // Controls where streamlines start from (either position or location).
211 
212  // Starting from cell location
215  double StartPCoords[3];
216 
217  // starting from global x-y-z position
218  double StartPosition[3];
219 
220  //
221  // Special classes for manipulating data
222  //
223  //BTX - begin tcl exclude
224  //
225  class StreamPoint {
226  public:
227  double x[3]; // position
228  vtkIdType cellId; // cell
229  int subId; // cell sub id
230  double p[3]; // parametric coords in cell
231  double v[3]; // velocity
232  double speed; // velocity norm
233  double s; // scalar value
234  double t; // time travelled so far
235  double d; // distance travelled so far
236  double omega; // stream vorticity, if computed
237  double theta; // rotation angle, if vorticity is computed
238  };
239 
240  class StreamArray;
241  friend class StreamArray;
242  class StreamArray { //;prevent man page generation
243  public:
244  StreamArray();
246  {
247  delete [] this->Array;
248  };
249  vtkIdType GetNumberOfPoints() {return this->MaxId + 1;};
250  StreamPoint *GetStreamPoint(vtkIdType i) {return this->Array + i;};
252  {
253  if ( ++this->MaxId >= this->Size )
254  {
255  this->Resize(this->MaxId);
256  }
257  return this->MaxId; //return offset from array
258  }
259  StreamPoint *Resize(vtkIdType sz); //reallocates data
260  void Reset() {this->MaxId = -1;};
261 
262  StreamPoint *Array; // pointer to data
263  vtkIdType MaxId; // maximum index inserted thus far
264  vtkIdType Size; // allocated size of data
265  vtkIdType Extend; // grow array by this amount
266  double Direction; // integration direction
267  };
268  //ETX
269  //
270 
271  //array of streamers
274 
275  // length of Streamer is generated by time, or by MaximumSteps
277 
278  // integration direction
280 
281  // the length (fraction of cell size) of integration steps
283 
284  // boolean controls whether vorticity is computed
286 
287  // terminal propagation speed
289 
290  // boolean controls whether data scalars or velocity magnitude are used
292 
293  // boolean controls whether data scalars or vorticity orientation are used
295 
296  // Prototype showing the integrator type to be set by the user.
298 
299  // A positive value, as small as possible for numerical comparison.
300  // The initial value is 1E-12.
301  double Epsilon;
302 
303  // Interval with which the stream points will be stored.
304  // Useful in reducing the memory footprint. Since the initial
305  // value is small, by default, it will store all/most points.
307 
308  static VTK_THREAD_RETURN_TYPE ThreadedIntegrate( void *arg );
309 
311 
313  vtkGetMacro( NumberOfStreamers, vtkIdType );
314  StreamArray *GetStreamers() { return this->Streamers; };
316 
317  void InitializeThreadedIntegrate();
320 
322 
323 private:
324  vtkStreamer(const vtkStreamer&); // Not implemented.
325  void operator=(const vtkStreamer&); // Not implemented.
326 };
327 
329 
331 {
333  {
334  return "IntegrateForward";
335  }
336  else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD )
337  {
338  return "IntegrateBackward";
339  }
340  else
341  {
342  return "IntegrateBothDirections";
343  }
344 }
346 
347 #endif
#define VTKFILTERSFLOWPATHS_EXPORT
vtkInitialValueProblemSolver * Integrator
Definition: vtkStreamer.h:297
vtkIdType GetNumberOfPoints()
Definition: vtkStreamer.h:249
virtual int FillInputPortInformation(int port, vtkInformation *info)
int OrientationScalars
Definition: vtkStreamer.h:294
StreamPoint * GetStreamPoint(vtkIdType i)
Definition: vtkStreamer.h:250
#define VTK_DOUBLE_MAX
Definition: vtkType.h:142
vtkMultiThreader * Threader
Definition: vtkStreamer.h:318
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
void SetIntegrationDirectionToBackward()
Definition: vtkStreamer.h:124
#define VTK_INTEGRATE_BOTH_DIRECTIONS
Definition: vtkStreamer.h:63
A class for performing multithreaded execution.
int IntegrationDirection
Definition: vtkStreamer.h:279
int vtkIdType
Definition: vtkType.h:275
vtkIdType NumberOfStreamers
Definition: vtkStreamer.h:273
#define VTK_INTEGRATE_FORWARD
Definition: vtkStreamer.h:61
int SpeedScalars
Definition: vtkStreamer.h:291
Proxy object to connect input/output ports.
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:38
abstract object implements integration of massless particle through vector field
Definition: vtkStreamer.h:65
int NumberOfThreads
Definition: vtkStreamer.h:319
double MaximumPropagationTime
Definition: vtkStreamer.h:276
double IntegrationStepLength
Definition: vtkStreamer.h:282
StreamArray * GetStreamers()
Definition: vtkStreamer.h:314
void SetIntegrationDirectionToForward()
Definition: vtkStreamer.h:122
vtkIdType StartCell
Definition: vtkStreamer.h:213
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
double SavePointInterval
Definition: vtkStreamer.h:306
double Epsilon
Definition: vtkStreamer.h:301
#define VTK_THREAD_RETURN_TYPE
double TerminalSpeed
Definition: vtkStreamer.h:288
const char * GetIntegrationDirectionAsString()
Definition: vtkStreamer.h:330
StreamArray * Streamers
Definition: vtkStreamer.h:272
vtkIdType InsertNextStreamPoint()
Definition: vtkStreamer.h:251
#define VTK_INTEGRATE_BACKWARD
Definition: vtkStreamer.h:62
void SetIntegrationDirectionToIntegrateBothDirections()
Definition: vtkStreamer.h:126
Integrate a set of ordinary differential equations (initial value problem) in time.