Go to the documentation of this file.00001 #ifndef OPENTISSUE_UTILITY_GL_GL_DRAW_GRID_H
00002 #define OPENTISSUE_UTILITY_GL_GL_DRAW_GRID_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/utility/gl/gl_util.h>
00013
00014 namespace OpenTissue
00015 {
00016
00017 namespace gl
00018 {
00019
00020 template<typename grid_type>
00021 inline void DrawGrid(grid_type const & grid)
00022 {
00023 typedef typename grid_type::math_types math_types;
00024 typedef typename math_types::real_type real_type;
00025
00026 size_t i,j,k;
00027
00028 real_type kmin = grid.min_coord(2);
00029 real_type kmax = grid.max_coord(2);
00030 real_type imin = grid.min_coord(0);
00031 real_type imax = grid.max_coord(0);
00032 real_type jmin = grid.min_coord(1);
00033 real_type jmax = grid.max_coord(1);
00034
00035 real_type ival,jval,kval;
00036
00037 glBegin(GL_LINES);
00038 jval = grid.min_coord(1);
00039 for(j=0; j < grid.J(); ++j)
00040 {
00041 ival = grid.min_coord(0);
00042 for(i=0; i<grid.I(); ++i)
00043 {
00044 glVertex3f(ival,jval,kmin);
00045 glVertex3f(ival,jval,kmax);
00046 ival += grid.dx();
00047 }
00048 jval += grid.dy();
00049 }
00050 kval = grid.min_coord(2);
00051 for(k=0; k<grid.K(); ++k)
00052 {
00053 jval = grid.min_coord(1);
00054 for(j=0; j<grid.J(); ++j)
00055 {
00056 glVertex3f(imin,jval,kval);
00057 glVertex3f(imax,jval,kval);
00058 jval += grid.dy();
00059 }
00060 kval += grid.dz();
00061 }
00062 kval = grid.min_coord(2);
00063 for(k=0; k<grid.K(); ++k)
00064 {
00065 ival = grid.min_coord(0);
00066 for(i=0; i<grid.I(); ++i)
00067 {
00068 glVertex3f(ival,jmin,kval);
00069 glVertex3f(ival,jmax,kval);
00070 ival += grid.dx();
00071 }
00072 kval += grid.dz();
00073 }
00074 glEnd();
00075 }
00076
00077 }
00078
00079 }
00080
00081
00082 #endif