1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
2 // Copyright (c) Lawrence Livermore National Security, LLC and other Ascent
3 // Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
4 // other details. No copyright assignment is required to contribute to Ascent.
5 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
6
7 //-----------------------------------------------------------------------------
8 ///
9 /// file: t_ascent_slice.cpp
10 ///
11 //-----------------------------------------------------------------------------
12
13
14 #include "gtest/gtest.h"
15
16 #include <ascent.hpp>
17
18 #include <iostream>
19 #include <math.h>
20
21 #include <conduit_blueprint.hpp>
22
23 #include "t_config.hpp"
24 #include "t_utils.hpp"
25
26
27
28
29 using namespace std;
30 using namespace conduit;
31 using namespace ascent;
32
33
34 index_t EXAMPLE_MESH_SIDE_DIM = 20;
35
36
37 //-----------------------------------------------------------------------------
TEST(ascent_slice,test_slice)38 TEST(ascent_slice, test_slice)
39 {
40 // the vtkm runtime is currently our only rendering runtime
41 Node n;
42 ascent::about(n);
43 // only run this test if ascent was built with vtkm support
44 if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
45 {
46 ASCENT_INFO("Ascent vtkm support disabled, skipping test");
47 return;
48 }
49
50 //
51 // Create an example mesh.
52 //
53 Node data, verify_info;
54 conduit::blueprint::mesh::examples::braid("hexs",
55 EXAMPLE_MESH_SIDE_DIM,
56 EXAMPLE_MESH_SIDE_DIM,
57 EXAMPLE_MESH_SIDE_DIM,
58 data);
59
60 EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));
61
62 ASCENT_INFO("Testing slice");
63
64
65 string output_path = prepare_output_dir();
66 string output_file = conduit::utils::join_file_path(output_path,"tout_slice_3d");
67
68 // remove old images before rendering
69 remove_test_image(output_file);
70
71
72 //
73 // Create the actions.
74 //
75
76 conduit::Node pipelines;
77 // pipeline 1
78 pipelines["pl1/f1/type"] = "slice";
79 // filter knobs
80 conduit::Node &slice_params = pipelines["pl1/f1/params"];
81 slice_params["point/x"] = 0.f;
82 slice_params["point/y"] = 0.f;
83 slice_params["point/z"] = 0.f;
84
85 slice_params["normal/x"] = 0.f;
86 slice_params["normal/y"] = 0.f;
87 slice_params["normal/z"] = 1.f;
88
89 conduit::Node scenes;
90 scenes["s1/plots/p1/type"] = "pseudocolor";
91 scenes["s1/plots/p1/field"] = "radial";
92 scenes["s1/plots/p1/pipeline"] = "pl1";
93 scenes["s1/image_prefix"] = output_file;
94
95 conduit::Node actions;
96 // add the pipeline
97 conduit::Node &add_pipelines = actions.append();
98 add_pipelines["action"] = "add_pipelines";
99 add_pipelines["pipelines"] = pipelines;
100 // add the scenes
101 conduit::Node &add_scenes= actions.append();
102 add_scenes["action"] = "add_scenes";
103 add_scenes["scenes"] = scenes;
104
105 //
106 // Run Ascent
107 //
108
109 Ascent ascent;
110
111 Node ascent_opts;
112 ascent_opts["runtime/type"] = "ascent";
113 ascent.open(ascent_opts);
114 ascent.publish(data);
115 ascent.execute(actions);
116 ascent.close();
117
118 // check that we created an image
119 EXPECT_TRUE(check_test_image(output_file));
120 std::string msg = "An example of the slice filter with a single plane.";
121 ASCENT_ACTIONS_DUMP(actions,output_file,msg);
122 }
123
124
125 //-----------------------------------------------------------------------------
TEST(ascent_slice,test_exaslice)126 TEST(ascent_slice, test_exaslice)
127 {
128 // the vtkm runtime is currently our only rendering runtime
129 Node n;
130 ascent::about(n);
131 // only run this test if ascent was built with vtkm support
132 if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
133 {
134 ASCENT_INFO("Ascent vtkm support disabled, skipping test");
135 return;
136 }
137
138 //
139 // Create an example mesh.
140 //
141 Node data, verify_info;
142 conduit::blueprint::mesh::examples::braid("hexs",
143 EXAMPLE_MESH_SIDE_DIM,
144 EXAMPLE_MESH_SIDE_DIM,
145 EXAMPLE_MESH_SIDE_DIM,
146 data);
147
148 EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));
149
150 ASCENT_INFO("Testing slice");
151
152
153 string output_path = prepare_output_dir();
154 string output_file = conduit::utils::join_file_path(output_path,"tout_exaslice_3d");
155
156 // remove old images before rendering
157 remove_test_image(output_file);
158
159
160 //
161 // Create the actions.
162 //
163
164 conduit::Node pipelines;
165 // pipeline 1
166 pipelines["pl1/f1/type"] = "exaslice";
167 // filter knobs
168 conduit::Node &slice_params = pipelines["pl1/f1/params"];
169 slice_params["point/x"] = 0.f;
170 slice_params["point/y"] = 0.f;
171 slice_params["point/z"] = 0.f;
172
173 slice_params["normal/x"] = 0.f;
174 slice_params["normal/y"] = 0.f;
175 slice_params["normal/z"] = 1.f;
176
177 conduit::Node scenes;
178 scenes["s1/plots/p1/type"] = "pseudocolor";
179 scenes["s1/plots/p1/field"] = "radial";
180 scenes["s1/plots/p1/pipeline"] = "pl1";
181 scenes["s1/image_prefix"] = output_file;
182
183 conduit::Node actions;
184 // add the pipeline
185 conduit::Node &add_pipelines = actions.append();
186 add_pipelines["action"] = "add_pipelines";
187 add_pipelines["pipelines"] = pipelines;
188 // add the scenes
189 conduit::Node &add_scenes= actions.append();
190 add_scenes["action"] = "add_scenes";
191 add_scenes["scenes"] = scenes;
192
193 //
194 // Run Ascent
195 //
196
197 Ascent ascent;
198
199 Node ascent_opts;
200 ascent_opts["runtime/type"] = "ascent";
201 ascent.open(ascent_opts);
202 ascent.publish(data);
203 ascent.execute(actions);
204 ascent.close();
205
206 // check that we created an image
207 EXPECT_TRUE(check_test_image(output_file));
208 std::string msg = "An example of the slice filter with a single plane.";
209 ASCENT_ACTIONS_DUMP(actions,output_file,msg);
210 }
211
212
213 //-----------------------------------------------------------------------------
TEST(ascent_slice,test_slice_offset)214 TEST(ascent_slice, test_slice_offset)
215 {
216 // the vtkm runtime is currently our only rendering runtime
217 Node n;
218 ascent::about(n);
219 // only run this test if ascent was built with vtkm support
220 if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
221 {
222 ASCENT_INFO("Ascent vtkm support disabled, skipping test");
223 return;
224 }
225
226 //
227 // Create an example mesh.
228 //
229 Node data, verify_info;
230 conduit::blueprint::mesh::examples::braid("hexs",
231 EXAMPLE_MESH_SIDE_DIM,
232 EXAMPLE_MESH_SIDE_DIM,
233 EXAMPLE_MESH_SIDE_DIM,
234 data);
235
236 EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));
237
238 ASCENT_INFO("Testing slice");
239
240
241 string output_path = prepare_output_dir();
242 string output_file = conduit::utils::join_file_path(output_path,"tout_slice_offset_3d");
243
244 // remove old images before rendering
245 remove_test_image(output_file);
246
247
248 //
249 // Create the actions.
250 //
251
252 conduit::Node pipelines;
253 // pipeline 1
254 pipelines["pl1/f1/type"] = "slice";
255 // filter knobs
256 conduit::Node &slice_params = pipelines["pl1/f1/params"];
257 slice_params["point/x_offset"] = 0.f;
258 slice_params["point/y_offset"] = -0.5f;
259 slice_params["point/z_offset"] = 0.f;
260
261 slice_params["normal/x"] = 1.f;
262 slice_params["normal/y"] = 1.f;
263 slice_params["normal/z"] = 1.f;
264
265 conduit::Node scenes;
266 scenes["s1/plots/p1/type"] = "pseudocolor";
267 scenes["s1/plots/p1/field"] = "radial";
268 scenes["s1/plots/p1/pipeline"] = "pl1";
269 scenes["s1/image_prefix"] = output_file;
270
271 conduit::Node actions;
272 // add the pipeline
273 conduit::Node &add_pipelines = actions.append();
274 add_pipelines["action"] = "add_pipelines";
275 add_pipelines["pipelines"] = pipelines;
276 // add the scenes
277 conduit::Node &add_scenes= actions.append();
278 add_scenes["action"] = "add_scenes";
279 add_scenes["scenes"] = scenes;
280
281 //
282 // Run Ascent
283 //
284
285 Ascent ascent;
286
287 Node ascent_opts;
288 ascent_opts["runtime/type"] = "ascent";
289 ascent.open(ascent_opts);
290 ascent.publish(data);
291 ascent.execute(actions);
292 ascent.close();
293
294 // check that we created an image
295 EXPECT_TRUE(check_test_image(output_file));
296 std::string msg = "An example of the slice filter with a single plane.";
297 ASCENT_ACTIONS_DUMP(actions,output_file,msg);
298 }
299 //-----------------------------------------------------------------------------
TEST(ascent_slice,test_slice_off_axis)300 TEST(ascent_slice, test_slice_off_axis)
301 {
302 // the vtkm runtime is currently our only rendering runtime
303 Node n;
304 ascent::about(n);
305 // only run this test if ascent was built with vtkm support
306 if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
307 {
308 ASCENT_INFO("Ascent vtkm support disabled, skipping test");
309 return;
310 }
311
312 //
313 // Create an example mesh.
314 //
315 Node data, verify_info;
316 conduit::blueprint::mesh::examples::braid("hexs",
317 EXAMPLE_MESH_SIDE_DIM,
318 EXAMPLE_MESH_SIDE_DIM,
319 EXAMPLE_MESH_SIDE_DIM,
320 data);
321
322 EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));
323
324 ASCENT_INFO("Testing slice off axis");
325
326
327 string output_path = prepare_output_dir();
328 string output_file = conduit::utils::join_file_path(output_path,"tout_slice_3d_off_axis");
329
330 // remove old images before rendering
331 remove_test_image(output_file);
332
333
334 //
335 // Create the actions.
336 //
337
338 conduit::Node pipelines;
339 // pipeline 1
340 pipelines["pl1/f1/type"] = "slice";
341 // filter knobs
342 conduit::Node &slice_params = pipelines["pl1/f1/params"];
343 slice_params["point/x"] = 1.f;
344 slice_params["point/y"] = 1.f;
345 slice_params["point/z"] = 1.f;
346
347 slice_params["normal/x"] = 0.f;
348 slice_params["normal/y"] = 0.f;
349 slice_params["normal/z"] = 1.f;
350
351 conduit::Node scenes;
352 scenes["s1/plots/p1/type"] = "pseudocolor";
353 scenes["s1/plots/p1/field"] = "radial";
354 scenes["s1/plots/p1/pipeline"] = "pl1";
355 scenes["s1/image_prefix"] = output_file;
356
357 conduit::Node actions;
358 // add the pipeline
359 conduit::Node &add_pipelines = actions.append();
360 add_pipelines["action"] = "add_pipelines";
361 add_pipelines["pipelines"] = pipelines;
362 // add the scenes
363 conduit::Node &add_scenes= actions.append();
364 add_scenes["action"] = "add_scenes";
365 add_scenes["scenes"] = scenes;
366
367 //
368 // Run Ascent
369 //
370
371 Ascent ascent;
372
373 Node ascent_opts;
374 ascent_opts["runtime/type"] = "ascent";
375 ascent.open(ascent_opts);
376 ascent.publish(data);
377 ascent.execute(actions);
378 ascent.close();
379
380 // check that we created an image
381 // NOTE: RELAXED TOLERANCE TO FROM default
382 // to mitigate differences between platforms
383 EXPECT_TRUE(check_test_image(output_file, 0.01f));
384 std::string msg = "An example of the slice filter with a single plane (off-axis).";
385 ASCENT_ACTIONS_DUMP(actions,output_file,msg);
386 }
387 //-----------------------------------------------------------------------------
388 //-----------------------------------------------------------------------------
TEST(ascent_slice,test_3slice)389 TEST(ascent_slice, test_3slice)
390 {
391 Node n;
392 ascent::about(n);
393 // only run this test if ascent was built with vtkm support
394 if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
395 {
396 ASCENT_INFO("Ascent vtkm support disabled, skipping test");
397 return;
398 }
399
400 //
401 // Create an example mesh.
402 //
403 Node data, verify_info;
404 conduit::blueprint::mesh::examples::braid("hexs",
405 EXAMPLE_MESH_SIDE_DIM,
406 EXAMPLE_MESH_SIDE_DIM,
407 EXAMPLE_MESH_SIDE_DIM,
408 data);
409
410 EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));
411
412 ASCENT_INFO("Testing 3slice");
413
414
415 string output_path = prepare_output_dir();
416 string output_file = conduit::utils::join_file_path(output_path,"tout_3slice_3d");
417
418 // remove old images before rendering
419 remove_test_image(output_file);
420
421
422 //
423 // Create the actions.
424 //
425
426 conduit::Node pipelines;
427 // pipeline 1
428 pipelines["pl1/f1/type"] = "3slice";
429 // filter knobs (all these are optional)
430
431 conduit::Node &slice_params = pipelines["pl1/f1/params"];
432 slice_params["x_offset"] = 1.f; // largest value on the x-axis
433 slice_params["y_offset"] = 0.f; // middle of the y-axis
434 slice_params["z_offset"] = -1.f; // smalles value of the z-axis
435
436 conduit::Node scenes;
437 scenes["s1/plots/p1/type"] = "pseudocolor";
438 scenes["s1/plots/p1/field"] = "radial";
439 scenes["s1/plots/p1/pipeline"] = "pl1";
440
441 scenes["s1/image_prefix"] = output_file;
442
443 conduit::Node actions;
444 // add the pipeline
445 conduit::Node &add_pipelines = actions.append();
446 add_pipelines["action"] = "add_pipelines";
447 add_pipelines["pipelines"] = pipelines;
448 // add the scenes
449 conduit::Node &add_scenes= actions.append();
450 add_scenes["action"] = "add_scenes";
451 add_scenes["scenes"] = scenes;
452
453 //
454 // Run Ascent
455 //
456
457 Ascent ascent;
458
459 Node ascent_opts;
460 ascent_opts["runtime/type"] = "ascent";
461 ascent.open(ascent_opts);
462 ascent.publish(data);
463 ascent.execute(actions);
464 ascent.close();
465
466 // check that we created an image
467 EXPECT_TRUE(check_test_image(output_file));
468 std::string msg = "An example of the three slice filter.";
469 ASCENT_ACTIONS_DUMP(actions,output_file,msg);
470 }
471 //-----------------------------------------------------------------------------
main(int argc,char * argv[])472 int main(int argc, char* argv[])
473 {
474 int result = 0;
475
476 ::testing::InitGoogleTest(&argc, argv);
477
478 // allow override of the data size via the command line
479 if(argc == 2)
480 {
481 EXAMPLE_MESH_SIDE_DIM = atoi(argv[1]);
482 }
483
484 result = RUN_ALL_TESTS();
485 return result;
486 }
487
488
489