-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBluntStreamlines.tar
351 lines (292 loc) · 20 KB
/
BluntStreamlines.tar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
BluntStreamlines/ 0000755 0000765 0000024 00000000000 13424703035 015322 5 ustar lorensen staff 0000000 0000000 BluntStreamlines/BluntStreamlines.cxx 0000644 0000765 0000024 00000011342 13424703035 021342 0 ustar lorensen staff 0000000 0000000 #include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkLineSource.h>
#include <vtkMultiBlockDataSet.h>
#include <vtkMultiBlockPLOT3DReader.h>
#include <vtkNamedColors.h>
#include <vtkPointData.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
#include <vtkStreamTracer.h>
#include <vtkStructuredGrid.h>
#include <vtkStructuredGridGeometryFilter.h>
#include <vtkStructuredGridOutlineFilter.h>
int main(int argc, char* argv[])
{
if (argc != 3)
{
std::cout << "Usage: " << argv[0] << " bluntfinxyz.bin bluntfinq.bin"
<< std::endl;
return EXIT_FAILURE;
}
double range[2], c[3];
double maxTime = 0.0;
auto colors =
vtkSmartPointer<vtkNamedColors>::New();
auto aren =
vtkSmartPointer<vtkRenderer>::New();
auto renWin =
vtkSmartPointer<vtkRenderWindow>::New();
renWin->AddRenderer(aren);
auto iren =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
iren->SetRenderWindow(renWin);
std::string xyzFilename = argv[1];
std::string qFilename = argv[2];
auto reader =
vtkSmartPointer<vtkMultiBlockPLOT3DReader>::New();
reader->SetXYZFileName(xyzFilename.c_str());
reader->SetQFileName(qFilename.c_str());
reader->Update(); // force a read to occur
vtkStructuredGrid* pd =
dynamic_cast<vtkStructuredGrid*>(reader->GetOutput()->GetBlock(0));
pd->GetCenter(c);
if (pd->GetPointData()->GetScalars())
{
pd->GetPointData()->GetScalars()->GetRange(range);
}
if (pd->GetPointData()->GetVectors())
{
auto maxVelocity = pd->GetPointData()->GetVectors()->GetMaxNorm();
maxTime = 20.0 * pd->GetLength() / maxVelocity;
}
auto outlineF =
vtkSmartPointer<vtkStructuredGridOutlineFilter>::New();
outlineF->SetInputData(pd);
auto outlineMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
outlineMapper->SetInputConnection(outlineF->GetOutputPort());
auto outline =
vtkSmartPointer<vtkActor>::New();
outline->SetMapper(outlineMapper);
outline->GetProperty()->SetColor(colors->GetColor3d("Moccasin").GetData());
outline->GetProperty()->SetLineWidth(2.0);
//
// Some geometry for context
//
auto wall =
vtkSmartPointer<vtkStructuredGridGeometryFilter>::New();
wall->SetInputData(pd);
wall->SetExtent(0, 100, 0, 100, 0, 0);
auto wallMap =
vtkSmartPointer<vtkPolyDataMapper>::New();
wallMap->SetInputConnection(wall->GetOutputPort());
wallMap->ScalarVisibilityOff();
auto wallActor =
vtkSmartPointer<vtkActor>::New();
wallActor->SetMapper(wallMap);
wallActor->GetProperty()->SetColor(colors->GetColor3d("Silver").GetData());
auto fin =
vtkSmartPointer<vtkStructuredGridGeometryFilter>::New();
fin->SetInputData(pd);
fin->SetExtent(0, 100, 0, 0, 0, 100);
auto finMap =
vtkSmartPointer<vtkPolyDataMapper>::New();
finMap->SetInputConnection(fin->GetOutputPort());
finMap->ScalarVisibilityOff();
auto finActor =
vtkSmartPointer<vtkActor>::New();
finActor->SetMapper(finMap);
finActor->GetProperty()->SetColor(colors->GetColor3d("Silver").GetData());
//
// regular streamlines
//
auto line1 =
vtkSmartPointer<vtkLineSource>::New();
line1->SetResolution(25);
line1->SetPoint1(-6.36, 0.25, 0.06);
line1->SetPoint2(-6.36, 0.25, 5.37);
auto rakeMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
rakeMapper->SetInputConnection(line1->GetOutputPort());
auto rake1 =
vtkSmartPointer<vtkActor>::New();
rake1->SetMapper(rakeMapper);
rake1->GetProperty()->SetColor(0.0, 0.0, 0.0);
rake1->GetProperty()->SetLineWidth(5);
auto streamers =
vtkSmartPointer<vtkStreamTracer>::New();
// streamers->DebugOn();
streamers->SetInputConnection(reader->GetOutputPort());
streamers->SetSourceConnection(line1->GetOutputPort());
streamers->SetMaximumPropagation(maxTime);
streamers->SetInitialIntegrationStep(.2);
streamers->SetMinimumIntegrationStep(.01);
streamers->SetIntegratorType(2);
streamers->Update();
auto streamersMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
streamersMapper->SetInputConnection(streamers->GetOutputPort());
streamersMapper->SetScalarRange(range);
auto lines =
vtkSmartPointer<vtkActor>::New();
lines->SetMapper(streamersMapper);
aren->AddActor(outline);
aren->AddActor(wallActor);
aren->AddActor(finActor);
aren->AddActor(rake1);
aren->AddActor(lines);
aren->SetBackground(0.5, 0.5, 0.5);
aren->ResetCamera();
aren->GetActiveCamera()->Elevation(30.0);
aren->GetActiveCamera()->Azimuth(30.0);
aren->GetActiveCamera()->Dolly(1.2);
aren->ResetCameraClippingRange();
renWin->SetSize(640, 480);
renWin->Render();
// interact with data
iren->Start();
// Clean up
return EXIT_SUCCESS;
}