diff --git a/include/openmc/plot.h b/include/openmc/plot.h index f3e482696..64c092ce8 100644 --- a/include/openmc/plot.h +++ b/include/openmc/plot.h @@ -36,7 +36,7 @@ struct RGBColor { RGBColor() : red(0), green(0), blue(0) { }; RGBColor(const int v[3]) : red(v[0]), green(v[1]), blue(v[2]) { }; RGBColor(int r, int g, int b) : red(r), green(g), blue(b) { }; - + RGBColor(const std::vector &v) { if (v.size() != 3) { throw std::out_of_range("Incorrect vector size for RGBColor."); @@ -49,7 +49,7 @@ struct RGBColor { // Members uint8_t red, green, blue; }; - + typedef xt::xtensor ImageData; enum class PlotType { @@ -67,7 +67,7 @@ enum class PlotColorBy { cells = 1, mats = 2 }; - + //=============================================================================== // Plot class //=============================================================================== @@ -176,6 +176,6 @@ void create_voxel(Plot pl); //! \return RGBColor with random value RGBColor random_color(); - + } // namespace openmc #endif // OPENMC_PLOT_H diff --git a/src/plot.cpp b/src/plot.cpp index 6a28d2653..7b0cddb63 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -22,7 +22,7 @@ namespace openmc { //============================================================================== // Global variables //============================================================================== - + int PLOT_LEVEL_LOWEST = -1; std::unordered_map plot_map; @@ -241,7 +241,7 @@ Plot::set_bg_color(pugi::xml_node plot_node) { // Copy plot background color if (check_for_node(plot_node, "background")) { - std::vector bg_rgb = get_node_array(plot_node, "background"); + std::vector bg_rgb = get_node_array(plot_node, "background"); if (PlotType::voxel == type_) { if (openmc_master) { std::stringstream err_msg; @@ -391,7 +391,7 @@ Plot::set_user_colors(pugi::xml_node plot_node) warning(err_msg); } } - + for (auto cn : plot_node.children("color")) { // Make sure 3 values are specified for RGB std::vector user_rgb = get_node_array(cn, "rgb"); @@ -549,7 +549,7 @@ Plot::set_mask(pugi::xml_node plot_node) { // Deal with masks pugi::xpath_node_set mask_nodes = plot_node.select_nodes("mask"); - + if (!mask_nodes.empty()) { if (PlotType::voxel == type_) { if (openmc_master) { @@ -564,7 +564,7 @@ Plot::set_mask(pugi::xml_node plot_node) pugi::xml_node mask_node = mask_nodes[0].node(); // Determine how many components there are and allocate - std::vector iarray = get_node_array(mask_node, "components"); + std::vector iarray = get_node_array(mask_node, "components"); if (iarray.size() == 0) { std::stringstream err_msg; err_msg << "Missing in mask of plot " << id_; @@ -748,7 +748,7 @@ void draw_mesh_lines(Plot pl, ImageData& data) xyz_ur_plot[0] = pl.origin_[0]; xyz_ur_plot[1] = pl.origin_[1]; xyz_ur_plot[2] = pl.origin_[2]; - + xyz_ll_plot[outer] = pl.origin_[outer] - pl.width_[0] / 2.; xyz_ll_plot[inner] = pl.origin_[inner] - pl.width_[1] / 2.; xyz_ur_plot[outer] = pl.origin_[outer] + pl.width_[0] / 2.; @@ -961,12 +961,7 @@ voxel_finalize(hid_t dspace, hid_t dset, hid_t memspace) } RGBColor random_color() { - RGBColor rgb; - rgb.red = int(prn()*255); - rgb.green = int(prn()*255); - rgb.blue = int(prn()*255); - return rgb; - // return {int(prn()*255), int(prn()*255), int(prn()*255)}; + return {int(prn()*255), int(prn()*255), int(prn()*255)}; } } // namespace openmc diff --git a/src/progress_bar.cpp b/src/progress_bar.cpp index 8518c10fa..7917f9ffd 100644 --- a/src/progress_bar.cpp +++ b/src/progress_bar.cpp @@ -28,7 +28,7 @@ void ProgressBar::set_value(double val) { if (!is_terminal()) return; - + // set the bar percentage if (val >= 100.0) { bar.append("100"); @@ -43,12 +43,12 @@ ProgressBar::set_value(double val) { bar.append("% |"); // remaining width of the bar int remaining_width = BAR_WIDTH - bar.size() - 2; - + // set the bar width if (val >= 100.0) { bar.append(remaining_width, '='); } else if (val < 0.0) { - bar.append(remaining_width, ' '); + bar.append(remaining_width, ' '); } else { int width = (int)((double)remaining_width*val/100); bar.append(width, '='); @@ -57,11 +57,11 @@ ProgressBar::set_value(double val) { } bar.append("|+"); - + // write the bar std::cout << '\r' << bar << std::flush; if (val >= 100.0) { std::cout << "\n"; } - + // reset the bar value bar = ""; }