OcTreeDrawer.h
Go to the documentation of this file.
1 /*
2  * This file is part of OctoMap - An Efficient Probabilistic 3D Mapping
3  * Framework Based on Octrees
4  * http://octomap.github.io
5  *
6  * Copyright (c) 2009-2014, K.M. Wurm and A. Hornung, University of Freiburg
7  * All rights reserved. License for the viewer octovis: GNU GPL v2
8  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
9  *
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  * for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see http://www.gnu.org/licenses/.
23  */
24 
25 #ifndef OCTREEDRAWER_H_
26 #define OCTREEDRAWER_H_
27 
28 #include "SceneObject.h"
29 
30 namespace octomap {
31 
33  public:
34  OcTreeDrawer();
35  virtual ~OcTreeDrawer();
36  void clear();
37 
38  void draw() const;
39 
40  // initialization of drawer -------------------------
41 
43  void setOcTree(const AbstractOcTree& octree){
44  octomap::pose6d o; // initialized to (0,0,0) , (0,0,0,1) by default
45  setOcTree(octree, o, 0);
46  }
47 
50  virtual void setOcTree(const AbstractOcTree& octree, const octomap::pose6d& origin, int map_id_);
51 
52  // modification of existing drawer ------------------
53 
55  void setOcTreeSelection(const std::list<octomap::OcTreeVolume>& selectedPoints);
56 
58  void clearOcTreeSelection();
59 
61  void setAlphaOccupied(double alpha);
62 
63  void enableOcTree(bool enabled = true);
64  void enableOcTreeCells(bool enabled = true) {m_drawOccupied = enabled; };
65  void enableFreespace(bool enabled = true) {m_drawFree = enabled; };
66  void enableSelection(bool enabled = true) {m_drawSelection = enabled; };
67  void setMax_tree_depth(unsigned int max_tree_depth) {m_max_tree_depth = max_tree_depth;};
68 
69  // set new origin (move object)
70  void setOrigin(octomap::pose6d t);
71  void enableAxes(bool enabled = true) { m_displayAxes = enabled; };
72 
73  protected:
74  //void clearOcTree();
75  void clearOcTreeStructure();
76 
77  void drawOctreeGrid() const;
78  void drawOccupiedVoxels() const;
79  void drawFreeVoxels() const;
80  void drawSelection() const;
81  void drawCubes(GLfloat** cubeArray, unsigned int cubeArraySize,
82  GLfloat* cubeColorArray = NULL) const;
83 
84  void drawAxes() const;
85 
89  void generateCubes(const std::list<octomap::OcTreeVolume>& voxels,
90  GLfloat*** glArray, unsigned int& glArraySize,
91  octomath::Pose6D& origin,
92  GLfloat** glColorArray = NULL);
93 
95  void clearCubes(GLfloat*** glArray, unsigned int& glArraySize,
96  GLfloat** glColorArray = NULL);
98  void initGLArrays(const unsigned int& num_cubes, unsigned int& glArraySize,
99  GLfloat*** glArray, GLfloat** glColorArray);
101  void initCubeTemplate(const octomath::Pose6D& origin,
102  std::vector<octomath::Vector3>& cube_template);
104  unsigned int generateCube(const octomap::OcTreeVolume& v,
105  const std::vector<octomath::Vector3>& cube_template,
106  const unsigned int& current_array_idx,
107  GLfloat*** glArray);
108  unsigned int setCubeColorHeightmap(const octomap::OcTreeVolume& v,
109  const unsigned int& current_array_idx,
110  GLfloat** glColorArray);
111  unsigned int setCubeColorRGBA(const unsigned char& r, const unsigned char& g,
112  const unsigned char& b, const unsigned char& a,
113  const unsigned int& current_array_idx,
114  GLfloat** glColorArray);
115 
116 
117  void initOctreeGridVis();
118 
120 
122  unsigned int m_occupiedThresSize;
123  GLfloat** m_freeThresArray;
124  unsigned int m_freeThresSize;
125  GLfloat** m_occupiedArray;
126  unsigned int m_occupiedSize;
127  GLfloat** m_freeArray;
128  unsigned int m_freeSize;
129  GLfloat** m_selectionArray;
130  unsigned int m_selectionSize;
131 
135 
137  // TODO: put in its own drawer object!
140 
141  std::list<octomap::OcTreeVolume> m_grid_voxels;
142 
149 
150  unsigned int m_max_tree_depth;
152 
155 
156  int map_id;
157  };
158 }
159 
160 #endif /* OCTREEDRAWER_H_ */
void setOcTree(const AbstractOcTree &octree)
sets a new OcTree that should be drawn by this drawer
Definition: OcTreeDrawer.h:43
void enableOcTreeCells(bool enabled=true)
Definition: OcTreeDrawer.h:64
unsigned int setCubeColorHeightmap(const octomap::OcTreeVolume &v, const unsigned int &current_array_idx, GLfloat **glColorArray)
unsigned int octree_grid_vertex_size
Definition: OcTreeDrawer.h:139
void enableAxes(bool enabled=true)
Definition: OcTreeDrawer.h:71
void clearCubes(GLfloat ***glArray, unsigned int &glArraySize, GLfloat **glColorArray=NULL)
clear OpenGL visualization
GLfloat ** m_occupiedArray
Definition: OcTreeDrawer.h:125
GLfloat * octree_grid_vertex_array
OpenGL representation of Octree (grid structure)
Definition: OcTreeDrawer.h:138
void clearOcTreeSelection()
clear the visualization of the OcTree selection
std::pair< point3d, double > OcTreeVolume
octomap::pose6d initial_origin
Definition: OcTreeDrawer.h:154
GLfloat * m_occupiedColorArray
Definition: OcTreeDrawer.h:134
void enableOcTree(bool enabled=true)
void initCubeTemplate(const octomath::Pose6D &origin, std::vector< octomath::Vector3 > &cube_template)
setup cube template
unsigned int m_max_tree_depth
Definition: OcTreeDrawer.h:150
void setOcTreeSelection(const std::list< octomap::OcTreeVolume > &selectedPoints)
sets a new selection of the current OcTree to be drawn
void generateCubes(const std::list< octomap::OcTreeVolume > &voxels, GLfloat ***glArray, unsigned int &glArraySize, octomath::Pose6D &origin, GLfloat **glColorArray=NULL)
GLfloat ** m_freeThresArray
Definition: OcTreeDrawer.h:123
void drawFreeVoxels() const
void drawAxes() const
void drawOctreeGrid() const
GLfloat ** m_occupiedThresArray
OpenGL representation of Octree cells (cubes)
Definition: OcTreeDrawer.h:121
unsigned int m_selectionSize
Definition: OcTreeDrawer.h:130
void enableFreespace(bool enabled=true)
Definition: OcTreeDrawer.h:65
void drawOccupiedVoxels() const
unsigned int generateCube(const octomap::OcTreeVolume &v, const std::vector< octomath::Vector3 > &cube_template, const unsigned int &current_array_idx, GLfloat ***glArray)
add one cube to arrays
void drawSelection() const
void initGLArrays(const unsigned int &num_cubes, unsigned int &glArraySize, GLfloat ***glArray, GLfloat **glColorArray)
setup OpenGL arrays
std::list< octomap::OcTreeVolume > m_grid_voxels
Definition: OcTreeDrawer.h:141
void drawCubes(GLfloat **cubeArray, unsigned int cubeArraySize, GLfloat *cubeColorArray=NULL) const
unsigned int m_occupiedThresSize
Definition: OcTreeDrawer.h:122
void setAlphaOccupied(double alpha)
sets alpha level for occupied cells
octomap::pose6d origin
Definition: OcTreeDrawer.h:153
void setMax_tree_depth(unsigned int max_tree_depth)
Definition: OcTreeDrawer.h:67
unsigned int m_occupiedSize
Definition: OcTreeDrawer.h:126
unsigned int setCubeColorRGBA(const unsigned char &r, const unsigned char &g, const unsigned char &b, const unsigned char &a, const unsigned int &current_array_idx, GLfloat **glColorArray)
GLfloat ** m_selectionArray
Definition: OcTreeDrawer.h:129
unsigned int m_freeSize
Definition: OcTreeDrawer.h:128
GLfloat * m_occupiedThresColorArray
Color array for occupied cells (height)
Definition: OcTreeDrawer.h:133
void setOrigin(octomap::pose6d t)
unsigned int m_freeThresSize
Definition: OcTreeDrawer.h:124
void enableSelection(bool enabled=true)
Definition: OcTreeDrawer.h:66


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Mon Jun 10 2019 14:00:25