OcTreeDrawer.h
Go to the documentation of this file.
00001 /*
00002  * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
00003  * http://octomap.github.com/
00004  *
00005  * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
00006  * All rights reserved.
00007  * License (octovis): GNU GPL v2
00008  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
00009  *
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful, but
00017  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00018  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
00019  * for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License along
00022  * with this program; if not, write to the Free Software Foundation, Inc.,
00023  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00024  */
00025 
00026 #ifndef OCTREEDRAWER_H_
00027 #define OCTREEDRAWER_H_
00028 
00029 #include "SceneObject.h"
00030 
00031 namespace octomap {
00032 
00033   class OcTreeDrawer: public octomap::SceneObject {
00034   public:
00035     OcTreeDrawer();
00036     virtual ~OcTreeDrawer();
00037     void clear();
00038 
00039     void draw() const;
00040 
00041     // initialization of drawer  -------------------------
00042 
00044     void setOcTree(const AbstractOcTree& octree){
00045       octomap::pose6d o; // initialized to (0,0,0) , (0,0,0,1) by default
00046       setOcTree(octree, o, 0);
00047     }
00048 
00051     virtual void setOcTree(const AbstractOcTree& octree, const octomap::pose6d& origin, int map_id_);
00052 
00053     // modification of existing drawer  ------------------
00054 
00056     void setOcTreeSelection(const std::list<octomap::OcTreeVolume>& selectedPoints);
00057 
00059     void clearOcTreeSelection();
00060 
00062     void setAlphaOccupied(double alpha);
00063 
00064     void enableOcTree(bool enabled = true);
00065     void enableOcTreeCells(bool enabled = true) {m_drawOccupied = enabled; };
00066     void enableFreespace(bool enabled = true) {m_drawFree = enabled; };
00067     void enableSelection(bool enabled = true) {m_drawSelection = enabled; };
00068     void setMax_tree_depth(unsigned int max_tree_depth) {m_max_tree_depth = max_tree_depth;};
00069 
00070     // set new origin (move object)
00071     void setOrigin(octomap::pose6d t);
00072     void enableAxes(bool enabled = true) { m_displayAxes = enabled; };
00073 
00074   protected:
00075     //void clearOcTree();
00076     void clearOcTreeStructure();
00077 
00078     void drawOctreeGrid() const;
00079     void drawOccupiedVoxels() const;
00080     void drawFreeVoxels() const;
00081     void drawSelection() const;
00082     void drawCubes(GLfloat** cubeArray, unsigned int cubeArraySize,
00083         GLfloat* cubeColorArray = NULL) const;
00084 
00085     void drawAxes() const;
00086 
00090     void generateCubes(const std::list<octomap::OcTreeVolume>& voxels,
00091                        GLfloat*** glArray, unsigned int& glArraySize, 
00092                        octomath::Pose6D& origin,
00093                        GLfloat** glColorArray = NULL);
00094     
00096     void clearCubes(GLfloat*** glArray, unsigned int& glArraySize,
00097                     GLfloat** glColorArray = NULL);
00099     void initGLArrays(const unsigned int& num_cubes, unsigned int& glArraySize,
00100                        GLfloat*** glArray, GLfloat** glColorArray);
00102     void initCubeTemplate(const octomath::Pose6D& origin,
00103                           std::vector<octomath::Vector3>& cube_template);
00105     unsigned int generateCube(const octomap::OcTreeVolume& v,
00106                               const std::vector<octomath::Vector3>& cube_template,
00107                               const unsigned int& current_array_idx,
00108                               GLfloat*** glArray);
00109     unsigned int setCubeColorHeightmap(const octomap::OcTreeVolume& v,
00110                                        const unsigned int& current_array_idx,
00111                                        GLfloat** glColorArray);
00112     unsigned int setCubeColorRGBA(const unsigned char& r, const unsigned char& g, 
00113                                   const unsigned char& b, const unsigned char& a,
00114                                   const unsigned int& current_array_idx,
00115                                   GLfloat** glColorArray);
00116       
00117 
00118     void initOctreeGridVis();
00119 
00121 
00122     GLfloat** m_occupiedThresArray;
00123     unsigned int m_occupiedThresSize;
00124     GLfloat** m_freeThresArray;
00125     unsigned int m_freeThresSize;
00126     GLfloat** m_occupiedArray;
00127     unsigned int m_occupiedSize;
00128     GLfloat** m_freeArray;
00129     unsigned int m_freeSize;
00130     GLfloat** m_selectionArray;
00131     unsigned int m_selectionSize;
00132 
00134     GLfloat* m_occupiedThresColorArray;
00135     GLfloat* m_occupiedColorArray;
00136 
00138     // TODO: put in its own drawer object!
00139     GLfloat* octree_grid_vertex_array;
00140     unsigned int octree_grid_vertex_size;
00141 
00142     std::list<octomap::OcTreeVolume> m_grid_voxels;
00143 
00144     bool m_drawOccupied;
00145     bool m_drawOcTreeGrid;
00146     bool m_drawFree;
00147     bool m_drawSelection;
00148     bool m_octree_grid_vis_initialized;
00149     bool m_displayAxes;
00150 
00151     unsigned int m_max_tree_depth;
00152     double m_alphaOccupied;
00153 
00154     octomap::pose6d origin;
00155     octomap::pose6d initial_origin;
00156 
00157     int map_id;
00158   };
00159 }
00160 
00161 #endif /* OCTREEDRAWER_H_ */


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Thu Aug 27 2015 14:13:26