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