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 
9 {
10 
11  Visualizer::Visualizer() = default;
12 
13  Visualizer::Visualizer(const armarx::DebugDrawerTopic& debugDrawer, const std::string& layer) :
14  voxelgrid::Visualizer<Voxel>(debugDrawer, layer)
15  {
16  }
17 
18  Visualizer::~Visualizer() = default;
19 
20  bool
22  {
23  return visu.voxel.isOccupied();
24  }
25 
26  void
28  {
29  ARMARX_CHECK(visu.voxel.isOccupied());
30 
31  const Label label = visu.voxel.getLabel();
32 
33  const pcl::RGB rgb =
34  pcl::GlasbeyLUT::at(static_cast<unsigned int>(label) % pcl::GlasbeyLUT::size());
35 
36  const armarx::DrawColor color = drawer().toDrawColor(rgb, alpha, true);
37 
38  drawer().drawBox({getVoxelLayer(), visu.name + "_" + std::to_string(label)},
39  visu.pos,
40  visu.ori,
41  visu.extents,
42  color);
43  }
44 
45  float
47  {
48  return alpha;
49  }
50 
51  void
53  {
56 
57  this->alpha = value;
58  }
59 
60 
61 } // namespace visionx::voxelgrid::LabelOccupancy
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:151
visionx::voxelgrid::LabelOccupancy::Visualizer::setAlpha
void setAlpha(float value)
Set the alpha. Must be in [0, 1].
Definition: Visualizer.cpp:52
visionx::voxelgrid::Visualizer::VoxelVisuData
Information about a voxel about to-be-drawn.
Definition: Visualizer.hpp:97
visionx::voxelgrid::LabelOccupancy::Visualizer::getAlpha
float getAlpha() const
Get the alpha.
Definition: Visualizer.cpp:46
visionx::voxelgrid::LabelOccupancy::Visualizer::~Visualizer
virtual ~Visualizer() override
Virtual destructor.
visionx::voxelgrid::Visualizer::VoxelVisuData::pos
const Eigen::Vector3f & pos
The voxel.
Definition: Visualizer.hpp:105
visionx::voxelgrid::Visualizer< Voxel >::drawer
armarx::DebugDrawerTopic & drawer()
Get the debug drawer.
Definition: Visualizer.hpp:124
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:861
Visualizer.h
visionx::voxelgrid::Visualizer::VoxelVisuData::ori
const Eigen::Quaternionf & ori
The voxel's position.
Definition: Visualizer.hpp:106
visionx::voxelgrid::LabelOccupancy
Definition: Visualizer.cpp:8
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:6
visionx::voxelgrid::LabelOccupancy::Visualizer::Visualizer
Visualizer()
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
visionx::voxelgrid::Visualizer< Voxel >::getVoxelLayer
std::string getVoxelLayer() const
Get the layer name.
Definition: Visualizer.hpp:137
visionx::voxelgrid::Visualizer::VoxelVisuData::voxel
const VoxelT & voxel
The voxel's index.
Definition: Visualizer.hpp:103
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:207
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:41
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:107
visionx::voxelgrid::LabelOccupancy::Visualizer
Visualizer for label occupancy voxel grids.
Definition: Visualizer.h:15
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:37
visionx::voxelgrid::LabelOccupancy::Voxel
A voxel storing whether it is occupied or free and the object label it is occupied by.
Definition: VoxelGrid.h:22
visionx::voxelgrid::Visualizer::VoxelVisuData::name
const std::string & name
The voxel grid.
Definition: Visualizer.hpp:100