Go to the documentation of this file.00001 #ifndef OPENTISSUE_UTILITY_GL_GL_DRAW_PLANE_H
00002 #define OPENTISSUE_UTILITY_GL_GL_DRAW_PLANE_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/utility/gl/gl.h>
00013
00014 namespace OpenTissue
00015 {
00016
00017 namespace gl
00018 {
00019
00027 template<typename plane_type>
00028 inline void DrawPlane(plane_type const & plane, bool wireframe = false)
00029 {
00030 typedef typename plane_type::vector3_type vector3_type;
00031 vector3_type p = plane.n()*plane.w();
00032 vector3_type s,t;
00033 plane.compute_plane_vectors(s,t);
00034 if (wireframe)
00035 {
00036 glBegin(GL_LINES);
00037 vector3_type a = p - 50*t;
00038 for(unsigned int i=0;i<101;++i)
00039 {
00040 vector3_type b = a - 50*s;
00041 vector3_type c = a + 50*s;
00042 glVertex3f(b(0),b(1),b(2));
00043 glVertex3f(c(0),c(1),c(2));
00044 a+=t;
00045 }
00046 a = p - 50*s;
00047 for(unsigned int i=0;i<101;++i)
00048 {
00049 vector3_type b = a - 50*t;
00050 vector3_type c = a + 50*t;
00051 glVertex3f(b(0),b(1),b(2));
00052 glVertex3f(c(0),c(1),c(2));
00053 a+=s;
00054 }
00055 glEnd();
00056 return;
00057 }
00058
00059
00060 glBegin(GL_QUADS);
00061 glNormal3f(plane.n()(0), plane.n()(1), plane.n()(2));
00062 vector3_type r = p - 50*s - 50*t;
00063 for(int j = -49; j < 51; ++j)
00064 {
00065 for(int i = -49; i < 51; ++i)
00066 {
00067 glVertex3f(r(0), r(1), r(2));
00068 r += s;
00069 glVertex3f(r(0), r(1), r(2));
00070 r += t;
00071 glVertex3f(r(0), r(1), r(2));
00072 r -= s;
00073 glVertex3f(r(0), r(1), r(2));
00074 r -= t;
00075 r += s;
00076 }
00077 r -= 100*s;
00078 r += t;
00079 }
00080 glEnd();
00081
00082 }
00083
00084 }
00085
00086 }
00087
00088
00089 #endif