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_render_3d.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_iso_volume,test_iso_volume)38 TEST(ascent_iso_volume, test_iso_volume)
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 3D Rendering with Default Pipeline");
63
64
65 string output_path = prepare_output_dir();
66 string output_file = conduit::utils::join_file_path(output_path,"tout_iso_volume");
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"] = "isovolume";
79 // filter knobs
80 conduit::Node &clip_params = pipelines["pl1/f1/params"];
81 clip_params["field"] = "braid";
82 clip_params["min_value"] = 5.;
83 clip_params["max_value"] = 10.;
84
85 conduit::Node scenes;
86 scenes["s1/plots/p1/type"] = "pseudocolor";
87 scenes["s1/plots/p1/field"] = "radial";
88 scenes["s1/plots/p1/pipeline"] = "pl1";
89 scenes["s1/image_prefix"] = output_file;
90
91 conduit::Node actions;
92 // add the pipeline
93 conduit::Node &add_pipelines= actions.append();
94 add_pipelines["action"] = "add_pipelines";
95 add_pipelines["pipelines"] = pipelines;
96 // add the scenes
97 conduit::Node &add_scenes= actions.append();
98 add_scenes["action"] = "add_scenes";
99 add_scenes["scenes"] = scenes;
100
101 //
102 // Run Ascent
103 //
104
105 Ascent ascent;
106
107 Node ascent_opts;
108 ascent_opts["runtime/type"] = "ascent";
109 ascent.open(ascent_opts);
110 ascent.publish(data);
111 ascent.execute(actions);
112 ascent.close();
113
114 // check that we created an image
115 EXPECT_TRUE(check_test_image(output_file));
116 std::string msg = "An example of using the isovolume filter.";
117 ASCENT_ACTIONS_DUMP(actions,output_file,msg);
118 }
119
120 //-----------------------------------------------------------------------------
main(int argc,char * argv[])121 int main(int argc, char* argv[])
122 {
123 int result = 0;
124
125 ::testing::InitGoogleTest(&argc, argv);
126
127 // allow override of the data size via the command line
128 if(argc == 2)
129 {
130 EXAMPLE_MESH_SIDE_DIM = atoi(argv[1]);
131 }
132
133 result = RUN_ALL_TESTS();
134 return result;
135 }
136
137
138