diff --git a/include/openmc/plot.h b/include/openmc/plot.h index 0f4b5166b..c71950fca 100644 --- a/include/openmc/plot.h +++ b/include/openmc/plot.h @@ -71,6 +71,19 @@ namespace openmc { std::vector colors; std::string path_plot; + private: + void set_id(pugi::xml_node plot_node); + void set_type(pugi::xml_node plot_node); + void set_output_path(pugi::xml_node plot_node); + void set_bg_color(pugi::xml_node plot_node); + void set_basis(pugi::xml_node plot_node); + void set_origin(pugi::xml_node plot_node); + void set_width(pugi::xml_node plot_node); + void set_universe(pugi::xml_node plot_node); + void set_default_colors(pugi::xml_node plot_node); + void set_user_colors(pugi::xml_node plot_node); + void set_meshlines(pugi::xml_node plot_node); + void set_mask(pugi::xml_node plot_node); }; //extern "C" int openmc_plot_geometry(); diff --git a/src/plot.cpp b/src/plot.cpp index 3c7d4cbb3..4e9d49597 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -152,10 +152,9 @@ void create_ppm(ObjectPlot* pl) { } - ObjectPlot::ObjectPlot(pugi::xml_node plot_node) : - index_meshlines_mesh(-1) { - - // Copy data into plots +void +ObjectPlot::set_id(pugi::xml_node plot_node) { + // Copy data into plots if (check_for_node(plot_node, "id")) { id = std::stoi(get_node_value(plot_node, "id")); } else { @@ -170,6 +169,10 @@ void create_ppm(ObjectPlot* pl) { fatal_error(err_msg.str()); } +} + +void +ObjectPlot::set_type(pugi::xml_node plot_node) { // Copy plot type // Default is slice std::string type_str = "slice"; @@ -188,8 +191,11 @@ void create_ppm(ObjectPlot* pl) { << "' in plot " << id; fatal_error(err_msg.str()); } - } + } +} +void +ObjectPlot::set_output_path(pugi::xml_node plot_node) { // Set output file path std::stringstream filename; filename << "plot_" << id; @@ -234,8 +240,11 @@ void create_ppm(ObjectPlot* pl) { fatal_error(err_msg.str()); } } +} - // Copy plot background color +void +ObjectPlot::set_bg_color(pugi::xml_node plot_node){ + // Copy plot background color std::vector bg_rgb; if (check_for_node(plot_node, "background")) { if (PLOT_TYPE::VOXEL == type) { @@ -263,7 +272,10 @@ void create_ppm(ObjectPlot* pl) { not_found.rgb[1] = 255; not_found.rgb[2] = 255; } +} +void +ObjectPlot::set_basis(pugi::xml_node plot_node) { // Copy plot basis if (PLOT_TYPE::SLICE == type) { std::string pl_basis = "xy"; @@ -284,7 +296,10 @@ void create_ppm(ObjectPlot* pl) { fatal_error(err_msg); } } +} +void +ObjectPlot::set_origin(pugi::xml_node plot_node) { // Copy plotting origin std::vector pl_origin; if (node_word_count(plot_node, "origin") == 3) { @@ -298,8 +313,11 @@ void create_ppm(ObjectPlot* pl) { << id; fatal_error(err_msg); } +} - // Copy plotting width +void +ObjectPlot::set_width(pugi::xml_node plot_node) { + // Copy plotting width std::vector pl_width; if (PLOT_TYPE::SLICE == type) { if (node_word_count(plot_node, "width") == 2) { @@ -325,7 +343,10 @@ void create_ppm(ObjectPlot* pl) { fatal_error(err_msg); } } +} +void +ObjectPlot::set_universe(pugi::xml_node plot_node) { // Copy plot universe level if (check_for_node(plot_node, "level")) { level = std::stoi(get_node_value(plot_node, "level")); @@ -337,7 +358,10 @@ void create_ppm(ObjectPlot* pl) { } else { level = PLOT_LEVEL_LOWEST; } +} +void +ObjectPlot::set_default_colors(pugi::xml_node plot_node) { // Copy plot color type and initialize all colors randomly std::string pl_color_by = "cell"; if (check_for_node(plot_node, "color_by")) { @@ -370,8 +394,11 @@ void create_ppm(ObjectPlot* pl) { << "' in plot " << id; fatal_error(err_msg); } +} - // Get the number of nodes and get a list of them +void +ObjectPlot::set_user_colors(pugi::xml_node plot_node) { + // Get the number of nodes and get a list of them std::vector color_nodes; color_nodes = get_child_nodes(plot_node, "color"); @@ -439,9 +466,11 @@ void create_ppm(ObjectPlot* pl) { } } // color node loop } +} - - // Deal with meshlines +void +ObjectPlot::set_meshlines(pugi::xml_node plot_node) { + // Deal with meshlines std::vector mesh_line_nodes; mesh_line_nodes = get_child_nodes(plot_node, "meshlines"); @@ -566,8 +595,11 @@ void create_ppm(ObjectPlot* pl) { fatal_error(err_msg); } } +} - // Deal with masks +void +ObjectPlot::set_mask(pugi::xml_node plot_node) { + // Deal with masks std::vector mask_nodes; mask_nodes = get_child_nodes(plot_node, "mask"); int n_masks = mask_nodes.size(); @@ -648,6 +680,34 @@ void create_ppm(ObjectPlot* pl) { fatal_error(err_msg); } } +} + +ObjectPlot::ObjectPlot(pugi::xml_node plot_node) + : index_meshlines_mesh(-1) { + + set_id(plot_node); + + set_type(plot_node); + + set_output_path(plot_node); + + set_bg_color(plot_node); + + set_basis(plot_node); + + set_origin(plot_node); + + set_width(plot_node); + + set_universe(plot_node); + + set_default_colors(plot_node); + + set_user_colors(plot_node); + + set_meshlines(plot_node); + + set_mask(plot_node); } // End ObjectPlot constructor