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_threshold,test_threshold_3d)38 TEST(ascent_threshold, test_threshold_3d)
39 {
40     Node n;
41     ascent::about(n);
42     // only run this test if ascent was built with vtkm support
43     if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
44     {
45         ASCENT_INFO("Ascent vtkm support disabled, skipping test");
46         return;
47     }
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_threshold_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"] = "threshold";
79     // filter knobs
80     conduit::Node &thresh_params = pipelines["pl1/f1/params"];
81     thresh_params["field"] = "braid";
82     thresh_params["min_value"] = -0.2;
83     thresh_params["max_value"] = 0.2;
84 
85     conduit::Node scenes;
86     scenes["s1/plots/p1/type"]         = "pseudocolor";
87     scenes["s1/plots/p1/field"] = "braid";
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 threshold filter.";
117     ASCENT_ACTIONS_DUMP(actions,output_file,msg);
118 }
119 
120 
121 //-----------------------------------------------------------------------------
main(int argc,char * argv[])122 int main(int argc, char* argv[])
123 {
124     int result = 0;
125 
126     ::testing::InitGoogleTest(&argc, argv);
127 
128     // allow override of the data size via the command line
129     if(argc == 2)
130     {
131         EXAMPLE_MESH_SIDE_DIM = atoi(argv[1]);
132     }
133 
134     result = RUN_ALL_TESTS();
135     return result;
136 }
137 
138 
139