primitives.cpp
Go to the documentation of this file.
00001 // HOG-Man - Hierarchical Optimization for Pose Graphs on Manifolds
00002 // Copyright (C) 2010 G. Grisetti, R. Kümmerle, C. Stachniss
00003 //
00004 // This file is part of HOG-Man.
00005 // 
00006 // HOG-Man is free software: you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation, either version 3 of the License, or
00009 // (at your option) any later version.
00010 // 
00011 // HOG-Man is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU General Public License
00017 // along with HOG-Man.  If not, see <http://www.gnu.org/licenses/>.
00018 
00019 #include "primitives.h"
00020 #include <qglviewer/qglviewer.h>
00021 #include <cstdlib>
00022 
00023 GLUquadricObj* g_quadratic = NULL;
00024 
00025 void freePrimitives()
00026 {
00027   if (g_quadratic) {
00028     gluDeleteQuadric(g_quadratic);
00029     g_quadratic = NULL;
00030   }
00031 }
00032 
00033 void initPrimitives()
00034 {
00035   if (!g_quadratic) {
00036     g_quadratic = gluNewQuadric();              // Create A Pointer To The Quadric Object ( NEW )
00037     gluQuadricNormals(g_quadratic, GLU_SMOOTH); // Create Smooth Normals ( NEW )
00038 
00039     atexit(freePrimitives);
00040   }
00041 }
00042 
00043 void drawAxis(float length)
00044 {
00045   QGLViewer::drawAxis(length);
00046 }
00047 
00048 void drawArrow(float length, float radius, int nbSubdivisions)
00049 {
00050   QGLViewer::drawArrow(length, radius, nbSubdivisions);
00051 }
00052 
00053 void drawGrid(float size, int nbSubdivisions)
00054 {
00055   QGLViewer::drawGrid(size, nbSubdivisions);
00056 }
00057 
00058 void drawArrow2D(float len, float head_width, float head_len)
00059 {
00060   glBegin(GL_LINES);
00061   glVertex2f(0, 0);
00062   glVertex2f(len, 0);
00063   glEnd();
00064 
00065   glNormal3f(0,0,1);
00066   glBegin(GL_TRIANGLES);
00067   glVertex2f(len, 0);
00068   glVertex2f(len - head_len,  0.5*head_width);
00069   glVertex2f(len - head_len, -0.5*head_width);
00070   glEnd();
00071 }
00072 
00073 void drawPoseBox()
00074 {
00075   glPushMatrix();
00076   glScalef(0.5,1,1);
00077   glPushMatrix();
00078   glScalef(1,0.25,0.5);
00079   glTranslatef(-0.5,0.5,0);
00080   glColor3f(1.0, 0.3, 0.3);
00081   drawBox(1, 1, 1);
00082   glPopMatrix();
00083 
00084   glPushMatrix();
00085   glScalef(1,0.25,0.5);
00086   glTranslatef(-0.5,-0.5,0);
00087   glColor3f(1.0, 0.1, 0.1);
00088   drawBox(1, 1, 1);
00089   glPopMatrix();
00090 
00091   glPushMatrix();
00092   glScalef(1,0.25,0.5);
00093   glTranslatef(+0.5,0.5,0);
00094   glColor3f(0.3, 0.3, 1.0);
00095   drawBox(1, 1, 1);
00096   glPopMatrix();
00097 
00098   glPushMatrix();
00099   glScalef(1,0.25,0.5);
00100   glTranslatef(+0.5,-0.5,0);
00101   glColor3f(0.1, 0.1, 1.);
00102   drawBox(1, 1, 1);
00103   glPopMatrix();
00104   glPopMatrix();
00105 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


hogman_minimal
Author(s): Maintained by Juergen Sturm
autogenerated on Wed Dec 26 2012 15:36:49