39 #include <octomap_msgs/Octomap.h> 42 #include <OgreSceneNode.h> 43 #include <OgreSceneManager.h> 49 typedef std::vector<rviz::PointCloud::Point>
VPoint;
54 std::size_t max_octree_depth, Ogre::SceneManager* scene_manager,
55 Ogre::SceneNode* parent_node = NULL)
56 : octree_(octree), colorFactor_(0.8)
63 if (!max_octree_depth)
69 octree_depth_ = std::min(max_octree_depth, (std::size_t)octree->getTreeDepth());
78 std::stringstream sname;
79 sname <<
"PointCloud Nr." << i;
81 cloud_[i]->setName(sname.str());
83 scene_node_->attachObject(
cloud_[i]);
119 double h = (1.0 - std::min(std::max((z_pos - min_z) / (max_z - min_z), 0.0), 1.0)) * color_factor;
164 double minX, minY, minZ, maxX, maxY, maxZ;
165 octree->getMetricMin(minX, minY, minZ);
166 octree->getMetricMax(maxX, maxY, maxZ);
168 unsigned int render_mode_mask =
static_cast<unsigned int>(octree_voxel_rendering);
170 size_t pointCount = 0;
175 bool display_voxel =
false;
178 if (((
int)octree->isNodeOccupied(*it) + 1) & render_mode_mask)
181 bool allNeighborsFound =
true;
186 for (key[2] = nKey[2] - 1; allNeighborsFound && key[2] <= nKey[2] + 1; ++key[2])
188 for (key[1] = nKey[1] - 1; allNeighborsFound && key[1] <= nKey[1] + 1; ++key[1])
190 for (key[0] = nKey[0] - 1; allNeighborsFound && key[0] <= nKey[0] + 1; ++key[0])
197 if (!(node && (((
int)octree->isNodeOccupied(node)) + 1) & render_mode_mask))
200 allNeighborsFound =
false;
207 display_voxel |= !allNeighborsFound;
218 float cell_probability;
220 switch (octree_color_mode)
226 cell_probability = it->getOccupancy();
227 newPoint.
setColor((1.0
f - cell_probability), cell_probability, 0.0);
234 unsigned int depth = it.getDepth();
235 pointBuf_[depth - 1].push_back(newPoint);
244 double size = octree->getNodeSize(i + 1);
247 cloud_[i]->setDimensions(size, size, size);
249 cloud_[i]->addPoints(&pointBuf_[i].front(), pointBuf_[i].size());
250 pointBuf_[i].clear();
std::vector< rviz::PointCloud::Point > VPoint
void setColor(double z_pos, double min_z, double max_z, double color_factor, rviz::PointCloud::Point *point)
std::size_t size(custom_string const &s)
std::vector< VPoint > VVPoint
void setOrientation(const Ogre::Quaternion &orientation)
void setPosition(const Ogre::Vector3 &position)
Ogre::SceneManager * scene_manager_
OcTreeRender(const std::shared_ptr< const octomap::OcTree > &octree, OctreeVoxelRenderMode octree_voxel_rendering, OctreeVoxelColorMode octree_color_mode, std::size_t max_octree_depth, Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node)
std::vector< rviz::PointCloud * > cloud_
std::size_t octree_depth_
void octreeDecoding(const std::shared_ptr< const octomap::OcTree > &octree, OctreeVoxelRenderMode octree_voxel_rendering, OctreeVoxelColorMode octree_color_mode)
Ogre::SceneNode * scene_node_
void setColor(float r, float g, float b, float a=1.0)