mesh.hpp

Go to the documentation of this file.
00001 /*
00002 **    TP 4ETI CPE Lyon
00003 **    Copyright (C) 2011 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 #ifndef _IO_OFF_HPP_
00020 #define _IO_OFF_HPP_
00021 
00022 #include <exception_cpe.hpp>
00023 #include <v3.hpp>
00024 #include <vector>
00025 #include <string>
00026 
00027 #include <color.hpp>
00028 
00029 namespace cpe
00030 {
00032     class mesh
00033     {
00034     public:
00035 
00036 
00037         // ********************************************* //
00038         // ********************************************* //
00039         //  Access data
00040         // ********************************************* //
00041         // ********************************************* //
00042 
00044         const std::vector<v3>& get_vertices() const;
00046         const std::vector<v3>& get_normal() const;
00048         const std::vector<color>& get_color() const;
00050         const std::vector<int>& get_connectivity() const;
00051 
00053         std::vector<v3>& get_vertices();
00055         std::vector<v3>& get_normal();
00057         std::vector<color>& get_color();
00059         std::vector<int>& get_connectivity();
00060 
00061         // ********************************************* //
00062         // ********************************************* //
00063         //  Color
00064         // ********************************************* //
00065         // ********************************************* //
00066 
00068         void fill_color(const color& c);
00070         void fill_color_xyz();
00072         void fill_color_normal();
00073 
00074 
00075         // ********************************************* //
00076         // ********************************************* //
00077         //  Normal
00078         // ********************************************* //
00079         // ********************************************* //
00080 
00082         void compute_normal();
00083 
00084         // ********************************************* //
00085         // ********************************************* //
00086         //  Math Operators
00087         // ********************************************* //
00088         // ********************************************* //
00089 
00091         friend mesh operator+(const v3& x,const mesh& m);
00093         friend mesh operator+(const mesh& m,const v3& x);
00095         mesh& operator+=(const v3& x);
00096 
00098         friend mesh operator-(const mesh& m,const v3& x);
00100         mesh& operator-=(const v3& x);
00101 
00103         friend mesh operator*(const double& s,const mesh& m);
00105         friend mesh operator*(const mesh& m,const double& s);
00107         mesh& operator*=(const double& s);
00108 
00109 
00111         void scale(const double& sx,const double& sy,const double& sz);
00117         void auto_scale(const double& scale=1.0);
00118 
00119 
00120 
00121         // ********************************************* //
00122         // ********************************************* //
00123         //  I/O
00124         // ********************************************* //
00125         // ********************************************* //
00126 
00128         void load_off(const std::string &filename);
00129 
00130 
00131 
00132 
00133 
00134     private:
00135 
00136         // ********************************************* //
00137         // ********************************************* //
00138         //  Internal data
00139         // ********************************************* //
00140         // ********************************************* //
00141 
00143         std::vector<v3> v_vertices;
00145         std::vector<v3> v_normal;
00147         std::vector<color> v_color;
00148 
00150         std::vector<int> v_connectivity;
00151 
00152     };
00153 
00154 
00155 
00157     class exception_mesh : public exception_cpe
00158     {
00159     public:
00160 
00162         exception_mesh():exception_cpe(){}
00164         exception_mesh(const std::string& msg,const std::string& file,const std::string& caller,const int& line):exception_cpe(msg,file,caller,line){}
00165     };
00166 }
00167 
00168 #endif
Generated on Mon Apr 18 20:43:30 2011 by  doxygen 1.6.3