From 38a248b4a51bbe6471b0c5cffa01a9b3c914c82f Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Mon, 29 Oct 2018 09:33:24 -0500 Subject: [PATCH] Updating names of ObjectPlot and Object Color. --- include/openmc/plot.h | 32 +++++++++++++-------------- src/plot.cpp | 50 +++++++++++++++++++++---------------------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/include/openmc/plot.h b/include/openmc/plot.h index 360cddc8d0..69d8c1cf8b 100644 --- a/include/openmc/plot.h +++ b/include/openmc/plot.h @@ -26,8 +26,8 @@ extern std::map plot_map; //!< map of plot ids to index extern int n_plots; //!< number of plots in openmc run -class ObjectPlot; -extern std::vector plots; //!< Plot instance container +class Plot; +extern std::vector plots; //!< Plot instance container typedef std::vector>> ImageData; @@ -48,26 +48,26 @@ enum class plot_color_by { }; //=============================================================================== -// ObjectColor holds color information for plotted objects +// RGBColor holds color information for plotted objects //=============================================================================== -struct ObjectColor { +struct RGBColor { int rgb[3]; //!< RGB color values }; //=============================================================================== -// ObjectPlot holds plot information +// Plot class //=============================================================================== -class ObjectPlot +class Plot { public: // Constructor - ObjectPlot(pugi::xml_node plot); + Plot(pugi::xml_node plot); // Destructor - ~ObjectPlot(); + ~Plot(); // Methods private: @@ -96,9 +96,9 @@ public: int meshlines_width; //!< Width of lines added to the plot int level; //!< Plot universe level int index_meshlines_mesh; //!< Index of the mesh to draw on the plot - ObjectColor meshlines_color; //!< Color of meshlines on the plot - ObjectColor not_found; //!< Plot background color - std::vector colors; //!< Plot colors + RGBColor meshlines_color; //!< Color of meshlines on the plot + RGBColor not_found; //!< Plot background color + std::vector colors; //!< Plot colors std::string path_plot; //!< Plot output filename pugi::xml_node _plot_node; }; @@ -110,13 +110,13 @@ public: //! Add mesh lines to image data of a plot object //! \param[in] plot object //! \param[out] image data associated with the plot object -void draw_mesh_lines(ObjectPlot* pl, +void draw_mesh_lines(Plot* pl, std::vector< std::vector< std::vector > > &data); //! Write a ppm image to file using a plot object's image data //! \param[in] plot object //! \param[out] image data associated with the plot object -void output_ppm(ObjectPlot* pl, +void output_ppm(Plot* pl, const std::vector< std::vector< std::vector > > &data); //! Get the rgb color for a given particle position in a plot @@ -124,7 +124,7 @@ void output_ppm(ObjectPlot* pl, //! \param[in] plot object //! \param[out] rgb color //! \param[out] cell or material id for particle position -void position_rgb(Particle* p, ObjectPlot* pl, int rgb[3], int &id); +void position_rgb(Particle* p, Plot* pl, int rgb[3], int &id); //! Initialize a voxel file @@ -159,11 +159,11 @@ extern "C" void read_plots(pugi::xml_node* plot_node); //! Create a ppm image for a plot object //! \param[in] plot object -extern "C" void create_ppm(ObjectPlot* pl); +extern "C" void create_ppm(Plot* pl); //! Create an hdf5 voxel file for a plot object //! \param[in] plot object -extern "C" void create_voxel(ObjectPlot *pl); +extern "C" void create_voxel(Plot *pl); } // namespace openmc diff --git a/src/plot.cpp b/src/plot.cpp index b585894718..12aab9242e 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -27,7 +27,7 @@ std::map plot_map; int n_plots; -std::vector plots; +std::vector plots; const int WHITE[3] = {255, 255, 255}; const int NULLRGB[3] = {0, 0, 0}; @@ -42,7 +42,7 @@ int openmc_plot_geometry() int err; for (int i = 0; i < n_plots; i++) { - ObjectPlot* pl = plots[i]; + Plot* pl = plots[i]; std::stringstream ss; ss << "Processing plot " << pl->id << ": " @@ -71,7 +71,7 @@ read_plots(pugi::xml_node* plots_node) n_plots = plot_nodes.size(); for(int i = 0; i < plot_nodes.size(); i++) { - ObjectPlot* pl = new ObjectPlot(plot_nodes[i]); + Plot* pl = new Plot(plot_nodes[i]); plots.push_back(pl); plot_map[pl->id] = i; } @@ -82,7 +82,7 @@ read_plots(pugi::xml_node* plots_node) // specification in the portable pixmap format (PPM) //=============================================================================== -void create_ppm(ObjectPlot* pl) +void create_ppm(Plot* pl) { int width = pl->pixels[0]; @@ -157,7 +157,7 @@ void create_ppm(ObjectPlot* pl) } void -ObjectPlot::set_id() +Plot::set_id() { // Copy data into plots if (check_for_node(_plot_node, "id")) { @@ -175,7 +175,7 @@ ObjectPlot::set_id() } void -ObjectPlot::set_type() +Plot::set_type() { // Copy plot type // Default is slice @@ -202,7 +202,7 @@ ObjectPlot::set_type() } void -ObjectPlot::set_output_path() +Plot::set_output_path() { // Set output file path std::stringstream filename; @@ -251,7 +251,7 @@ ObjectPlot::set_output_path() } void -ObjectPlot::set_bg_color() +Plot::set_bg_color() { // Copy plot background color std::vector bg_rgb; @@ -284,7 +284,7 @@ ObjectPlot::set_bg_color() } void -ObjectPlot::set_basis() +Plot::set_basis() { // Copy plot basis if (plot_type::slice == type) { @@ -309,7 +309,7 @@ ObjectPlot::set_basis() } void -ObjectPlot::set_origin() +Plot::set_origin() { // Copy plotting origin std::vector pl_origin; @@ -327,7 +327,7 @@ ObjectPlot::set_origin() } void -ObjectPlot::set_width() +Plot::set_width() { // Copy plotting width std::vector pl_width; @@ -358,7 +358,7 @@ ObjectPlot::set_width() } void -ObjectPlot::set_universe() +Plot::set_universe() { // Copy plot universe level if (check_for_node(_plot_node, "level")) { @@ -374,7 +374,7 @@ ObjectPlot::set_universe() } void -ObjectPlot::set_default_colors() +Plot::set_default_colors() { // Copy plot color type and initialize all colors randomly std::string pl_color_by = "cell"; @@ -384,7 +384,7 @@ ObjectPlot::set_default_colors() if ("cell" == pl_color_by) { color_by = plot_color_by::cells; for(int i = 0; i < n_cells; i++) { - colors.push_back(new ObjectColor()); + colors.push_back(new RGBColor()); colors[i]->rgb[RED] = int(prn()*255); colors[i]->rgb[GREEN] = int(prn()*255); colors[i]->rgb[BLUE] = int(prn()*255); @@ -393,7 +393,7 @@ ObjectPlot::set_default_colors() } else if("material" == pl_color_by) { color_by = plot_color_by::mats; for(int i = 0; i < materials.size(); i++) { - colors.push_back(new ObjectColor()); + colors.push_back(new RGBColor()); colors[i]->rgb[RED] = int(prn()*255); colors[i]->rgb[GREEN] = int(prn()*255); colors[i]->rgb[BLUE] = int(prn()*255); @@ -407,7 +407,7 @@ ObjectPlot::set_default_colors() } void -ObjectPlot::set_user_colors() +Plot::set_user_colors() { // Get the number of nodes and get a list of them std::vector color_nodes; @@ -477,7 +477,7 @@ ObjectPlot::set_user_colors() } void -ObjectPlot::set_meshlines() +Plot::set_meshlines() { // Deal with meshlines std::vector mesh_line_nodes; @@ -596,7 +596,7 @@ ObjectPlot::set_meshlines() } void -ObjectPlot::set_mask() +Plot::set_mask() { // Deal with masks std::vector mask_nodes; @@ -679,7 +679,7 @@ ObjectPlot::set_mask() } } -ObjectPlot::ObjectPlot(pugi::xml_node plot_node): +Plot::Plot(pugi::xml_node plot_node): index_meshlines_mesh(-1) { _plot_node = plot_node; @@ -696,9 +696,9 @@ index_meshlines_mesh(-1) set_meshlines(); set_mask(); _plot_node = pugi::xml_node(); // set to null node after construction -} // End ObjectPlot constructor +} // End Plot constructor -ObjectPlot::~ObjectPlot() { +Plot::~Plot() { // cleanup color pointers for (auto c : colors) { if (c) {delete c;} @@ -710,7 +710,7 @@ ObjectPlot::~ObjectPlot() { // current particle's position //=============================================================================== -void position_rgb(Particle* p, ObjectPlot* pl, int rgb[3], int &id) +void position_rgb(Particle* p, Plot* pl, int rgb[3], int &id) { p->n_coord = 1; @@ -768,7 +768,7 @@ void position_rgb(Particle* p, ObjectPlot* pl, int rgb[3], int &id) // OUTPUT_PPM writes out a previously generated image to a PPM file //=============================================================================== -void output_ppm(ObjectPlot* pl, const ImageData &data) +void output_ppm(Plot* pl, const ImageData &data) { // Open PPM file for writing std::string fname = pl->path_plot; @@ -803,7 +803,7 @@ void output_ppm(ObjectPlot* pl, const ImageData &data) // DRAW_MESH_LINES draws mesh line boundaries on an image //=============================================================================== -void draw_mesh_lines(ObjectPlot *pl, ImageData &data) +void draw_mesh_lines(Plot *pl, ImageData &data) { std::vector rgb; rgb.resize(3); rgb[RED] = pl->meshlines_color.rgb[RED]; @@ -912,7 +912,7 @@ void draw_mesh_lines(ObjectPlot *pl, ImageData &data) // id. For 1 million voxels this produces a file of approximately 15MB. //=============================================================================== -void create_voxel(ObjectPlot *pl) +void create_voxel(Plot *pl) { // compute voxel widths in each direction