mesh.hpp

Go to the documentation of this file.
00001 /*
00002 **    TP ETI5 CPE Lyon
00003 **    Copyright (C) 2010 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 _MESH_HPP_
00020 #define _MESH_HPP_
00021 
00022 #include <v3.hpp>
00023 
00024 #include <iostream>
00025 #include <vector>
00026 #include <map>
00027 #include <list>
00028 
00030 namespace cpe
00031 {}
00032 
00033 namespace cpe
00034 {
00035 
00040     class mesh
00041     {
00042 
00043 
00044 
00045 
00046     public:
00047 
00048         // ********************************************* //
00049         // ********************************************* //
00050         //  CONSTRUCTORS
00051         // ********************************************* //
00052         // ********************************************* //
00053 
00055         mesh();
00057         mesh(const std::pair <std::vector<double>,std::vector<unsigned int> >& input);
00058 
00059 
00060         // ********************************************* //
00061         // ********************************************* //
00062         //  Get value
00063         // ********************************************* //
00064         // ********************************************* //
00065 
00067         v3 get_vertex(const unsigned int& k_vertex) const;
00069         v3 get_vertex(const unsigned int& k_tri,const unsigned int& k_v) const;
00071         std::vector<unsigned int> get_connectivity(const unsigned int& k_polygon) const;
00072 
00074         void set_vertex(const unsigned int& k_vertex,const v3& new_vertex);
00076         void set_connectivity(const unsigned int& k_polygon,const std::vector<unsigned int>& new_triangle);
00077 
00078 
00079 
00081         void set_texture(const unsigned int& k_vertex,const double& tx,const double& ty);
00083         double get_texture_tx(const unsigned int& k_vertex) const;
00085         double get_texture_ty(const unsigned int& k_vertex) const;
00086 
00087 
00088         // ********************************************* //
00089         // ********************************************* //
00090         //  Build shape
00091         // ********************************************* //
00092         // ********************************************* //
00093 
00095         void add_vertex(const v3& x);
00097         void add_vertex(const double& x,const double& y,const double& z);
00099         void add_triangle(const unsigned int& u0,const unsigned int& u1,const unsigned int& u2);
00100 
00101 
00102         // ********************************************* //
00103         // ********************************************* //
00104         //  Size
00105         // ********************************************* //
00106         // ********************************************* //
00107 
00109         unsigned int vertex_number() const;
00111         unsigned int triangle_number() const;
00112 
00113         // ********************************************* //
00114         // ********************************************* //
00115         //  Connectivity information
00116         // ********************************************* //
00117         // ********************************************* //
00118 
00120         std::map<int,std::list<int> > ring() const;
00122         std::map<int,std::list<int> > star() const;
00123 
00124 
00125         // ********************************************* //
00126         // ********************************************* //
00127         //  Normal
00128         // ********************************************* //
00129         // ********************************************* //
00130 
00132         std::vector <double> normal_vertex() const;
00134         std::vector <double> normal_polygon() const;
00135 
00136 
00138         void inverse_triangle_order();
00139 
00140 
00141         // ********************************************* //
00142         // ********************************************* //
00143         //  INTERNAL ACCESS
00144         // ********************************************* //
00145         // ********************************************* //
00146 
00148         const std::vector<double>& get_vertex() const;
00150         std::vector<double>& get_vertex();
00151 
00153         const std::vector <unsigned int>& get_connectivity() const;
00155         std::vector <unsigned int>& get_connectivity();
00156 
00158         const std::vector<double>& get_texture() const;
00160         std::vector<double>& get_texture();
00161 
00162         // ********************************************* //
00163         // ********************************************* //
00164         //  Assert
00165         // ********************************************* //
00166         // ********************************************* //
00167 
00169         void assert_vertex(const unsigned int& k_vertex) const;
00170 
00172         void assert_connectivity(const unsigned int& k_connectivity) const;
00173 
00174 
00175         // ********************************************* //
00176         // ********************************************* //
00177         //  IN/OUT
00178         // ********************************************* //
00179         // ********************************************* //
00180 
00182         static mesh load_off_file(const std::string& filename);
00184         void save_off_file(const std::string& filename) const;
00185 
00186 
00187         // ********************************************* //
00188         // ********************************************* //
00189         //  Deformation
00190         // ********************************************* //
00191         // ********************************************* //
00192 
00194         void scale_unity();
00195 
00196     private:
00197 
00199         std::vector <double> vertex;
00201         std::vector <unsigned int> connectivity;
00202 
00206         std::vector <double> texture;
00207 
00208     };
00209 }
00210 
00211 #endif
Generated on Wed Oct 27 16:12:18 2010 by  doxygen 1.6.3