polaroid-pp

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

commit cf6118cb14dc3ba1b062a2144f2545989860fcfe
parent 6c4b26d061c7e52796a8914e64870f2162819a66
Author: Fabian Wermelinger <fabianw@mavt.ethz.ch>
Date:   Tue, 13 Sep 2016 18:40:18 +0200

renamed DAT1D -> ASCII

Diffstat:
Mapps/polaroidCamera/SceneProcessor.cpp | 4++--
Ainclude/PhotoASCII.h | 37+++++++++++++++++++++++++++++++++++++
Dinclude/PhotoDAT1D.h | 37-------------------------------------
Minclude/PhotoFormats.h | 2+-
Asrc/PhotoASCII.cpp | 43+++++++++++++++++++++++++++++++++++++++++++
Dsrc/PhotoDAT1D.cpp | 43-------------------------------------------
6 files changed, 83 insertions(+), 83 deletions(-)

diff --git a/apps/polaroidCamera/SceneProcessor.cpp b/apps/polaroidCamera/SceneProcessor.cpp @@ -47,8 +47,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 (paper == "ascii") + m_photo = new PhotoASCII; else if (paper == "info") m_photo = new PhotoINFO; else diff --git a/include/PhotoASCII.h b/include/PhotoASCII.h @@ -0,0 +1,37 @@ +// File : PhotoASCII.h +// Date : Thu 30 Jun 2016 03:58:09 PM CEST +// Author : Fabian Wermelinger +// Description: ASCII .dat file for 1D extraction +// Copyright 2016 ETH Zurich. All Rights Reserved. +#ifndef PHOTOASCII_H_OSYU1497 +#define PHOTOASCII_H_OSYU1497 + +#include <string> +#include <vector> + +#include "common.h" +#include "Polaroid.h" +#include "PhotoPaper.h" + +class PhotoASCII : public PhotoPaper +{ +private: + std::vector<Real> m_data; + Real m_time; + +public: + PhotoASCII(const int N=0, const std::string filename="dat1d", const Real t=0) : PhotoPaper(0,0,filename), m_data(N), m_time(t) + { + m_description = "ASCII data"; + } + virtual ~PhotoASCII() { } + + virtual void make_new(const std::string name, const int N, const int dummy); + virtual void resize(const int N, const int dummy); + virtual void write(); + virtual void set_pixel(const double phi, const int x, const int dummy); + virtual std::string suffix() const { return std::string(".dat"); } + inline void set_time(const Real t) { m_time = t; } +}; + +#endif /* PHOTOASCII_H_OSYU1497 */ diff --git a/include/PhotoDAT1D.h b/include/PhotoDAT1D.h @@ -1,37 +0,0 @@ -// File : PhotoDAT1D.h -// Date : Thu 30 Jun 2016 03:58:09 PM CEST -// Author : Fabian Wermelinger -// Description: ASCII .dat file for 1D extraction -// Copyright 2016 ETH Zurich. All Rights Reserved. -#ifndef PHOTODAT1D_H_OSYU1497 -#define PHOTODAT1D_H_OSYU1497 - -#include <string> -#include <vector> - -#include "common.h" -#include "Polaroid.h" -#include "PhotoPaper.h" - -class PhotoDAT1D : public PhotoPaper -{ -private: - std::vector<Real> m_data; - Real m_time; - -public: - PhotoDAT1D(const int N=0, const std::string filename="dat1d", const Real t=0) : PhotoPaper(0,0,filename), m_data(N), m_time(t) - { - m_description = "ASCII data"; - } - virtual ~PhotoDAT1D() { } - - virtual void make_new(const std::string name, const int N, const int dummy); - virtual void resize(const int N, const int dummy); - virtual void write(); - virtual void set_pixel(const double phi, const int x, const int dummy); - virtual std::string suffix() const { return std::string(".dat"); } - inline void set_time(const Real t) { m_time = t; } -}; - -#endif /* PHOTODAT1D_H_OSYU1497 */ diff --git a/include/PhotoFormats.h b/include/PhotoFormats.h @@ -9,7 +9,7 @@ #include "PhotoPaper.h" #include "PhotoHDF5.h" #include "PhotoPNG.h" -#include "PhotoDAT1D.h" +#include "PhotoASCII.h" #include "PhotoINFO.h" #endif /* PHOTOFORMATS_H_3IWQHPAU */ diff --git a/src/PhotoASCII.cpp b/src/PhotoASCII.cpp @@ -0,0 +1,43 @@ +// File : PhotoASCII.cpp +// Date : Thu 30 Jun 2016 04:14:56 PM CEST +// Author : Fabian Wermelinger +// Description: 1D ASCII paper Implementation +// Copyright 2016 ETH Zurich. All Rights Reserved. +#include <cassert> +#include <fstream> +#include "PhotoASCII.h" + +using namespace std; + +void PhotoASCII::make_new(const string name, const int N, const int dummy) +{ + m_fname = name; + m_data.clear(); + m_data.resize(N); +} + +void PhotoASCII::resize(const int N, const int dummy) +{ + m_data.clear(); + m_data.resize(N); +} + +void PhotoASCII::write() +{ + ofstream asciiout(m_fname.c_str()); + asciiout.setf(std::ios::scientific, std::ios::floatfield); + asciiout.precision(12); + if (!m_data.empty()) + { + const Real h = 1.0/m_data.size(); + for (size_t i = 0; i < m_data.size(); ++i) + asciiout << h*(i+0.5) << '\t' << m_data[i] << endl; + } + asciiout.close(); +} + +void PhotoASCII::set_pixel(const double phi, const int i, const int dummy) +{ + assert(i < static_cast<int>(data.size())); + m_data[i] = phi; +} diff --git a/src/PhotoDAT1D.cpp b/src/PhotoDAT1D.cpp @@ -1,43 +0,0 @@ -// File : PhotoDAT1D.cpp -// Date : Thu 30 Jun 2016 04:14:56 PM CEST -// Author : Fabian Wermelinger -// Description: 1D ASCII paper Implementation -// Copyright 2016 ETH Zurich. All Rights Reserved. -#include <cassert> -#include <fstream> -#include "PhotoDAT1D.h" - -using namespace std; - -void PhotoDAT1D::make_new(const string name, const int N, const int dummy) -{ - m_fname = name; - m_data.clear(); - m_data.resize(N); -} - -void PhotoDAT1D::resize(const int N, const int dummy) -{ - m_data.clear(); - m_data.resize(N); -} - -void PhotoDAT1D::write() -{ - ofstream asciiout(m_fname.c_str()); - asciiout.setf(std::ios::scientific, std::ios::floatfield); - asciiout.precision(12); - if (!m_data.empty()) - { - const Real h = 1.0/m_data.size(); - for (size_t i = 0; i < m_data.size(); ++i) - asciiout << h*(i+0.5) << '\t' << m_data[i] << endl; - } - asciiout.close(); -} - -void PhotoDAT1D::set_pixel(const double phi, const int i, const int dummy) -{ - assert(i < static_cast<int>(data.size())); - m_data[i] = phi; -}