00001 /* 00002 ** Mesh Converter 00003 ** Copyright (C) 2008 Damien Rohmer 00004 ** 00005 ** This program is free software: you can redistribute it and/or modify 00006 ** it under the terms of the GNU General Public License as published by 00007 ** the Free Software Foundation, either version 3 of the License, or 00008 ** (at your option) any later version. 00009 ** 00010 ** This program is distributed in the hope that it will be useful, 00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 ** GNU General Public License for more details. 00014 ** 00015 ** You should have received a copy of the GNU General Public License 00016 ** along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #ifndef MC_OPENGL_DRAWER_HPP_ 00020 #define MC_OPENGL_DRAWER_HPP_ 00021 00022 #include <stdlib.h> 00023 #include <iostream> 00024 00025 #include <GL/glut.h> 00026 #include <MC_curve.hpp> 00027 00028 namespace mesh_conv 00029 { 00030 00031 class MC_mesh_index_vector; 00032 class MC_mesh_index_vector_draw; 00033 class MC_mesh_fast_draw; 00034 class MC_segment; 00035 class MC_v3d; 00036 class MC_polygon; 00037 00038 namespace object 00039 { 00040 class MC_bounding_box_oriented; 00041 } 00042 00043 namespace mesh 00044 { 00045 namespace cgal 00046 { 00047 class MC_mesh_cgal; 00048 } 00049 } 00050 00052 00053 class MC_opengl_drawer 00054 { 00055 public: 00056 00057 00058 //*********************************************// 00059 //*********************************************// 00060 // CONSTRUCTORS 00061 //*********************************************// 00062 //*********************************************// 00063 00064 00066 MC_opengl_drawer(); 00067 00068 00069 00070 //*********************************************// 00071 //*********************************************// 00072 // Static drawer 00073 //*********************************************// 00074 //*********************************************// 00075 00077 static const MC_mesh_index_vector& draw(const MC_mesh_index_vector& mesh); 00079 static void draw_per_polygon_color(const MC_mesh_index_vector& mesh,const MC_v3d_vector& color_per_polygon); 00081 static const MC_mesh_index_vector_draw& draw(const MC_mesh_index_vector_draw& mesh); 00083 static const MC_mesh_fast_draw& draw(const MC_mesh_fast_draw& mesh); 00085 static const MC_segment& draw(const MC_segment& segment); 00087 static const std::vector<MC_segment>& draw(const std::vector<MC_segment>& segments); 00089 static const MC_curve& draw(const MC_curve& curve); 00091 static const std::vector <MC_curve>& draw(const std::vector <MC_curve>& curves); 00093 static const MC_polygon& draw(const MC_polygon& polygon); 00095 static void draw(const object::MC_bounding_box_oriented& bb); 00096 00098 static MC_opengl_drawer draw_triangular(const mesh::cgal::MC_mesh_cgal& mesh); 00099 00101 static void draw_sphere(const MC_v3d& position,const double& radius=0.5,const int& N_subdiv=2); 00106 static void draw_sphere(const MC_v3d_vector& position,const double& radius=0.5,const int& N_subdiv=2); 00107 00109 static void draw_points(const MC_v3d_vector& position); 00110 00112 static const MC_mesh_index_vector& draw_grid(const MC_mesh_index_vector& mesh); 00114 static const MC_mesh_fast_draw& draw_grid(const MC_mesh_fast_draw& mesh); 00115 00117 static const MC_mesh_index_vector& draw_normal_per_polygon(const MC_mesh_index_vector& mesh,const double& L=0.1); 00118 00120 template <typename T> 00121 static const MC_opengl_drawer draw(const std::vector<T>& to_draw) 00122 { 00123 for(int k=0,N=to_draw.size();k<N;++k) 00124 MC_opengl_drawer::draw(to_draw[k]); 00125 return MC_opengl_drawer(); 00126 } 00127 00128 //*********************************************// 00129 //*********************************************// 00130 // Send geometry to GPU 00131 //*********************************************// 00132 //*********************************************// 00133 00136 static GLuint send_gpu(const MC_mesh_fast_draw& mesh); 00137 00140 static GLuint send_gpu_grid(const MC_mesh_index_vector& mesh); 00141 00142 private: 00143 00144 00145 }; 00146 } 00147 00148 #endif
1.6.1