polaroid-pp

Schlieren and contour plot tool
git clone https://git.0xfab.ch/polaroid-pp.git
Log | Files | Refs | Submodules | README | LICENSE

commit 9f84b1b766d83eba1d8e470acaa7602122f6ab9c
parent 940363b7dfde730726f9215383afb3cb7c1114ca
Author: Fabian Wermelinger <fabianw@mavt.ethz.ch>
Date:   Thu, 30 Jun 2016 17:12:00 +0200

added 1D line extractor

Diffstat:
Mapps/polaroidCamera/Cartridges.h | 1+
Mapps/polaroidCamera/LineExtractor.h | 10++++++----
Mapps/polaroidCamera/SceneProcessor.cpp | 4++++
Minclude/PhotoFormats.h | 1+
Minclude/PhotoHDF5.h | 8+++-----
Minclude/PhotoPNG.h | 26++++++++++++--------------
Minclude/PhotoPaper.h | 5+++--
Msrc/PhotoHDF5.cpp | 4+++-
8 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/apps/polaroidCamera/Cartridges.h b/apps/polaroidCamera/Cartridges.h @@ -13,5 +13,6 @@ #include "BoundedNormalizerCartridge.h" #include "BoundedLogNormalizerCartridge.h" #include "SchlierenCartridge.h" +#include "LineExtractor.h" #endif /* CARTRIDGES_H_LTWKNANR */ diff --git a/apps/polaroidCamera/LineExtractor.h b/apps/polaroidCamera/LineExtractor.h @@ -34,6 +34,8 @@ public: string desc("1D_Line"); photo.set_description(desc.c_str()); + const std::string basename(photo.get_name()); + if ((wf >= 0 && wi < 0) || (wi >= 0 && wf < 0)) { const int fixed = (wf >= 0) ? static_cast<int>(width*wf) : wi; @@ -41,28 +43,28 @@ public: std::ostringstream buf; buf << "-line_sliceID=" << data.get_sliceID() << "_sliceDir=" << data.get_sliceDir(); buf << "_sliceWidthID=" << fixed; - photo.make_new(photo.get_name()+buf.str(), height); + photo.make_new(basename+buf.str()+photo.suffix(), height); // extract line for (int h=0; h < height; ++h) photo.set_pixel(data(fixed,h), h); photo.write(); } - else if ((hf >= 0 && hi < 0) || (hi >= 0 && hf < 0)) + if ((hf >= 0 && hi < 0) || (hi >= 0 && hf < 0)) { const int fixed = (hf >= 0) ? static_cast<int>(height*hf) : hi; assert(fixed < height); std::ostringstream buf; buf << "-line_sliceID=" << data.get_sliceID() << "_sliceDir=" << data.get_sliceDir(); buf << "_sliceHeightID=" << fixed; - photo.make_new(photo.get_name()+buf.str(), width); + photo.make_new(basename+buf.str()+photo.suffix(), width); // extract line for (int w=0; w < width; ++w) photo.set_pixel(data(w,fixed), w); photo.write(); } - else + if ((wf < 0 && wi < 0) && (hi < 0 && hf < 0)) std::cerr << "No seed point specified for line extraction... Skipping this one" << std:: endl; } diff --git a/apps/polaroidCamera/SceneProcessor.cpp b/apps/polaroidCamera/SceneProcessor.cpp @@ -28,6 +28,8 @@ void SceneProcessor::_prepare_cam() m_cartridge = new BoundedLogNormalizerCartridge(m_parser); else if (cart == "schlieren") m_cartridge = new SchlierenCartridge(m_parser); + else if (cart == "line_extractor") + m_cartridge = new LineExtractor(m_parser); else { if (m_mpi.isroot()) @@ -42,6 +44,8 @@ void SceneProcessor::_prepare_cam() m_photo = new PNG_MONO; else if (paper == "hdf5") m_photo = new PhotoHDF5; + else if (paper == "dat1d") + m_photo = new PhotoDAT1D; else { if (m_mpi.isroot()) diff --git a/include/PhotoFormats.h b/include/PhotoFormats.h @@ -9,5 +9,6 @@ #include "PhotoPaper.h" #include "PhotoHDF5.h" #include "PhotoPNG.h" +#include "PhotoDAT1D.h" #endif /* PHOTOFORMATS_H_3IWQHPAU */ diff --git a/include/PhotoHDF5.h b/include/PhotoHDF5.h @@ -17,7 +17,6 @@ class PhotoHDF5 : public PhotoPaper { private: - std::string m_description; bool m_open; Real* m_hdfraw; Real m_time; @@ -34,12 +33,12 @@ private: void _dump_xmf() const; public: - PhotoHDF5(const std::string filename="hdf5", const Real t=0) : PhotoPaper(0,0,filename), m_description("data"), m_open(false), m_hdfraw(nullptr), m_time(t) {} - PhotoHDF5(const Polaroid& cam, const std::string filename="hdf5", const Real t=0) : PhotoPaper(0,0,filename), m_description("data"), m_open(false), m_hdfraw(nullptr), m_time(t) + PhotoHDF5(const std::string filename="hdf5", const Real t=0) : PhotoPaper(0,0,filename), m_open(false), m_hdfraw(nullptr), m_time(t) {} + PhotoHDF5(const Polaroid& cam, const std::string filename="hdf5", const Real t=0) : PhotoPaper(0,0,filename), m_open(false), m_hdfraw(nullptr), m_time(t) { resize(cam.width(), cam.height()); } - PhotoHDF5(const int width, const int height, const std::string filename="hdf5", const Real t=0) : PhotoPaper(0,0,filename), m_description("data"), m_open(false), m_hdfraw(nullptr), m_time(t) + PhotoHDF5(const int width, const int height, const std::string filename="hdf5", const Real t=0) : PhotoPaper(0,0,filename), m_open(false), m_hdfraw(nullptr), m_time(t) { resize(width,height); } @@ -50,7 +49,6 @@ public: virtual void write(); virtual void set_pixel(const double phi, const int x, const int y); virtual std::string suffix() const { return std::string(".h5"); } - virtual void set_description(const char* const desc) { m_description = std::string(desc); } inline void set_time(const Real t) { m_time = t; } }; #endif /* _USE_HDF_ */ diff --git a/include/PhotoPNG.h b/include/PhotoPNG.h @@ -13,7 +13,6 @@ class PNG_HSV : public PhotoPaper { protected: - std::string m_description; bool m_open; pngwriter* m_png; double m_saturation, m_value, m_background; @@ -31,22 +30,22 @@ protected: public: PNG_HSV(const std::string filename="hsv", const double saturation=1.0, const double value=1.0, const double bg=1.0) : - PhotoPaper(0,0,filename), m_description("PNG HSV colorscheme"), m_open(false), m_png(nullptr), - m_saturation(saturation), m_value(value), m_background(bg) + PhotoPaper(0,0,filename), m_open(false), m_png(nullptr), m_saturation(saturation), m_value(value), m_background(bg) { + m_description = "PNG HSV colorscheme"; _default_info(); } PNG_HSV(const Polaroid& cam, const std::string filename="hsv", const double saturation=1.0, const double value=1.0, const double bg=1.0) : - PhotoPaper(0,0,filename), m_description("PNG HSV colorscheme"), m_open(false), m_png(nullptr), - m_saturation(saturation), m_value(value), m_background(bg) + PhotoPaper(0,0,filename), m_open(false), m_png(nullptr), m_saturation(saturation), m_value(value), m_background(bg) { + m_description = "PNG HSV colorscheme"; _default_info(); resize(cam.width(), cam.height()); } PNG_HSV(const int width, const int height, const std::string filename="hsv", const double saturation=1.0, const double value=1.0, const double bg=1.0) : - PhotoPaper(0,0,filename), m_description("PNG HSV colorscheme"), m_open(false), m_png(nullptr), - m_saturation(saturation), m_value(value), m_background(bg) + PhotoPaper(0,0,filename), m_open(false), m_png(nullptr), m_saturation(saturation), m_value(value), m_background(bg) { + m_description = "PNG HSV colorscheme"; _default_info(); resize(width, height); } @@ -65,24 +64,23 @@ public: virtual void write(); virtual void set_pixel(const double phi, const int x, const int y); virtual std::string suffix() const { return std::string(".png"); } - virtual void set_description(const char* const desc) { m_description = desc; } }; class PNG_MONO : public PNG_HSV { public: - PNG_MONO(const std::string filename="mono") : PNG_HSV(filename) { } - PNG_MONO(const Polaroid& cam, const std::string filename="mono") : PNG_HSV(cam, filename) { } - PNG_MONO(const int width, const int height, const std::string filename="mono") : PNG_HSV(width, height, filename) { } + PNG_MONO(const std::string filename="mono") : PNG_HSV(filename) { m_description = "PNG MONO colorscheme"; } + PNG_MONO(const Polaroid& cam, const std::string filename="mono") : PNG_HSV(cam, filename) { m_description = "PNG MONO colorscheme"; } + PNG_MONO(const int width, const int height, const std::string filename="mono") : PNG_HSV(width, height, filename) { m_description = "PNG MONO colorscheme"; } virtual void set_pixel(const double phi, const int x, const int y); }; class PNG_RGB : public PNG_HSV { - PNG_RGB(const std::string filename="rgb") : PNG_HSV(filename) { } - PNG_RGB(const Polaroid& cam, const std::string filename="rgb") : PNG_HSV(cam, filename) { } - PNG_RGB(const int width, const int height, const std::string filename="rgb") : PNG_HSV(width, height, filename) { } + PNG_RGB(const std::string filename="rgb") : PNG_HSV(filename) { m_description = "PNG RGB colorscheme"; } + PNG_RGB(const Polaroid& cam, const std::string filename="rgb") : PNG_HSV(cam, filename) { m_description = "PNG RGB colorscheme"; } + PNG_RGB(const int width, const int height, const std::string filename="rgb") : PNG_HSV(width, height, filename) { m_description = "PNG RGB colorscheme"; } inline void set_pixel(const int x, const int y, const double R, const double G, const double B) { diff --git a/include/PhotoPaper.h b/include/PhotoPaper.h @@ -14,9 +14,10 @@ class PhotoPaper protected: int m_width, m_height; std::string m_fname; + std::string m_description; public: - PhotoPaper(const int width, const int height, const std::string& name) : m_width(width), m_height(height), m_fname(name) {}; + PhotoPaper(const int width, const int height, const std::string& name) : m_width(width), m_height(height), m_fname(name), m_description("data") {}; virtual ~PhotoPaper() {}; virtual void make_new(const std::string name, const int width, const int height=0) = 0; @@ -24,7 +25,7 @@ public: virtual void write() = 0; virtual void set_pixel(const double phi, const int x, const int y=0) = 0; virtual std::string suffix() const = 0; - virtual void set_description(const char* const desc) { } + virtual void set_description(const char* const desc) { m_description = std::string(desc); } inline void set_name(const std::string& name) { m_fname = name; } inline std::string get_name() const { return m_fname; } }; diff --git a/src/PhotoHDF5.cpp b/src/PhotoHDF5.cpp @@ -8,6 +8,8 @@ #include <cstdio> #include "PhotoHDF5.h" +using namespace std; + void PhotoHDF5::_open_hdf_file() { hsize_t tmp[4] = { 1, static_cast<hsize_t>(m_height), static_cast<hsize_t>(m_width), 1 }; @@ -72,7 +74,7 @@ void PhotoHDF5::resize(const int width, const int height) _close_hdf_file(); if (m_hdfraw) delete [] m_hdfraw; } - m_hdfraw = new Real[width*height]; + m_hdfraw = new Real[width*height]; m_width = width; m_height= height;