diff --git a/include/openmc/plot.h b/include/openmc/plot.h index e64ecc2f7..be9030fa7 100644 --- a/include/openmc/plot.h +++ b/include/openmc/plot.h @@ -11,16 +11,18 @@ namespace openmc { + typedef std::vector< std::vector< std::vector > > ImageData; + class ObjectPlot; - + int PLOT_LEVEL_LOWEST = -1; std::map plot_dict; - + std::vector n_plots; std::vector plots; - + enum PLOT_TYPE { SLICE = 1, VOXEL = 2 @@ -48,7 +50,7 @@ namespace openmc { //=============================================================================== // ObjectPlot holds plot information //=============================================================================== - + struct ObjectPlot { int id; int type; @@ -64,25 +66,25 @@ namespace openmc { ObjectColor not_found; ObjectColor colors[MAX_COORD]; char path_plot[MAX_WORD_LEN]; - + }; void draw_mesh_lines(ObjectPlot* pl, std::vector< std::vector< std::vector > > &data); - + void output_ppm(ObjectPlot* pl, const std::vector< std::vector< std::vector > > &data); - + extern "C" void create_ppm(ObjectPlot* pl); - + extern "C" void position_rgb(Particle* p, ObjectPlot* pl, int rgb[3], int &id); - + extern "C" void voxel_init(hid_t file_id, const hsize_t* dims, hid_t* dspace, hid_t* dset, hid_t* memspace); extern "C" void voxel_write_slice(int x, hid_t dspace, hid_t dset, hid_t memspace, void* buf); extern "C" void voxel_finalize(hid_t dspace, hid_t dset, hid_t memspace); - + } // namespace openmc #endif // OPENMC_PLOT_H diff --git a/src/plot.F90 b/src/plot.F90 index d2e81308f..8e41dcb1b 100644 --- a/src/plot.F90 +++ b/src/plot.F90 @@ -39,7 +39,7 @@ module plot import ObjectPlot type(ObjectPlot), intent(in) :: pl end subroutine create_ppm - + end interface contains diff --git a/src/plot.cpp b/src/plot.cpp index 6c98225c0..9e5d34286 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -63,8 +63,7 @@ void create_ppm(ObjectPlot* pl) { double in_pixel = (pl->width[0])/double(width); double out_pixel = (pl->width[1])/double(height); - std::vector< std::vector< std::vector > > data; - + ImageData data; data.resize(width); for (auto & i : data) { i.resize(height); @@ -117,7 +116,7 @@ void create_ppm(ObjectPlot* pl) { } if (pl->index_meshlines_mesh >= 0) { draw_mesh_lines(pl, data); } - + output_ppm(pl, data); } @@ -188,17 +187,15 @@ 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 std::vector< std::vector< std::vector > > &data) +void output_ppm(ObjectPlot* pl, const ImageData &data) { - // Open PPM file for writing std::string fname = std::string(pl->path_plot); fname = strtrim(fname); std::ofstream of; of.open(fname); - + // Write header of << "P6" << std::endl; of << pl->pixels[0] << " " << pl->pixels[1] << std::endl; @@ -216,18 +213,17 @@ void position_rgb(Particle* p, ObjectPlot* pl, int rgb[3], int &id) { } } // Close file - // THIS IS HERE TO MATCH FORTRAN VERSION, NOT NECESSARY - of << std::endl; + // THIS IS HERE TO MATCH FORTRAN VERSION, NOT NECESSARY + of << std::endl; of.close(); } //=============================================================================== // DRAW_MESH_LINES draws mesh line boundaries on an image //=============================================================================== - -void draw_mesh_lines(ObjectPlot *pl, - std::vector< std::vector< std::vector > > &data) { +void draw_mesh_lines(ObjectPlot *pl, ImageData &data) +{ std::vector rgb; rgb.resize(3); rgb[0] = pl->meshlines_color.rgb[0]; rgb[1] = pl->meshlines_color.rgb[1]; @@ -272,16 +268,16 @@ void draw_mesh_lines(ObjectPlot *pl, // Fortran/C++ index correction ijk_ur[0]++; ijk_ur[1]++; ijk_ur[2]++; - + double frac; int outrange[3], inrange[3]; double xyz_ll[3], xyz_ur[3]; - // sweep through all meshbins on this plane and draw borders + // sweep through all meshbins on this plane and draw borders for (int i = ijk_ll[outer]; i <= ijk_ur[outer]; i++) { for (int j = ijk_ll[inner]; j <= ijk_ur[inner]; j++) { // check if we're in the mesh for this ijk if (i > 0 && i <= m->shape_[outer] && j >0 && j <= m->shape_[inner] ) { - + // get xyz's of lower left and upper right of this mesh cell xyz_ll[outer] = m->lower_left_[outer] + m->width_[outer] * (i - 1); xyz_ll[inner] = m->lower_left_[inner] + m->width_[inner] * (j - 1); @@ -321,9 +317,9 @@ void draw_mesh_lines(ObjectPlot *pl, } // end if(in mesh) } } // end outer loops - + } - + void voxel_init(hid_t file_id, const hsize_t* dims, hid_t* dspace, hid_t* dset, hid_t* memspace)