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
21 Visualizer::isVisible(const Visualizer::VoxelVisuData& visu) const
22 {
23 return visu.voxel.isOccupied();
24 }
25
26 void
27 Visualizer::drawVoxel(const Visualizer::VoxelVisuData& visu)
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
The DebugDrawerTopic wraps a DebugDrawerInterfacePrx and provides a more useful interface than the Ic...
static DrawColor toDrawColor(const ColorT &color, float alpha=1, bool byteToFloat=false)
Construct a DrawColor from the given color type.
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.
void setAlpha(float value)
Set the alpha. Must be in [0, 1].
virtual ~Visualizer() override
Virtual destructor.
virtual void drawVoxel(const VoxelVisuData &voxelVisu) override
virtual bool isVisible(const VoxelVisuData &voxelVisu) const override
Indicate whether a voxel shall be drawn.
A voxel storing whether it is occupied or free and the object label it is occupied by.
Definition VoxelGrid.h:23
armarx::DebugDrawerTopic & drawer()
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#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...
uint32_t Label
Type of an object label.
Definition types.h:6