Streamer.hh 7.22 KB
Newer Older
Will Schroeder's avatar
Will Schroeder committed
1
2
/*=========================================================================

Ken Martin's avatar
Ken Martin committed
3
  Program:   Visualization Toolkit
Will Schroeder's avatar
Will Schroeder committed
4
5
6
7
8
  Module:    Streamer.hh
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

Ken Martin's avatar
Ken Martin committed
9
This file is part of the Visualization Toolkit. No part of this file
Will Schroeder's avatar
Will Schroeder committed
10
11
12
13
14
15
or its contents may be copied, reproduced or altered in any way
without the express written consent of the authors.

Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994 

=========================================================================*/
Ken Martin's avatar
Ken Martin committed
16
// .NAME vtkStreamer - abstract object implements integration of massless particle through vector field
Will Schroeder's avatar
Will Schroeder committed
17
// .SECTION Description
Ken Martin's avatar
Ken Martin committed
18
// vtkStreamer is a filter that integrates a massless particle through a vector
Will Schroeder's avatar
Will Schroeder committed
19
// field. The integration is performed using 2cnd order Runge-Kutta method. 
Ken Martin's avatar
Ken Martin committed
20
21
// vtkStreamer often serves as a base class for other classes that perform 
// numerical integration through a vector field (e.g., vtkStreamLine).
Will Schroeder's avatar
Will Schroeder committed
22
23
//    Note that vtkStreamer can integrate both forward and backward in time,
// or in both directions. The length of the streamer time) is controlled by 
Will Schroeder's avatar
Will Schroeder committed
24
// specifying an elapsed time. (The elapsed time is the time each particle 
Will Schroeder's avatar
Will Schroeder committed
25
26
// travels). Otherwise, the integration terminates after exiting the dataset or
// if the particle speed is reduced to a value less than the terminal speed.
Ken Martin's avatar
Ken Martin committed
27
//    vtkStreamer integrates through any type of dataset. Thus if the dataset
Will Schroeder's avatar
Will Schroeder committed
28
29
30
31
32
33
34
// contains 2D cells such as polygons or triangles, the integration is
// constrained to lie on the surface defined by the 2D cells.
//    The starting point of streamers may be defined in three different ways.
// Starting from global x-y-z "position" allows you to start a single streamer
// at a specified x-y-z coordinate. Starting from "location" allows you to 
// start at a specified cell, subId, and parametric coordinate. Finally, you 
// may specify a source object to start multiple streamers. If you start 
Will Schroeder's avatar
Will Schroeder committed
35
36
37
38
39
40
41
42
43
44
// streamers using a source object, for each point in the source that is 
// inside the dataset a streamer is created.
//    vtkStreamer implements the integration process in the Integrate() method.
// Because vtkStreamer does not implement the Execute() method that its 
// superclass (i.e., Filter) requires, it is an abstract class. Its subclasses
// implement the execute method and use the Integrate() method and then build
// their own representation of the integration path (i.e., lines, dashed 
// lines, points, etc.).
// .SECTION See Also
// vtkStreamLine, vtkDashedStreamLine, vtkStreamPoints
Will Schroeder's avatar
Will Schroeder committed
45

Ken Martin's avatar
Ken Martin committed
46
47
#ifndef __vtkStreamer_h
#define __vtkStreamer_h
Will Schroeder's avatar
Will Schroeder committed
48
49
50
51
52
53
54
55
56
57

#include "DS2PolyF.hh"

#define INTEGRATE_FORWARD 0
#define INTEGRATE_BACKWARD 1
#define INTEGRATE_BOTH_DIRECTIONS 2

#define START_FROM_POSITION 0
#define START_FROM_LOCATION 1

Ken Martin's avatar
Ken Martin committed
58
typedef struct _vtkStreamPoint {
Will Schroeder's avatar
Will Schroeder committed
59
60
61
62
63
64
65
66
67
68
69
    float   x[3];    // position 
    int     cellId;  // cell
    int     subId;   // cell sub id
    float   p[3];    // parametric coords in cell 
    float   v[3];    // velocity 
    float   speed;   // velocity norm 
    float   s;       // scalar value 
    float   t;       // time travelled so far 
    float   d;       // distance travelled so far 
    float   w[3];    // vorticity (if vorticity is computed)
    float   n[3];    // normal (if vorticity is computed)
Ken Martin's avatar
Ken Martin committed
70
} vtkStreamPoint;
Will Schroeder's avatar
Will Schroeder committed
71
72
73
74
75
76

//
// Special classes for manipulating data
//
//BTX - begin tcl exclude
//
Ken Martin's avatar
Ken Martin committed
77
class vtkStreamArray { //;prevent man page generation
Will Schroeder's avatar
Will Schroeder committed
78
public:
Ken Martin's avatar
Ken Martin committed
79
80
  vtkStreamArray();
  ~vtkStreamArray() {if (this->Array) delete [] this->Array;};
Will Schroeder's avatar
Will Schroeder committed
81
  int GetNumberOfPoints() {return this->MaxId + 1;};
Ken Martin's avatar
Ken Martin committed
82
83
  vtkStreamPoint *GetStreamPoint(int i) {return this->Array + i;};
  vtkStreamPoint *InsertNextStreamPoint() 
Will Schroeder's avatar
Will Schroeder committed
84
85
86
87
    {
    if ( ++this->MaxId >= this->Size ) this->Resize(this->MaxId);
    return this->Array + this->MaxId;
    }
Ken Martin's avatar
Ken Martin committed
88
  vtkStreamPoint *Resize(int sz); //reallocates data
Will Schroeder's avatar
Will Schroeder committed
89
90
  void Reset() {this->MaxId = -1;};

Ken Martin's avatar
Ken Martin committed
91
  vtkStreamPoint *Array;  // pointer to data
Will Schroeder's avatar
Will Schroeder committed
92
93
94
95
  int MaxId;              // maximum index inserted thus far
  int Size;               // allocated size of data
  int Extend;             // grow array by this amount
  float Direction;        // integration direction
Will Schroeder's avatar
Will Schroeder committed
96
97
98
99
};
//ETX - end tcl exclude
//

Ken Martin's avatar
Ken Martin committed
100
class vtkStreamer : public vtkDataSetToPolyFilter
Will Schroeder's avatar
Will Schroeder committed
101
102
{
public:
Ken Martin's avatar
Ken Martin committed
103
104
105
106
  vtkStreamer();
  ~vtkStreamer() {};
  char *GetClassName() {return "vtkStreamer";};
  void PrintSelf(ostream& os, vtkIndent indent);
Will Schroeder's avatar
Will Schroeder committed
107
108

  void SetStartLocation(int cellId, int subId, float pcoords[3]);
109
  void SetStartLocation(int cellId, int subId, float r, float s, float t);
Will Schroeder's avatar
Will Schroeder committed
110
111
112
  int GetStartLocation(int& subId, float pcoords[3]);

  void SetStartPosition(float x[3]);
113
  void SetStartPosition(float x, float y, float z);
Will Schroeder's avatar
Will Schroeder committed
114
115
116
117
118
119
  float *GetStartPosition();

  void Update();

  // Description:
  // Specify the source object used to generate starting points.
Ken Martin's avatar
Ken Martin committed
120
121
  vtkSetObjectMacro(Source,vtkDataSet);
  vtkGetObjectMacro(Source,vtkDataSet);
Will Schroeder's avatar
Will Schroeder committed
122
123
124

  // Description:
  // Specify the maximum length of the Streamer expressed in elapsed time.
Ken Martin's avatar
Ken Martin committed
125
126
  vtkSetClampMacro(MaximumPropagationTime,float,0.0,LARGE_FLOAT);
  vtkGetMacro(MaximumPropagationTime,float);
Will Schroeder's avatar
Will Schroeder committed
127
128
129

  // Description:
  // Specify the direction in which to integrate the Streamer.
Ken Martin's avatar
Ken Martin committed
130
  vtkSetClampMacro(IntegrationDirection,int,
Will Schroeder's avatar
Will Schroeder committed
131
                  INTEGRATE_FORWARD,INTEGRATE_BOTH_DIRECTIONS);
Ken Martin's avatar
Ken Martin committed
132
  vtkGetMacro(IntegrationDirection,int);
Will Schroeder's avatar
Will Schroeder committed
133
134
135
136

  // Description:
  // Specify a nominal integration step size (expressed as a fraction of
  // the size of each cell).
Ken Martin's avatar
Ken Martin committed
137
138
  vtkSetClampMacro(IntegrationStepLength,float,0.001,0.5);
  vtkGetMacro(IntegrationStepLength,float);
Will Schroeder's avatar
Will Schroeder committed
139
140
141
142

  // Description:
  // Turn on/off the creation of scalar data from velocity magnitude. If off,
  // and input dataset has scalars, input dataset scalars are used.
Ken Martin's avatar
Ken Martin committed
143
144
145
  vtkSetMacro(SpeedScalars,int);
  vtkGetMacro(SpeedScalars,int);
  vtkBooleanMacro(SpeedScalars,int);
Will Schroeder's avatar
Will Schroeder committed
146
147
148
149

  // Description:
  // Set/get terminal speed (i.e., speed is velocity magnitude).  Terminal 
  // speed is speed at which streamer will terminate propagation.
Ken Martin's avatar
Ken Martin committed
150
151
  vtkSetClampMacro(TerminalSpeed,float,0.0,LARGE_FLOAT);
  vtkGetMacro(TerminalSpeed,float);
Will Schroeder's avatar
Will Schroeder committed
152
153

  // Description:
Will Schroeder's avatar
Will Schroeder committed
154
155
156
  // Turn on/off the computation of vorticity. Vorticity is an indication of
  // the rotation of the flow. In combination with vtkStreamLine and 
  // vtkTubeFilter can be used to create rotated tubes.
Ken Martin's avatar
Ken Martin committed
157
158
159
  vtkSetMacro(Vorticity,int);
  vtkGetMacro(Vorticity,int);
  vtkBooleanMacro(Vorticity,int);
Will Schroeder's avatar
Will Schroeder committed
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179

protected:
  // Integrate data
  void Integrate();

  // Special method for computing streamer vorticity
  void ComputeVorticity();

  // Controls where streamlines start from (either position or location).
  int StartFrom;

  // Starting from cell location
  int StartCell;
  int StartSubId;
  float StartPCoords[3];

  // starting from global x-y-z position
  float StartPosition[3];

  //points used to seed streamlines  
Ken Martin's avatar
Ken Martin committed
180
  vtkDataSet *Source; 
Will Schroeder's avatar
Will Schroeder committed
181
182

  //array of streamers
Ken Martin's avatar
Ken Martin committed
183
  vtkStreamArray *Streamers;
Will Schroeder's avatar
Will Schroeder committed
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
  int NumberOfStreamers;

  // length of Streamer is generated by time, or by MaximumSteps
  float MaximumPropagationTime;

  // integration direction
  int IntegrationDirection;

  // the length (fraction of cell size) of integration steps
  float IntegrationStepLength;

  // boolean controls whether vorticity is computed
  int Vorticity;

  // terminal propagation speed
  float TerminalSpeed;

  // boolean controls whether data scalars or velocity magnitude are used
  int SpeedScalars;
};

#endif