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 =========================================================================*/
53 #ifndef vtkStreamer_h
54 #define vtkStreamer_h
55 
56 #include "vtkFiltersFlowPathsModule.h" // For export macro
57 #include "vtkPolyDataAlgorithm.h"
58 
60 class vtkMultiThreader;
61 
62 #ifndef VTK_LEGACY_REMOVE
63 
64 #define VTK_INTEGRATE_FORWARD 0
65 #define VTK_INTEGRATE_BACKWARD 1
66 #define VTK_INTEGRATE_BOTH_DIRECTIONS 2
67 
68 class VTKFILTERSFLOWPATHS_EXPORT vtkStreamer : public vtkPolyDataAlgorithm
69 {
70 public:
72  void PrintSelf(ostream& os, vtkIndent indent);
73 
78  void SetStartLocation(vtkIdType cellId, int subId, double pcoords[3]);
79 
84  void SetStartLocation(vtkIdType cellId, int subId, double r, double s,
85  double t);
86 
90  vtkIdType GetStartLocation(int& subId, double pcoords[3]);
91 
97  void SetStartPosition(double x[3]);
98 
104  void SetStartPosition(double x, double y, double z);
105 
109  double *GetStartPosition();
110 
112 
115  void SetSourceData(vtkDataSet *source);
116  vtkDataSet *GetSource();
118 
123  void SetSourceConnection(vtkAlgorithmOutput* algOutput);
124 
126 
129  vtkSetClampMacro(MaximumPropagationTime,double,0.0,VTK_DOUBLE_MAX);
130  vtkGetMacro(MaximumPropagationTime,double);
132 
134 
137  vtkSetClampMacro(IntegrationDirection,int,
139  vtkGetMacro(IntegrationDirection,int);
141  {this->SetIntegrationDirection(VTK_INTEGRATE_FORWARD);};
143  {this->SetIntegrationDirection(VTK_INTEGRATE_BACKWARD);};
145  {this->SetIntegrationDirection(VTK_INTEGRATE_BOTH_DIRECTIONS);};
146  const char *GetIntegrationDirectionAsString();
148 
150 
154  vtkSetClampMacro(IntegrationStepLength,double,0.0000001,VTK_DOUBLE_MAX);
155  vtkGetMacro(IntegrationStepLength,double);
157 
159 
163  vtkSetMacro(SpeedScalars,int);
164  vtkGetMacro(SpeedScalars,int);
165  vtkBooleanMacro(SpeedScalars,int);
167 
169 
176  vtkSetMacro(OrientationScalars, int);
177  vtkGetMacro(OrientationScalars, int);
178  vtkBooleanMacro(OrientationScalars, int);
180 
182 
186  vtkSetClampMacro(TerminalSpeed,double,0.0,VTK_DOUBLE_MAX);
187  vtkGetMacro(TerminalSpeed,double);
189 
191 
198  vtkSetMacro(Vorticity,int);
199  vtkGetMacro(Vorticity,int);
200  vtkBooleanMacro(Vorticity,int);
202 
203  vtkSetMacro( NumberOfThreads, int );
204  vtkGetMacro( NumberOfThreads, int );
205 
206  vtkSetMacro( SavePointInterval, double );
207  vtkGetMacro( SavePointInterval, double );
208 
210 
217  void SetIntegrator(vtkInitialValueProblemSolver *);
218  vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
220 
222 
226  vtkSetMacro(Epsilon,double);
227  vtkGetMacro(Epsilon,double);
229 
230 protected:
232 
237  vtkStreamer();
238  ~vtkStreamer();
240 
241  // Integrate data
242  void Integrate(vtkDataSet *input, vtkDataSet *source);
243 
244  // Controls where streamlines start from (either position or location).
246 
247  // Starting from cell location
250  double StartPCoords[3];
251 
252  // starting from global x-y-z position
253  double StartPosition[3];
254 
255  //
256  // Special classes for manipulating data
257  //
258  class StreamPoint {
259  public:
260  double x[3]; // position
261  vtkIdType cellId; // cell
262  int subId; // cell sub id
263  double p[3]; // parametric coords in cell
264  double v[3]; // velocity
265  double speed; // velocity norm
266  double s; // scalar value
267  double t; // time travelled so far
268  double d; // distance travelled so far
269  double omega; // stream vorticity, if computed
270  double theta; // rotation angle, if vorticity is computed
271  };
272 
273  class StreamArray;
274  friend class StreamArray;
275  class StreamArray { //;prevent man page generation
276  public:
277  StreamArray();
279  {
280  delete [] this->Array;
281  };
282  vtkIdType GetNumberOfPoints() {return this->MaxId + 1;};
283  StreamPoint *GetStreamPoint(vtkIdType i) {return this->Array + i;};
285  {
286  if ( ++this->MaxId >= this->Size )
287  {
288  this->Resize(this->MaxId);
289  }
290  return this->MaxId; //return offset from array
291  }
292  StreamPoint *Resize(vtkIdType sz); //reallocates data
293  void Reset() {this->MaxId = -1;};
294 
295  StreamPoint *Array; // pointer to data
296  vtkIdType MaxId; // maximum index inserted thus far
297  vtkIdType Size; // allocated size of data
298  vtkIdType Extend; // grow array by this amount
299  double Direction; // integration direction
300  };
301 
302  //
303 
304  //array of streamers
307 
308  // length of Streamer is generated by time, or by MaximumSteps
310 
311  // integration direction
313 
314  // the length (fraction of cell size) of integration steps
316 
317  // boolean controls whether vorticity is computed
319 
320  // terminal propagation speed
322 
323  // boolean controls whether data scalars or velocity magnitude are used
325 
326  // boolean controls whether data scalars or vorticity orientation are used
328 
329  // Prototype showing the integrator type to be set by the user.
331 
332  // A positive value, as small as possible for numerical comparison.
333  // The initial value is 1E-12.
334  double Epsilon;
335 
336  // Interval with which the stream points will be stored.
337  // Useful in reducing the memory footprint. Since the initial
338  // value is small, by default, it will store all/most points.
340 
341  static VTK_THREAD_RETURN_TYPE ThreadedIntegrate( void *arg );
342 
344 
348  vtkGetMacro( NumberOfStreamers, vtkIdType );
349  StreamArray *GetStreamers() { return this->Streamers; };
351 
352  void InitializeThreadedIntegrate();
355 
357 
358 private:
359  vtkStreamer(const vtkStreamer&) VTK_DELETE_FUNCTION;
360  void operator=(const vtkStreamer&) VTK_DELETE_FUNCTION;
361 };
362 
364 
367 inline const char *vtkStreamer::GetIntegrationDirectionAsString()
368 {
369  if ( this->IntegrationDirection == VTK_INTEGRATE_FORWARD )
370  {
371  return "IntegrateForward";
372  }
373  else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD )
374  {
375  return "IntegrateBackward";
376  }
377  else
378  {
379  return "IntegrateBothDirections";
380  }
381 }
383 
384 #endif // VTK_LEGACY_REMOVE
385 #endif
vtkInitialValueProblemSolver * Integrator
Definition: vtkStreamer.h:330
vtkIdType GetNumberOfPoints()
Definition: vtkStreamer.h:282
int OrientationScalars
Definition: vtkStreamer.h:327
StreamPoint * GetStreamPoint(vtkIdType i)
Definition: vtkStreamer.h:283
#define VTK_DOUBLE_MAX
Definition: vtkType.h:163
vtkMultiThreader * Threader
Definition: vtkStreamer.h:353
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
void SetIntegrationDirectionToBackward()
Specify the direction in which to integrate the Streamer.
Definition: vtkStreamer.h:142
#define VTK_INTEGRATE_BOTH_DIRECTIONS
Definition: vtkStreamer.h:66
A class for performing multithreaded execution.
int IntegrationDirection
Definition: vtkStreamer.h:312
int vtkIdType
Definition: vtkType.h:287
vtkIdType NumberOfStreamers
Definition: vtkStreamer.h:306
#define VTK_INTEGRATE_FORWARD
Definition: vtkStreamer.h:64
int SpeedScalars
Definition: vtkStreamer.h:324
Proxy object to connect input/output ports.
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:39
abstract object implements integration of massless particle through vector field
Definition: vtkStreamer.h:68
int NumberOfThreads
Definition: vtkStreamer.h:354
double MaximumPropagationTime
Definition: vtkStreamer.h:309
double IntegrationStepLength
Definition: vtkStreamer.h:315
StreamArray * GetStreamers()
These methods were added to allow access to these variables from the threads.
Definition: vtkStreamer.h:349
void SetIntegrationDirectionToForward()
Specify the direction in which to integrate the Streamer.
Definition: vtkStreamer.h:140
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkIdType StartCell
Definition: vtkStreamer.h:248
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
double SavePointInterval
Definition: vtkStreamer.h:339
double Epsilon
Definition: vtkStreamer.h:334
#define VTK_THREAD_RETURN_TYPE
double TerminalSpeed
Definition: vtkStreamer.h:321
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
StreamArray * Streamers
Definition: vtkStreamer.h:305
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkIdType InsertNextStreamPoint()
Definition: vtkStreamer.h:284
#define VTK_INTEGRATE_BACKWARD
Definition: vtkStreamer.h:65
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetIntegrationDirectionToIntegrateBothDirections()
Specify the direction in which to integrate the Streamer.
Definition: vtkStreamer.h:144
Integrate a set of ordinary differential equations (initial value problem) in time.