mesh.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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 class matrix3;
00033 class v3;
00034 }
00035
00036 namespace cpe
00037 {
00038
00043 class mesh
00044 {
00045
00046 public:
00047
00048
00049
00050
00051
00052
00053
00055 mesh();
00057 mesh(const std::pair <std::vector<v3>,std::vector<unsigned int> >& input);
00058
00059
00060
00061
00062
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 v3& get_vertex(const unsigned int& k_vertex);
00073 v3& get_vertex(const unsigned int& k_tri,const unsigned int& k_v);
00074
00076 std::vector<unsigned int> get_connectivity(const unsigned int& k_polygon) const;
00077
00079 void set_vertex(const unsigned int& k_vertex,const v3& new_vertex);
00081 void set_connectivity(const unsigned int& k_polygon,const std::vector<unsigned int>& new_triangle);
00082
00083
00084
00086 void set_texture(const unsigned int& k_vertex,const double& tx,const double& ty);
00088 double get_texture_tx(const unsigned int& k_vertex) const;
00090 double get_texture_ty(const unsigned int& k_vertex) const;
00091
00092
00093
00094
00095
00096
00097
00098
00100 void add_vertex(const v3& x);
00102 void add_vertex(const double& x,const double& y,const double& z);
00103
00105 void add_triangle(const unsigned int& u0,const unsigned int& u1,const unsigned int& u2);
00106
00107
00108
00109
00110
00111
00112
00113
00115 unsigned int vertex_number() const;
00117 unsigned int triangle_number() const;
00118
00119
00120
00121
00122
00123
00124
00126 std::map<int,std::list<int> > ring() const;
00128 std::map<int,std::list<int> > star() const;
00129
00130
00131
00132
00133
00134
00135
00136
00138 std::vector <v3> normal_vertex() const;
00140 std::vector <v3> normal_polygon() const;
00141
00142
00144 void inverse_triangle_order();
00145
00146
00147
00148
00149
00150
00151
00152
00154 const std::vector<v3>& get_vertex() const;
00156 std::vector<v3>& get_vertex();
00157
00159 const std::vector <unsigned int>& get_connectivity() const;
00161 std::vector <unsigned int>& get_connectivity();
00162
00164 const std::vector<double>& get_texture() const;
00166 std::vector<double>& get_texture();
00167
00168
00169
00170
00171
00172
00173
00175 void assert_vertex(const unsigned int& k_vertex) const;
00176
00178 void assert_connectivity(const unsigned int& k_connectivity) const;
00179
00180
00181
00182
00183
00184
00185
00186
00188 static mesh load_off_file(const std::string& filename);
00190 void save_off_file(const std::string& filename) const;
00191
00192
00193
00194
00195
00196
00197
00198
00200 void scale_unity();
00201
00203 void scale(const double& value);
00205 void apply(const matrix3& M);
00207 void translate(const v3& tr);
00208
00209 private:
00210
00212 std::vector <v3> vertex;
00214 std::vector <unsigned int> connectivity;
00215
00219 std::vector <double> texture;
00220
00221 };
00222 }
00223
00224 #endif