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 }
00034
00035 namespace cpe
00036 {
00037
00042 class mesh
00043 {
00044
00045 public:
00046
00047
00048
00049
00050
00051
00052
00054 mesh();
00056 mesh(const std::pair <std::vector<double>,std::vector<unsigned int> >& input);
00057
00058
00059
00060
00061
00062
00063
00064
00066 v3 get_vertex(const unsigned int& k_vertex) const;
00068 v3 get_vertex(const unsigned int& k_tri,const unsigned int& k_v) const;
00070 std::vector<unsigned int> get_connectivity(const unsigned int& k_polygon) const;
00071
00073 void set_vertex(const unsigned int& k_vertex,const v3& new_vertex);
00075 void set_connectivity(const unsigned int& k_polygon,const std::vector<unsigned int>& new_triangle);
00076
00077
00078
00080 void set_texture(const unsigned int& k_vertex,const double& tx,const double& ty);
00082 double get_texture_tx(const unsigned int& k_vertex) const;
00084 double get_texture_ty(const unsigned int& k_vertex) const;
00085
00086
00087
00088
00089
00090
00091
00092
00094 void add_vertex(const v3& x);
00096 void add_vertex(const double& x,const double& y,const double& z);
00098 void add_triangle(const unsigned int& u0,const unsigned int& u1,const unsigned int& u2);
00099
00100
00101
00102
00103
00104
00105
00106
00108 unsigned int vertex_number() const;
00110 unsigned int triangle_number() const;
00111
00112
00113
00114
00115
00116
00117
00119 std::map<int,std::list<int> > ring() const;
00121 std::map<int,std::list<int> > star() const;
00122
00123
00124
00125
00126
00127
00128
00129
00131 std::vector <double> normal_vertex() const;
00133 std::vector <double> normal_polygon() const;
00134
00135
00137 void inverse_triangle_order();
00138
00139
00140
00141
00142
00143
00144
00145
00147 const std::vector<double>& get_vertex() const;
00149 std::vector<double>& get_vertex();
00150
00152 const std::vector <unsigned int>& get_connectivity() const;
00154 std::vector <unsigned int>& get_connectivity();
00155
00157 const std::vector<double>& get_texture() const;
00159 std::vector<double>& get_texture();
00160
00161
00162
00163
00164
00165
00166
00168 void assert_vertex(const unsigned int& k_vertex) const;
00169
00171 void assert_connectivity(const unsigned int& k_connectivity) const;
00172
00173
00174
00175
00176
00177
00178
00179
00181 static mesh load_off_file(const std::string& filename);
00183 void save_off_file(const std::string& filename) const;
00184
00185
00186
00187
00188
00189
00190
00191
00193 void scale_unity();
00194
00196 void scale(const double& value);
00198 void apply(const matrix3& M);
00200 void translate(const v3& tr);
00201
00202
00203
00204
00205 private:
00206
00208 std::vector <double> vertex;
00210 std::vector <unsigned int> connectivity;
00211
00215 std::vector <double> texture;
00216
00217 };
00218 }
00219
00220 #endif