mesh.hpp
Go to the documentation of this file.00001
00006 #ifndef _MESH_HPP_
00007 #define _MESH_HPP_
00008
00009 #include <MC_v3d.hpp>
00010
00011 #include <iostream>
00012 #include <vector>
00013 #include <map>
00014 #include <list>
00015
00016 namespace cpe_mesh
00017 {
00018
00023 class mesh
00024 {
00025
00026
00027 private:
00028
00030 std::vector <double> vertex;
00032 std::vector <int> connectivity;
00033
00034 public:
00035
00036
00037
00038
00039
00040
00041
00043 mesh();
00045 mesh(const std::pair <std::vector<double>,std::vector<int> >& input);
00046
00047
00048
00049
00050
00051
00052
00053
00055 mesh_conv::MC_v3d get_vertex(const unsigned int& k_vertex) const;
00057 std::vector<int> get_connectivity(const unsigned int& k_polygon) const;
00058
00060 mesh& set_vertex(const unsigned int& k_vertex,const mesh_conv::MC_v3d& new_vertex);
00062 mesh& set_connectivity(const unsigned int& k_polygon,const std::vector<int>& new_triangle);
00063
00064
00065
00066
00067
00068
00069
00070
00072 unsigned int vertex_number() const;
00074 unsigned int triangle_number() const;
00075
00076
00077
00078
00079
00080
00081
00083 std::map<int,std::list<int> > ring() const;
00085 std::map<int,std::list<int> > star() const;
00086
00087
00088
00089
00090
00091
00092
00093
00094
00096 std::vector <double> normal_vertex() const;
00098 std::vector <double> normal_polygon() const;
00099
00100
00101
00102
00103
00104
00105
00107 const std::vector<double>& get_vertex() const;
00109 std::vector<double>& get_vertex();
00110
00112 const std::vector <int>& get_connectivity() const;
00114 std::vector <int>& get_connectivity();
00115
00116
00117
00118
00119
00120
00121
00123 void assert_vertex(const unsigned int& k_vertex) const
00124 {if(3*k_vertex+2>=vertex.size()){std::cout<<"Error in mesh::assert_vertex("<<k_vertex<<"), vertex.size()="<<vertex.size()<<std::endl;exit(-1);}}
00125
00127 void assert_connectivity(const unsigned int& k_connectivity) const
00128 {if(3*k_connectivity+2>=connectivity.size()){std::cout<<"Error in mesh::assert_connectivity("<<k_connectivity<<"), connectivity.size()="<<connectivity.size()<<std::endl;exit(-1);}}
00129
00130
00131
00132
00133
00134
00135
00136
00138 static mesh load_off_file(const std::string& filename);
00140 const mesh& save_off_file(const std::string& filename) const;
00141
00142
00143
00144
00145
00146
00147
00148
00150 mesh& scale_unity();
00151
00152
00153
00154
00155
00156 };
00157 }
00158
00159 #endif