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
00033 namespace cpe
00034 {
00035
00040 class mesh
00041 {
00042
00043
00044
00045
00046 public:
00047
00048
00049
00050
00051
00052
00053
00055 mesh();
00057 mesh(const std::pair <std::vector<double>,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 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
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
00105
00106
00107
00109 unsigned int vertex_number() const;
00111 unsigned int triangle_number() const;
00112
00113
00114
00115
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
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
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
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
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
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