Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
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     
00042 
00044     void setOcTree(const AbstractOcTree& octree){
00045       octomap::pose6d o; 
00046       setOcTree(octree, o, 0);
00047     }
00048 
00051     virtual void setOcTree(const AbstractOcTree& octree, const octomap::pose6d& origin, int map_id_);
00052 
00053     
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     
00071     void setOrigin(octomap::pose6d t);
00072     void enableAxes(bool enabled = true) { m_displayAxes = enabled; };
00073 
00074   protected:
00075     
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     
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