Volume.hpp
Go to the documentation of this file.
00001 /*
00002 **    TP 4ETI CPE Lyon
00003 **    Copyright (C) 2012 Damien Rohmer
00004 **
00005 **    This program is free software: you can redistribute it and/or modify
00006 **    it under the terms of the GNU General Public License as published by
00007 **    the Free Software Foundation, either version 3 of the License, or
00008 **    (at your option) any later version.
00009 **
00010 **   This program is distributed in the hope that it will be useful,
00011 **    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 **    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 **    GNU General Public License for more details.
00014 **
00015 **    You should have received a copy of the GNU General Public License
00016 **    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 
00020 #ifndef VOLUME_HPP
00021 #define VOLUME_HPP
00022 
00023 #include <iostream>
00024 #include <vector>
00025 
00026 #include <color.hpp>
00027 
00028 namespace cpe
00029 {
00030 class Volume
00031 {
00032     public:
00033 
00034         //*********************************************//
00035         //*********************************************//
00036         // CONSTRUCTORS
00037         //*********************************************//
00038         //*********************************************//
00039 
00041         Volume();
00043         ~Volume();
00044 
00045         //*********************************************//
00046         //*********************************************//
00047         // Load File
00048         //*********************************************//
00049         //*********************************************//
00050 
00052         static Volume load_v4d(const std::string& filename);
00054         void save_v4d(const std::string& filename);
00055 
00057         void normalize_data_to_one();
00058 
00059 
00060         //*********************************************//
00061         //*********************************************//
00062         // Size
00063         //*********************************************//
00064         //*********************************************//
00065 
00067         void resize(const unsigned int& Nx,const unsigned int& Ny,const unsigned int& Nz);
00068 
00070         unsigned int size_x() const;
00072         unsigned int size_y() const;
00074         unsigned int size_z() const;
00075 
00076 
00077         //*********************************************//
00078         //*********************************************//
00079         // Get/Set value
00080         //*********************************************//
00081         //*********************************************//
00082 
00084         float get_data(const unsigned int& kx,const unsigned int& ky,const unsigned int& kz) const;
00086         void set_data(const unsigned int& kx,const unsigned int& ky,const unsigned int& kz,const float& value);
00087 
00089         float operator()(const float& x,const float& y,const float& z) const;
00090 
00091 
00092         //*********************************************//
00093         //*********************************************//
00094         // Modifications
00095         //*********************************************//
00096         //*********************************************//
00097 
00098 
00100         Volume resampled_square(const unsigned int& N) const;
00101 
00103         Volume rotated_z(const float& angle) const;
00105         Volume rotated_x(const float& angle) const;
00107         Volume rotated_y(const float& angle) const;
00108 
00110         Volume smoothed() const;
00111 
00112         //*********************************************//
00113         //*********************************************//
00114         // Slicing
00115         //*********************************************//
00116         //*********************************************//
00117 
00119         std::vector <float> slice_x(const unsigned& kx) const;
00121         std::vector <float> slice_y(const unsigned& ky) const;
00123         std::vector <float> slice_z(const unsigned& kz) const;
00124 
00125 
00126 
00127 
00128         //*********************************************//
00129         //*********************************************//
00130         // Visu
00131         //*********************************************//
00132         //*********************************************//
00133 
00135         std::vector<float> mip() const;
00137         std::vector<cpe::color> ray_cast() const;
00138 
00139 
00140     private:
00141 
00143         float linear_interpolation(const float& x,const float& y,const float& z) const;
00144 
00146         unsigned int Nx;
00148         unsigned int Ny;
00150         unsigned int Nz;
00152         std::vector <float> data;
00153 };
00154 }
00155 
00156 #endif