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 _IO_OFF_HPP_
00020 #define _IO_OFF_HPP_
00021
00022 #include <exception_cpe.hpp>
00023 #include <v3.hpp>
00024 #include <vector>
00025 #include <string>
00026
00027 #include <color.hpp>
00028
00029 namespace cpe
00030 {
00032 class mesh
00033 {
00034 public:
00035
00036
00037
00038
00039
00040
00041
00042
00044 const std::vector<v3>& get_vertices() const;
00046 const std::vector<v3>& get_normal() const;
00048 const std::vector<color>& get_color() const;
00050 const std::vector<int>& get_connectivity() const;
00051
00053 std::vector<v3>& get_vertices();
00055 std::vector<v3>& get_normal();
00057 std::vector<color>& get_color();
00059 std::vector<int>& get_connectivity();
00060
00061
00062
00063
00064
00065
00066
00068 void fill_color(const color& c);
00070 void fill_color_xyz();
00072 void fill_color_normal();
00073
00074
00075
00076
00077
00078
00079
00080
00082 void compute_normal();
00083
00084
00085
00086
00087
00088
00089
00091 friend mesh operator+(const v3& x,const mesh& m);
00093 friend mesh operator+(const mesh& m,const v3& x);
00095 mesh& operator+=(const v3& x);
00096
00098 friend mesh operator-(const mesh& m,const v3& x);
00100 mesh& operator-=(const v3& x);
00101
00103 friend mesh operator*(const double& s,const mesh& m);
00105 friend mesh operator*(const mesh& m,const double& s);
00107 mesh& operator*=(const double& s);
00108
00109
00111 void scale(const double& sx,const double& sy,const double& sz);
00117 void auto_scale(const double& scale=1.0);
00118
00119
00120
00121
00122
00123
00124
00125
00126
00128 void load_off(const std::string &filename);
00129
00130
00131
00132
00133
00134 private:
00135
00136
00137
00138
00139
00140
00141
00143 std::vector<v3> v_vertices;
00145 std::vector<v3> v_normal;
00147 std::vector<color> v_color;
00148
00150 std::vector<int> v_connectivity;
00151
00152 };
00153
00154
00155
00157 class exception_mesh : public exception_cpe
00158 {
00159 public:
00160
00162 exception_mesh():exception_cpe(){}
00164 exception_mesh(const std::string& msg,const std::string& file,const std::string& caller,const int& line):exception_cpe(msg,file,caller,line){}
00165 };
00166 }
00167
00168 #endif