From c6a8c8bf13ec1222d232a73676717ab366e28462 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 9 Jan 2019 11:50:35 -0600 Subject: [PATCH] Adding function for writing plot ids to a binary file. --- src/plot.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/plot.cpp b/src/plot.cpp index ae2f00023..f44687a4b 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -88,6 +88,19 @@ void read_plots_xml() } } +void write_ids(xt::xtensor ids) { + + // create a binary file with ID information + std::string fname = "plot_ids.binary"; + std::ofstream of; + + of.open(fname); + + for (auto id : ids) { of << id; } + + of.close(); +} + //============================================================================== // CREATE_PPM creates an image based on user input from a plots.xml // specification in the portable pixmap format (PPM) @@ -104,6 +117,8 @@ void create_ppm(Plot pl) ImageData data; data.resize({width, height}); + xt::xtensor ids; + ids.resize({width, height}); int in_i, out_i; Position r; @@ -150,6 +165,7 @@ void create_ppm(Plot pl) p.r()[in_i] = r[in_i] + in_pixel * x; position_rgb(p, pl, rgb, id); data(x,y) = rgb; + ids(x,y) = id; } } } @@ -158,6 +174,9 @@ void create_ppm(Plot pl) // write ppm data to file output_ppm(pl, data); + + // write ids to binary file + write_ids(ids); } void