From 66bdf04511e9ab999ea167fd3fa729f26c04bd93 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Tue, 30 Oct 2018 22:30:45 -0500 Subject: [PATCH] Updating RGBColor to a char array. --- include/openmc/plot.h | 2 +- src/plot.cpp | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/openmc/plot.h b/include/openmc/plot.h index a3e527456..8d9a11ff9 100644 --- a/include/openmc/plot.h +++ b/include/openmc/plot.h @@ -35,7 +35,7 @@ extern std::vector plots; //!< Plot instance container // RGBColor holds color information for plotted objects //=============================================================================== -typedef std::array RGBColor; +typedef std::array RGBColor; typedef xt::xtensor ImageData; diff --git a/src/plot.cpp b/src/plot.cpp index e1cbdb2d1..d6f54b90a 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -1,4 +1,5 @@ #include +#include #include "openmc/plot.h" #include "openmc/constants.h" @@ -22,6 +23,12 @@ namespace openmc { // Global variables //============================================================================== +const char* to_char(int i) { + std::stringstream s; + s << i; + return s.str().c_str(); + } + int PLOT_LEVEL_LOWEST = -1; std::unordered_map plot_map; @@ -30,7 +37,7 @@ int n_plots; std::vector plots; -const RGBColor WHITE = {255, 255, 255}; +const RGBColor WHITE = {static_cast(255), static_cast(255), static_cast(255)}; const RGBColor NULLRGB = {0, 0, 0}; //============================================================================== @@ -734,9 +741,9 @@ void output_ppm(Plot pl, const ImageData& data) for (int y = 0; y < pl.pixels_[1]; y++) { for (int x = 0; x < pl.pixels_[0]; x++) { RGBColor rgb = data(x,y); - of.write(reinterpret_cast(&rgb[RED]), 1); - of.write(reinterpret_cast(&rgb[GREEN]), 1); - of.write(reinterpret_cast(&rgb[BLUE]), 1); + of.write(&rgb[RED], 1); + of.write(&rgb[GREEN], 1); + of.write(&rgb[BLUE], 1); } } // Close file