draw_helpers.cpp
Go to the documentation of this file.
00001 // g2o - General Graph Optimization
00002 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
00003 //
00004 // This file is part of g2o.
00005 // 
00006 // g2o 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 // g2o 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 g2o.  If not, see <http://www.gnu.org/licenses/>.
00018 
00019 #include "draw_helpers.h"
00020 
00021 #include <cmath>
00022 
00023 namespace g2o {
00024 
00028   namespace {
00029     class GLUWrapper
00030     {
00031       public:
00032         static GLUquadricObj* getQuadradic()
00033         {
00034           static GLUWrapper inst;
00035           return inst._quadratic;
00036         }
00037       protected:
00038         GLUWrapper()
00039         {
00040           _quadratic = gluNewQuadric();              // Create A Pointer To The Quadric Object ( NEW )
00041           gluQuadricNormals(_quadratic, GLU_SMOOTH); // Create Smooth Normals ( NEW )
00042         }
00043         ~GLUWrapper()
00044         {
00045           gluDeleteQuadric(_quadratic);
00046         }
00047         GLUquadricObj* _quadratic;;
00048     };
00049   }
00050 
00051   void drawDisk(GLfloat radius)
00052   {
00053     gluDisk(GLUWrapper::getQuadradic(), 0, radius, 32, 1);
00054   }
00055 
00056   void drawCircle(GLfloat radius, int segments)
00057   {
00058     double angleStep = (2 * M_PI / (segments));
00059     glBegin(GL_LINE_STRIP);
00060     for (int i = 0; i <= segments; i++) {
00061       double angle = i * angleStep;
00062       float x = radius * cos(angle);
00063       float y = radius * sin(angle);
00064       glVertex3f(x, y, 0.f);
00065     }
00066     glEnd();
00067   }
00068 
00069 } // end namespace g2o


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:31:02