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);
63 
64  void enableOcTree(bool enabled = true);
65  void enableOcTreeCells(bool enabled = true) { m_update = true; m_drawOccupied = enabled; };
66  void enableFreespace(bool enabled = true) { m_update = true; m_drawFree = enabled; };
67  void enableSelection(bool enabled = true) { m_update = true; m_drawSelection = enabled; };
68  void setMax_tree_depth(unsigned int max_tree_depth) { m_update = true; m_max_tree_depth = max_tree_depth;};
69 
70  // set new origin (move object)
71  void setOrigin(octomap::pose6d t);
72  void enableAxes(bool enabled = true) { m_update = true; m_displayAxes = enabled; };
73 
74  protected:
75  //void clearOcTree();
76  void clearOcTreeStructure();
77 
78  void drawOctreeGrid() const;
79  void drawOccupiedVoxels() const;
80  void drawFreeVoxels() const;
81  void drawSelection() const;
82  void drawCubes(GLfloat** cubeArray, unsigned int cubeArraySize,
83  GLfloat* cubeColorArray = NULL) const;
84 
85  void drawAxes() const;
86 
90  void generateCubes(const std::list<octomap::OcTreeVolume>& voxels,
91  GLfloat*** glArray, unsigned int& glArraySize,
92  octomath::Pose6D& origin,
93  GLfloat** glColorArray = NULL);
94 
96  void clearCubes(GLfloat*** glArray, unsigned int& glArraySize,
97  GLfloat** glColorArray = NULL);
99  void initGLArrays(const unsigned int& num_cubes, unsigned int& glArraySize,
100  GLfloat*** glArray, GLfloat** glColorArray);
102  void initCubeTemplate(const octomath::Pose6D& origin,
103  std::vector<octomath::Vector3>& cube_template);
105  unsigned int generateCube(const octomap::OcTreeVolume& v,
106  const std::vector<octomath::Vector3>& cube_template,
107  const unsigned int& current_array_idx,
108  GLfloat*** glArray);
109  unsigned int setCubeColorHeightmap(const octomap::OcTreeVolume& v,
110  const unsigned int& current_array_idx,
111  GLfloat** glColorArray);
112  unsigned int setCubeColorRGBA(const unsigned char& r, const unsigned char& g,
113  const unsigned char& b, const unsigned char& a,
114  const unsigned int& current_array_idx,
115  GLfloat** glColorArray);
116 
117 
118  void initOctreeGridVis();
119 
121 
123  unsigned int m_occupiedThresSize;
124  GLfloat** m_freeThresArray;
125  unsigned int m_freeThresSize;
126  GLfloat** m_occupiedArray;
127  unsigned int m_occupiedSize;
128  GLfloat** m_freeArray;
129  unsigned int m_freeSize;
130  GLfloat** m_selectionArray;
131  unsigned int m_selectionSize;
132 
136 
138  // TODO: put in its own drawer object!
141 
142  std::list<octomap::OcTreeVolume> m_grid_voxels;
143 
151  mutable bool m_update;
152 
153  unsigned int m_max_tree_depth;
155 
158 
159  int map_id;
160  };
161 }
162 
163 #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:65
unsigned int setCubeColorHeightmap(const octomap::OcTreeVolume &v, const unsigned int &current_array_idx, GLfloat **glColorArray)
unsigned int octree_grid_vertex_size
Definition: OcTreeDrawer.h:140
void enableAxes(bool enabled=true)
Definition: OcTreeDrawer.h:72
void drawFreeVoxels() const
void clearCubes(GLfloat ***glArray, unsigned int &glArraySize, GLfloat **glColorArray=NULL)
clear OpenGL visualization
GLfloat ** m_occupiedArray
Definition: OcTreeDrawer.h:126
GLfloat * octree_grid_vertex_array
OpenGL representation of Octree (grid structure)
Definition: OcTreeDrawer.h:139
void clearOcTreeSelection()
clear the visualization of the OcTree selection
void drawOccupiedVoxels() const
std::pair< point3d, double > OcTreeVolume
octomap::pose6d initial_origin
Definition: OcTreeDrawer.h:157
GLfloat * m_occupiedColorArray
Definition: OcTreeDrawer.h:135
void enableOcTree(bool enabled=true)
void initCubeTemplate(const octomath::Pose6D &origin, std::vector< octomath::Vector3 > &cube_template)
setup cube template
void drawSelection() const
unsigned int m_max_tree_depth
Definition: OcTreeDrawer.h:153
void setOcTreeSelection(const std::list< octomap::OcTreeVolume > &selectedPoints)
sets a new selection of the current OcTree to be drawn
void drawOctreeGrid() const
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:124
void setAlternativeDrawing(bool flag)
Definition: OcTreeDrawer.h:62
GLfloat ** m_occupiedThresArray
OpenGL representation of Octree cells (cubes)
Definition: OcTreeDrawer.h:122
unsigned int m_selectionSize
Definition: OcTreeDrawer.h:131
void enableFreespace(bool enabled=true)
Definition: OcTreeDrawer.h:66
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 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:142
unsigned int m_occupiedThresSize
Definition: OcTreeDrawer.h:123
void setAlphaOccupied(double alpha)
sets alpha level for occupied cells
octomap::pose6d origin
Definition: OcTreeDrawer.h:156
void setMax_tree_depth(unsigned int max_tree_depth)
Definition: OcTreeDrawer.h:68
unsigned int m_occupiedSize
Definition: OcTreeDrawer.h:127
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:130
unsigned int m_freeSize
Definition: OcTreeDrawer.h:129
GLfloat * m_occupiedThresColorArray
Color array for occupied cells (height)
Definition: OcTreeDrawer.h:134
void setOrigin(octomap::pose6d t)
void drawCubes(GLfloat **cubeArray, unsigned int cubeArraySize, GLfloat *cubeColorArray=NULL) const
unsigned int m_freeThresSize
Definition: OcTreeDrawer.h:125
void enableSelection(bool enabled=true)
Definition: OcTreeDrawer.h:67


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Mon Feb 28 2022 22:58:16