Visualizer.cpp
Go to the documentation of this file.
1 #include "Visualizer.h"
2 
3 #include <pcl/common/colors.h>
4 #include <pcl/point_types.h> // for pcl::RGB
5 
7 
8 
10 {
11 
13  = default;
14 
16  const armarx::DebugDrawerTopic& debugDrawer, const std::string& layer) :
17  voxelgrid::Visualizer<Voxel>(debugDrawer, layer)
18  {}
19 
21  = default;
22 
23 
24  bool Visualizer::isVisible(const Visualizer::VoxelVisuData& visu) const
25  {
26  return visu.voxel.isOccupied();
27  }
28 
30  {
31  ARMARX_CHECK(visu.voxel.isOccupied());
32 
33  const Label label = visu.voxel.getLabel();
34 
35  const pcl::RGB rgb = pcl::GlasbeyLUT::at(static_cast<unsigned int>(label)
36  % pcl::GlasbeyLUT::size());
37 
38  const armarx::DrawColor color = drawer().toDrawColor(rgb, alpha, true);
39 
40  drawer().drawBox({getVoxelLayer(), visu.name + "_" + std::to_string(label)},
41  visu.pos, visu.ori, visu.extents, color);
42  }
43 
44  float Visualizer::getAlpha() const
45  {
46  return alpha;
47  }
48 
50  {
53 
54  this->alpha = value;
55  }
56 
57 
58 }
visionx::voxelgrid::LabelOccupancy::Visualizer::isVisible
virtual bool isVisible(const VoxelVisuData &voxelVisu) const override
Indicate whether a voxel shall be drawn.
armarx::DebugDrawerTopic
The DebugDrawerTopic wraps a DebugDrawerInterfacePrx and provides a more useful interface than the Ic...
Definition: DebugDrawerTopic.h:152
visionx::voxelgrid::LabelOccupancy::Visualizer::setAlpha
void setAlpha(float value)
Set the alpha. Must be in [0, 1].
Definition: Visualizer.cpp:49
visionx::voxelgrid::Visualizer::VoxelVisuData
Information about a voxel about to-be-drawn.
Definition: Visualizer.hpp:96
visionx::voxelgrid::LabelOccupancy::Visualizer::getAlpha
float getAlpha() const
Get the alpha.
Definition: Visualizer.cpp:44
visionx::voxelgrid::LabelOccupancy::Visualizer::~Visualizer
virtual ~Visualizer() override
Virtual destructor.
visionx::voxelgrid::Visualizer::VoxelVisuData::pos
const Eigen::Vector3f & pos
The voxel.
Definition: Visualizer.hpp:104
visionx::voxelgrid::Visualizer< Voxel >::drawer
armarx::DebugDrawerTopic & drawer()
Get the debug drawer.
Definition: Visualizer.hpp:122
armarx::DebugDrawerTopic::toDrawColor
static DrawColor toDrawColor(const ColorT &color, float alpha=1, bool byteToFloat=false)
Construct a DrawColor from the given color type.
Definition: DebugDrawerTopic.h:841
Visualizer.h
visionx::voxelgrid::Visualizer::VoxelVisuData::ori
const Eigen::Quaternionf & ori
The voxel's position.
Definition: Visualizer.hpp:105
visionx::voxelgrid::LabelOccupancy
Definition: Visualizer.cpp:9
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition: ExpressionException.h:82
visionx::voxelgrid::Label
uint32_t Label
Type of an object label.
Definition: types.h:7
visionx::voxelgrid::LabelOccupancy::Visualizer::Visualizer
Visualizer()
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
visionx::voxelgrid::Visualizer< Voxel >::getVoxelLayer
std::string getVoxelLayer() const
Get the layer name.
Definition: Visualizer.hpp:132
visionx::voxelgrid::Visualizer::VoxelVisuData::voxel
const VoxelT & voxel
The voxel's index.
Definition: Visualizer.hpp:102
armarx::DebugDrawerTopic::drawBox
void drawBox(const VisuID &id, const Eigen::Vector3f &position, const Eigen::Quaternionf &orientation, const Eigen::Vector3f &extents, const DrawColor &color=DEFAULTS.colorBox, bool ignoreLengthScale=false)
Draw a box.
Definition: DebugDrawerTopic.cpp:179
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:40
ARMARX_CHECK_LESS_EQUAL
#define ARMARX_CHECK_LESS_EQUAL(lhs, rhs)
This macro evaluates whether lhs is less or equal (<=) rhs and if it turns out to be false it will th...
Definition: ExpressionException.h:109
ExpressionException.h
visionx::voxelgrid::Visualizer::VoxelVisuData::extents
const Eigen::Vector3f & extents
The voxel's orientation.
Definition: Visualizer.hpp:106
visionx::voxelgrid::LabelOccupancy::Visualizer
Visualizer for label occupancy voxel grids.
Definition: Visualizer.h:16
visionx::voxelgrid::LabelOccupancy::Visualizer::drawVoxel
virtual void drawVoxel(const VoxelVisuData &voxelVisu) override
Draw a voxel.
visionx::voxelgrid::LabelOccupancy::Visualizer::alpha
float alpha
Definition: Visualizer.h:40
visionx::voxelgrid::LabelOccupancy::Voxel
A voxel storing whether it is occupied or free and the object label it is occupied by.
Definition: VoxelGrid.h:23
visionx::voxelgrid::Visualizer::VoxelVisuData::name
const std::string & name
The voxel grid.
Definition: Visualizer.hpp:99