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,
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);
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_ */
octomap::OcTreeDrawer::enableAxes
void enableAxes(bool enabled=true)
Definition: OcTreeDrawer.h:72
octomap::OcTreeDrawer::drawFreeVoxels
void drawFreeVoxels() const
Definition: OcTreeDrawer.cpp:721
octomap::OcTreeDrawer::setAlphaOccupied
void setAlphaOccupied(double alpha)
sets alpha level for occupied cells
Definition: OcTreeDrawer.cpp:134
octomap::OcTreeDrawer::m_drawOccupied
bool m_drawOccupied
Definition: OcTreeDrawer.h:144
octomap::OcTreeDrawer::m_drawFree
bool m_drawFree
Definition: OcTreeDrawer.h:146
octomap::OcTreeVolume
std::pair< point3d, double > OcTreeVolume
octomap::OcTreeDrawer::setOrigin
void setOrigin(octomap::pose6d t)
Definition: OcTreeDrawer.cpp:865
octomap::OcTreeDrawer::m_octree_grid_vis_initialized
bool m_octree_grid_vis_initialized
Definition: OcTreeDrawer.h:148
octomap::OcTreeDrawer::clearCubes
void clearCubes(GLfloat ***glArray, unsigned int &glArraySize, GLfloat **glColorArray=NULL)
clear OpenGL visualization
Definition: OcTreeDrawer.cpp:494
octomap::OcTreeDrawer::m_occupiedThresArray
GLfloat ** m_occupiedThresArray
OpenGL representation of Octree cells (cubes)
Definition: OcTreeDrawer.h:122
octomap::OcTreeDrawer::m_occupiedSize
unsigned int m_occupiedSize
Definition: OcTreeDrawer.h:127
octomap::OcTreeDrawer::setCubeColorHeightmap
unsigned int setCubeColorHeightmap(const octomap::OcTreeVolume &v, const unsigned int &current_array_idx, GLfloat **glColorArray)
Definition: OcTreeDrawer.cpp:453
octomap::OcTreeDrawer::map_id
int map_id
Definition: OcTreeDrawer.h:159
octomap::OcTreeDrawer::m_freeThresArray
GLfloat ** m_freeThresArray
Definition: OcTreeDrawer.h:124
octomap::OcTreeDrawer::m_drawSelection
bool m_drawSelection
Definition: OcTreeDrawer.h:147
octomap::SceneObject
Definition: SceneObject.h:48
octomap::OcTreeDrawer::clearOcTreeSelection
void clearOcTreeSelection()
clear the visualization of the OcTree selection
Definition: OcTreeDrawer.cpp:250
octomap::OcTreeDrawer::m_occupiedColorArray
GLfloat * m_occupiedColorArray
Definition: OcTreeDrawer.h:135
octomap::OcTreeDrawer::initCubeTemplate
void initCubeTemplate(const octomath::Pose6D &origin, std::vector< octomath::Vector3 > &cube_template)
setup cube template
Definition: OcTreeDrawer.cpp:274
octomap::OcTreeDrawer::drawOccupiedVoxels
void drawOccupiedVoxels() const
Definition: OcTreeDrawer.cpp:680
octomap::OcTreeDrawer::m_selectionArray
GLfloat ** m_selectionArray
Definition: OcTreeDrawer.h:130
octomap::OcTreeDrawer::draw
void draw() const
Definition: OcTreeDrawer.cpp:64
octomap::OcTreeDrawer::m_occupiedThresSize
unsigned int m_occupiedThresSize
Definition: OcTreeDrawer.h:123
octomap::OcTreeDrawer::setMax_tree_depth
void setMax_tree_depth(unsigned int max_tree_depth)
Definition: OcTreeDrawer.h:68
octomap::OcTreeDrawer::m_max_tree_depth
unsigned int m_max_tree_depth
Definition: OcTreeDrawer.h:153
octomap::AbstractOcTree
octomap::OcTreeDrawer::setCubeColorRGBA
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)
Definition: OcTreeDrawer.cpp:473
octomap::OcTreeDrawer::~OcTreeDrawer
virtual ~OcTreeDrawer()
Definition: OcTreeDrawer.cpp:60
octomap::OcTreeDrawer::drawSelection
void drawSelection() const
Definition: OcTreeDrawer.cpp:745
octomap::OcTreeDrawer::m_freeThresSize
unsigned int m_freeThresSize
Definition: OcTreeDrawer.h:125
octomap::OcTreeDrawer::m_drawOcTreeGrid
bool m_drawOcTreeGrid
Definition: OcTreeDrawer.h:145
octomap::OcTreeDrawer::initial_origin
octomap::pose6d initial_origin
Definition: OcTreeDrawer.h:157
octomap::OcTreeDrawer::clear
void clear()
Definition: OcTreeDrawer.cpp:669
octomap::OcTreeDrawer::m_grid_voxels
std::list< octomap::OcTreeVolume > m_grid_voxels
Definition: OcTreeDrawer.h:142
octomap::OcTreeDrawer::OcTreeDrawer
OcTreeDrawer()
Definition: OcTreeDrawer.cpp:33
octomap::OcTreeDrawer::clearOcTreeStructure
void clearOcTreeStructure()
Definition: OcTreeDrawer.cpp:661
octomap::OcTreeDrawer::drawOctreeGrid
void drawOctreeGrid() const
Definition: OcTreeDrawer.cpp:840
octomap::OcTreeDrawer::enableFreespace
void enableFreespace(bool enabled=true)
Definition: OcTreeDrawer.h:66
octomap::OcTreeDrawer::enableSelection
void enableSelection(bool enabled=true)
Definition: OcTreeDrawer.h:67
octomap::OcTreeDrawer::enableOcTreeCells
void enableOcTreeCells(bool enabled=true)
Definition: OcTreeDrawer.h:65
octomap::OcTreeDrawer::m_selectionSize
unsigned int m_selectionSize
Definition: OcTreeDrawer.h:131
octomap::OcTreeDrawer::m_displayAxes
bool m_displayAxes
Definition: OcTreeDrawer.h:149
octomap::OcTreeDrawer::m_occupiedThresColorArray
GLfloat * m_occupiedThresColorArray
Color array for occupied cells (height)
Definition: OcTreeDrawer.h:134
octomap::OcTreeDrawer
Definition: OcTreeDrawer.h:32
SceneObject.h
octomap::OcTreeDrawer::m_occupiedArray
GLfloat ** m_occupiedArray
Definition: OcTreeDrawer.h:126
octomap::OcTreeDrawer::generateCubes
void generateCubes(const std::list< octomap::OcTreeVolume > &voxels, GLfloat ***glArray, unsigned int &glArraySize, octomath::Pose6D &origin, GLfloat **glColorArray=NULL)
Definition: OcTreeDrawer.cpp:513
octomap::OcTreeDrawer::initOctreeGridVis
void initOctreeGridVis()
Definition: OcTreeDrawer.cpp:536
octomap::OcTreeDrawer::m_alternativeDrawing
bool m_alternativeDrawing
Definition: OcTreeDrawer.h:150
octomap::OcTreeDrawer::setOcTreeSelection
void setOcTreeSelection(const std::list< octomap::OcTreeVolume > &selectedPoints)
sets a new selection of the current OcTree to be drawn
Definition: OcTreeDrawer.cpp:241
octomap::OcTreeDrawer::origin
octomap::pose6d origin
Definition: OcTreeDrawer.h:156
octomap::OcTreeDrawer::generateCube
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
Definition: OcTreeDrawer.cpp:308
octomap::OcTreeDrawer::m_alphaOccupied
double m_alphaOccupied
Definition: OcTreeDrawer.h:154
octomap::OcTreeDrawer::setAlternativeDrawing
void setAlternativeDrawing(bool flag)
Definition: OcTreeDrawer.h:62
octomap::OcTreeDrawer::drawAxes
void drawAxes() const
Definition: OcTreeDrawer.cpp:876
octomap::OcTreeDrawer::initGLArrays
void initGLArrays(const unsigned int &num_cubes, unsigned int &glArraySize, GLfloat ***glArray, GLfloat **glColorArray)
setup OpenGL arrays
Definition: OcTreeDrawer.cpp:255
octomap::OcTreeDrawer::m_update
bool m_update
Definition: OcTreeDrawer.h:151
octomap
octomath::Pose6D
octomap::OcTreeDrawer::enableOcTree
void enableOcTree(bool enabled=true)
Definition: OcTreeDrawer.cpp:856
octomap::OcTreeDrawer::octree_grid_vertex_size
unsigned int octree_grid_vertex_size
Definition: OcTreeDrawer.h:140
octomap::OcTreeDrawer::m_freeSize
unsigned int m_freeSize
Definition: OcTreeDrawer.h:129
octomap::OcTreeDrawer::drawCubes
void drawCubes(GLfloat **cubeArray, unsigned int cubeArraySize, GLfloat *cubeColorArray=NULL) const
Definition: OcTreeDrawer.cpp:752
octomap::OcTreeDrawer::octree_grid_vertex_array
GLfloat * octree_grid_vertex_array
OpenGL representation of Octree (grid structure)
Definition: OcTreeDrawer.h:139
octomap::OcTreeDrawer::m_freeArray
GLfloat ** m_freeArray
Definition: OcTreeDrawer.h:128
octomap::OcTreeDrawer::setOcTree
void setOcTree(const AbstractOcTree &octree)
sets a new OcTree that should be drawn by this drawer
Definition: OcTreeDrawer.h:43


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Thu Apr 3 2025 02:40:44