mesh.hpp

Go to the documentation of this file.
00001 
00002 #ifndef _MESH_HPP_
00003 #define _MESH_HPP_
00004 
00005 #include <MC_v3d.hpp>
00006 
00007 #include <iostream>
00008 #include <vector>
00009 #include <map>
00010 #include <list>
00011 
00012 namespace cpe_mesh
00013 {
00014 
00019     class mesh
00020     {
00021 
00022 
00023     private:
00024 
00026         std::vector <double> vertex;
00028         std::vector <int> connectivity;
00029 
00030     public:
00031 
00032         //*********************************************//
00033         //*********************************************//
00034         // CONSTRUCTORS
00035         //*********************************************//
00036         //*********************************************//
00037 
00039         mesh();
00041         mesh(const std::pair <std::vector<double>,std::vector<int> >& input);
00042 
00043 
00044         //*********************************************//
00045         //*********************************************//
00046         // Get value
00047         //*********************************************//
00048         //*********************************************//
00049 
00051         mesh_conv::MC_v3d get_vertex(const unsigned int& k_vertex) const;
00053         std::vector<int> get_connectivity(const unsigned int& k_polygon) const;
00054 
00056         mesh& set_vertex(const unsigned int& k_vertex,const mesh_conv::MC_v3d& new_vertex);
00058         mesh& set_connectivity(const unsigned int& k_polygon,const std::vector<int>& new_triangle);
00059 
00060 
00061         //*********************************************//
00062         //*********************************************//
00063         // Size
00064         //*********************************************//
00065         //*********************************************//
00066 
00068         unsigned int vertex_number() const;
00070         unsigned int triangle_number() const;
00071 
00072         //*********************************************//
00073         //*********************************************//
00074         // Connectivity information
00075         //*********************************************//
00076         //*********************************************//
00077 
00079         std::map<int,std::list<int> > ring() const;
00081         std::map<int,std::list<int> > star() const;
00082 
00083 
00084 
00085         //*********************************************//
00086         //*********************************************//
00087         // Normal
00088         //*********************************************//
00089         //*********************************************//
00090 
00092         std::vector <double> normal_vertex() const;
00094         std::vector <double> normal_polygon() const;
00095 
00096         //*********************************************//
00097         //*********************************************//
00098         // INTERNAL ACCESS
00099         //*********************************************//
00100         //*********************************************//
00101 
00103         const std::vector<double>& get_vertex() const;
00105         std::vector<double>& get_vertex();
00106 
00108         const std::vector <int>& get_connectivity() const;
00110         std::vector <int>& get_connectivity();
00111 
00112         //*********************************************//
00113         //*********************************************//
00114         // Assert
00115         //*********************************************//
00116         //*********************************************//
00117 
00119         void assert_vertex(const unsigned int& k_vertex) const
00120         {if(3*k_vertex+2>=vertex.size()){std::cout<<"Error in mesh::assert_vertex("<<k_vertex<<"), vertex.size()="<<vertex.size()<<std::endl;exit(-1);}}
00121 
00123         void assert_connectivity(const unsigned int& k_connectivity) const
00124         {if(3*k_connectivity+2>=connectivity.size()){std::cout<<"Error in mesh::assert_connectivity("<<k_connectivity<<"), connectivity.size()="<<connectivity.size()<<std::endl;exit(-1);}}
00125 
00126 
00127         //*********************************************//
00128         //*********************************************//
00129         // IN/OUT
00130         //*********************************************//
00131         //*********************************************//
00132 
00134         static mesh load_off_file(const std::string& filename);
00136         const mesh& save_off_file(const std::string& filename) const;
00137 
00138 
00139         //*********************************************//
00140         //*********************************************//
00141         // Deformation
00142         //*********************************************//
00143         //*********************************************//
00144 
00146         mesh& scale_unity();
00147 
00148 
00149 
00150 
00151 
00152     };
00153 }
00154 
00155 #endif

Generated on Fri Sep 25 13:31:35 2009 by  doxygen 1.5.8