VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
65 class VTKFILTERSFLOWPATHS_EXPORT vtkStreamer : public vtkPolyDataAlgorithm
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
213  vtkIdType StartCell;
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  if (this->Array)
248  {
249  delete [] this->Array;
250  }
251  };
252  vtkIdType GetNumberOfPoints() {return this->MaxId + 1;};
253  StreamPoint *GetStreamPoint(vtkIdType i) {return this->Array + i;};
255  {
256  if ( ++this->MaxId >= this->Size )
257  {
258  this->Resize(this->MaxId);
259  }
260  return this->MaxId; //return offset from array
261  }
262  StreamPoint *Resize(vtkIdType sz); //reallocates data
263  void Reset() {this->MaxId = -1;};
264 
265  StreamPoint *Array; // pointer to data
266  vtkIdType MaxId; // maximum index inserted thus far
267  vtkIdType Size; // allocated size of data
268  vtkIdType Extend; // grow array by this amount
269  double Direction; // integration direction
270  };
271  //ETX
272  //
273 
274  //array of streamers
276  vtkIdType NumberOfStreamers;
277 
278  // length of Streamer is generated by time, or by MaximumSteps
280 
281  // integration direction
283 
284  // the length (fraction of cell size) of integration steps
286 
287  // boolean controls whether vorticity is computed
289 
290  // terminal propagation speed
292 
293  // boolean controls whether data scalars or velocity magnitude are used
295 
296  // boolean controls whether data scalars or vorticity orientation are used
298 
299  // Prototype showing the integrator type to be set by the user.
301 
302  // A positive value, as small as possible for numerical comparison.
303  // The initial value is 1E-12.
304  double Epsilon;
305 
306  // Interval with which the stream points will be stored.
307  // Useful in reducing the memory footprint. Since the initial
308  // value is small, by default, it will store all/most points.
310 
311  static VTK_THREAD_RETURN_TYPE ThreadedIntegrate( void *arg );
312 
314 
316  vtkGetMacro( NumberOfStreamers, vtkIdType );
317  StreamArray *GetStreamers() { return this->Streamers; };
319 
320  void InitializeThreadedIntegrate();
321  vtkMultiThreader *Threader;
323 
324  virtual int FillInputPortInformation(int port, vtkInformation *info);
325 
326 private:
327  vtkStreamer(const vtkStreamer&); // Not implemented.
328  void operator=(const vtkStreamer&); // Not implemented.
329 };
330 
332 
334 {
336  {
337  return "IntegrateForward";
338  }
339  else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD )
340  {
341  return "IntegrateBackward";
342  }
343  else
344  {
345  return "IntegrateBothDirections";
346  }
347 }
349 
350 #endif
vtkInitialValueProblemSolver * Integrator
Definition: vtkStreamer.h:300
vtkIdType GetNumberOfPoints()
Definition: vtkStreamer.h:252
virtual int FillInputPortInformation(int port, vtkInformation *info)
int OrientationScalars
Definition: vtkStreamer.h:297
StreamPoint * GetStreamPoint(vtkIdType i)
Definition: vtkStreamer.h:253
vtkMultiThreader * Threader
Definition: vtkStreamer.h:321
void SetIntegrationDirectionToBackward()
Definition: vtkStreamer.h:124
#define VTK_INTEGRATE_BOTH_DIRECTIONS
Definition: vtkStreamer.h:63
int IntegrationDirection
Definition: vtkStreamer.h:282
vtkIdType NumberOfStreamers
Definition: vtkStreamer.h:276
#define VTK_INTEGRATE_FORWARD
Definition: vtkStreamer.h:61
int SpeedScalars
Definition: vtkStreamer.h:294
Proxy object to connect input/output ports.
void PrintSelf(ostream &os, vtkIndent indent)
Superclass for algorithms that produce only polydata as output.
abstract object implements integration of massless particle through vector field
Definition: vtkStreamer.h:65
int NumberOfThreads
Definition: vtkStreamer.h:322
double MaximumPropagationTime
Definition: vtkStreamer.h:279
double IntegrationStepLength
Definition: vtkStreamer.h:285
StreamArray * GetStreamers()
Definition: vtkStreamer.h:317
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:309
double Epsilon
Definition: vtkStreamer.h:304
double TerminalSpeed
Definition: vtkStreamer.h:291
const char * GetIntegrationDirectionAsString()
Definition: vtkStreamer.h:333
StreamArray * Streamers
Definition: vtkStreamer.h:275
vtkIdType InsertNextStreamPoint()
Definition: vtkStreamer.h:254
#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.