Removing RGB index defs. Writing to ppm more cleanly.

This commit is contained in:
Patrick Shriwise 2018-11-02 22:33:09 -05:00
parent 148c588a39
commit daffe0923d
2 changed files with 10 additions and 38 deletions

View file

@ -18,10 +18,6 @@ namespace openmc {
// Global variables
//===============================================================================
constexpr int RED = 0;
constexpr int GREEN = 1;
constexpr int BLUE = 2;
extern int PLOT_LEVEL_LOWEST; //!< lower bound on plot universe level
extern std::unordered_map<int, int> plot_map; //!< map of plot ids to index
@ -38,7 +34,7 @@ extern std::vector<Plot> plots; //!< Plot instance container
struct RGBColor {
//Constructors
RGBColor() : red(0), green(0), blue(0) { };
RGBColor(const int v[3]) : red(v[RED]), green(v[GREEN]), blue(v[BLUE]) { };
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<int> &v) {
@ -48,27 +44,6 @@ struct RGBColor {
blue = v[2];
}
// Index operators
const unsigned char& operator[](int i) const {
switch (i) {
case 0: return red;
case 1: return green;
case 2: return blue;
default:
throw std::out_of_range{"Index in RGBColor must be between 0 and 2."};
}
}
unsigned char& operator[](int i) {
switch (i) {
case 0: return red;
case 1: return green;
case 2: return blue;
default:
throw std::out_of_range{"Index in RGBColor must be between 0 and 2."};
}
}
// Members
uint8_t red, green, blue;
};