1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * Copyright (C) 2004-2012 HUBzero Foundation, LLC |
---|
4 | * |
---|
5 | * Author: Leif Delgass <ldelgass@purdue.edu> |
---|
6 | */ |
---|
7 | |
---|
8 | #ifndef VTKVIS_STREAMLINES_H |
---|
9 | #define VTKVIS_STREAMLINES_H |
---|
10 | |
---|
11 | #include <vtkSmartPointer.h> |
---|
12 | #include <vtkProp.h> |
---|
13 | #include <vtkPlaneCollection.h> |
---|
14 | #include <vtkStreamTracer.h> |
---|
15 | #include <vtkPolyDataAlgorithm.h> |
---|
16 | #include <vtkPolyDataMapper.h> |
---|
17 | #include <vtkLookupTable.h> |
---|
18 | #include <vtkAssembly.h> |
---|
19 | |
---|
20 | #include "ColorMap.h" |
---|
21 | #include "GraphicsObject.h" |
---|
22 | #include "DataSet.h" |
---|
23 | |
---|
24 | namespace VtkVis { |
---|
25 | |
---|
26 | /** |
---|
27 | * \brief Streamline visualization of vector fields |
---|
28 | * |
---|
29 | * The DataSet must contain vectors |
---|
30 | */ |
---|
31 | class Streamlines : public GraphicsObject { |
---|
32 | public: |
---|
33 | enum LineType { |
---|
34 | LINES, |
---|
35 | TUBES, |
---|
36 | RIBBONS |
---|
37 | }; |
---|
38 | enum ColorMode { |
---|
39 | COLOR_BY_SCALAR, |
---|
40 | COLOR_BY_VECTOR_MAGNITUDE, |
---|
41 | COLOR_BY_VECTOR_X, |
---|
42 | COLOR_BY_VECTOR_Y, |
---|
43 | COLOR_BY_VECTOR_Z, |
---|
44 | COLOR_CONSTANT |
---|
45 | }; |
---|
46 | enum StepUnit { |
---|
47 | LENGTH_UNIT, |
---|
48 | CELL_LENGTH_UNIT |
---|
49 | }; |
---|
50 | enum IntegratorType { |
---|
51 | RUNGE_KUTTA2, |
---|
52 | RUNGE_KUTTA4, |
---|
53 | RUNGE_KUTTA45 |
---|
54 | }; |
---|
55 | enum IntegrationDirection { |
---|
56 | FORWARD, |
---|
57 | BACKWARD, |
---|
58 | BOTH |
---|
59 | }; |
---|
60 | enum SeedType { |
---|
61 | DATASET_MESH_POINTS, |
---|
62 | DATASET_FILLED_MESH, |
---|
63 | MESH_POINTS, |
---|
64 | FILLED_MESH, |
---|
65 | RAKE, |
---|
66 | DISK, |
---|
67 | POLYGON, |
---|
68 | FILLED_POLYGON |
---|
69 | }; |
---|
70 | |
---|
71 | Streamlines(); |
---|
72 | virtual ~Streamlines(); |
---|
73 | |
---|
74 | virtual const char *getClassName() const |
---|
75 | { |
---|
76 | return "Streamlines"; |
---|
77 | } |
---|
78 | |
---|
79 | virtual void setDataSet(DataSet *dataSet, |
---|
80 | Renderer *renderer); |
---|
81 | |
---|
82 | virtual void setLighting(bool state); |
---|
83 | |
---|
84 | virtual void setOpacity(double opacity); |
---|
85 | |
---|
86 | virtual void setVisibility(bool state); |
---|
87 | |
---|
88 | virtual bool getVisibility(); |
---|
89 | |
---|
90 | virtual void setColor(float color[3]); |
---|
91 | |
---|
92 | virtual void setEdgeVisibility(bool state); |
---|
93 | |
---|
94 | virtual void setEdgeColor(float color[3]); |
---|
95 | |
---|
96 | virtual void setEdgeWidth(float edgeWidth); |
---|
97 | |
---|
98 | virtual void setClippingPlanes(vtkPlaneCollection *planes); |
---|
99 | |
---|
100 | void setNumberOfSeedPoints(int numPoints); |
---|
101 | |
---|
102 | void setSeedToMeshPoints(int maxPoints = 500); |
---|
103 | |
---|
104 | void setSeedToFilledMesh(int numPoints); |
---|
105 | |
---|
106 | void setSeedToMeshPoints(vtkDataSet *ds, int maxPoints = 500); |
---|
107 | |
---|
108 | void setSeedToFilledMesh(vtkDataSet *ds, int numPoints); |
---|
109 | |
---|
110 | void setSeedToRake(double start[3], double end[3], int numPoints); |
---|
111 | |
---|
112 | void setSeedToDisk(double center[3], double normal[3], |
---|
113 | double radius, double innerRadius, int numPoints); |
---|
114 | |
---|
115 | void setSeedToPolygon(double center[3], double normal[3], |
---|
116 | double angle, double radius, |
---|
117 | int numSides); |
---|
118 | |
---|
119 | void setSeedToFilledPolygon(double center[3], double normal[3], |
---|
120 | double angle, double radius, |
---|
121 | int numSides, int numPoints); |
---|
122 | |
---|
123 | void setIntegrator(IntegratorType integrator); |
---|
124 | |
---|
125 | void setIntegrationDirection(IntegrationDirection dir); |
---|
126 | |
---|
127 | void setIntegrationStepUnit(StepUnit unit); |
---|
128 | |
---|
129 | void setInitialIntegrationStep(double step); |
---|
130 | |
---|
131 | void setMinimumIntegrationStep(double step); |
---|
132 | |
---|
133 | void setMaximumIntegrationStep(double step); |
---|
134 | |
---|
135 | void setMaximumError(double error); |
---|
136 | |
---|
137 | void setMaxPropagation(double length); |
---|
138 | |
---|
139 | void setMaxNumberOfSteps(int steps); |
---|
140 | |
---|
141 | void setTerminalSpeed(double speed); |
---|
142 | |
---|
143 | void setLineTypeToLines(); |
---|
144 | |
---|
145 | void setLineTypeToTubes(int numSides, double radius); |
---|
146 | |
---|
147 | void setLineTypeToRibbons(double width, double angle); |
---|
148 | |
---|
149 | void setColorMode(ColorMode mode, DataSet::DataAttributeType type, |
---|
150 | const char *name, double range[2] = NULL); |
---|
151 | |
---|
152 | void setColorMode(ColorMode mode, |
---|
153 | const char *name, double range[2] = NULL); |
---|
154 | |
---|
155 | void setColorMode(ColorMode mode); |
---|
156 | |
---|
157 | void setColorMap(ColorMap *colorMap); |
---|
158 | |
---|
159 | /** |
---|
160 | * \brief Return the ColorMap in use |
---|
161 | */ |
---|
162 | ColorMap *getColorMap() |
---|
163 | { |
---|
164 | return _colorMap; |
---|
165 | } |
---|
166 | |
---|
167 | void updateColorMap(); |
---|
168 | |
---|
169 | virtual void updateRanges(Renderer *renderer); |
---|
170 | |
---|
171 | void setSeedVisibility(bool state); |
---|
172 | |
---|
173 | void setSeedColor(float color[3]); |
---|
174 | |
---|
175 | void setSeedPointSize(float size); |
---|
176 | |
---|
177 | private: |
---|
178 | virtual void initProp(); |
---|
179 | virtual void update(); |
---|
180 | |
---|
181 | static double getRandomNum(double min, double max); |
---|
182 | static void getRandomPoint(double pt[3], const double bounds[6]); |
---|
183 | static void getRandomPointInTriangle(double pt[3], |
---|
184 | const double v0[3], |
---|
185 | const double v1[3], |
---|
186 | const double v2[3]); |
---|
187 | static void getRandomPointOnLineSegment(double pt[3], |
---|
188 | const double endpt[3], |
---|
189 | const double endpt2[3]); |
---|
190 | static void getRandomPointInTetrahedron(double pt[3], |
---|
191 | const double v0[3], |
---|
192 | const double v1[3], |
---|
193 | const double v2[3], |
---|
194 | const double v3[3]); |
---|
195 | static void getRandomCellPt(double pt[3], vtkDataSet *ds); |
---|
196 | |
---|
197 | LineType _lineType; |
---|
198 | ColorMap *_colorMap; |
---|
199 | ColorMode _colorMode; |
---|
200 | std::string _colorFieldName; |
---|
201 | DataSet::DataAttributeType _colorFieldType; |
---|
202 | double _colorFieldRange[2]; |
---|
203 | SeedType _seedType; |
---|
204 | float _seedColor[3]; |
---|
205 | bool _seedVisible; |
---|
206 | double _vectorMagnitudeRange[2]; |
---|
207 | double _vectorComponentRange[3][2]; |
---|
208 | Renderer *_renderer; |
---|
209 | double _dataScale; |
---|
210 | |
---|
211 | vtkSmartPointer<vtkLookupTable> _lut; |
---|
212 | vtkSmartPointer<vtkActor> _linesActor; |
---|
213 | vtkSmartPointer<vtkActor> _seedActor; |
---|
214 | vtkSmartPointer<vtkDataSet> _seedMesh; |
---|
215 | vtkSmartPointer<vtkAlgorithm> _mesher; |
---|
216 | vtkSmartPointer<vtkStreamTracer> _streamTracer; |
---|
217 | vtkSmartPointer<vtkPolyDataAlgorithm> _lineFilter; |
---|
218 | vtkSmartPointer<vtkPolyDataMapper> _pdMapper; |
---|
219 | vtkSmartPointer<vtkPolyDataMapper> _seedMapper; |
---|
220 | }; |
---|
221 | |
---|
222 | } |
---|
223 | |
---|
224 | #endif |
---|