29 #include <pcl/common/colors.h>
31 #include <Inventor/SbColor.h>
32 #include <Inventor/SbVec3f.h>
33 #include <Inventor/nodes/SoCoordinate3.h>
34 #include <Inventor/nodes/SoDrawStyle.h>
35 #include <Inventor/nodes/SoMaterial.h>
36 #include <Inventor/nodes/SoMaterialBinding.h>
37 #include <Inventor/nodes/SoPointSet.h>
42 template <
class ColorT>
46 array[0] =
static_cast<float>(color.r) / 255.0f;
47 array[1] =
static_cast<float>(color.g) / 255.0f;
48 array[2] =
static_cast<float>(color.b) / 255.0f;
52 visionx::PointContentType originalType,
55 originalCloud(originalCloud), originalType(originalType)
58 SoMaterial* materialInfo =
new SoMaterial();
59 std::vector<SbColor> colorData;
60 colorData.reserve(originalCloud->points.size());
62 SoCoordinate3* coordinates =
new SoCoordinate3();
63 std::vector<SbVec3f> pointData;
64 pointData.reserve(originalCloud->points.size());
65 for (
const PointT& p : originalCloud->points)
69 SbColor colorContainer;
74 const pcl::RGB color = pcl::GlasbeyLUT::at(p.label % pcl::GlasbeyLUT::size());
82 colorContainer.setValue(colorArray);
83 colorData.push_back(colorContainer);
85 SbVec3f pointContainer;
86 pointContainer[0] = p.x;
87 pointContainer[1] = p.y;
88 pointContainer[2] = p.z;
90 pointData.push_back(pointContainer);
94 materialInfo->diffuseColor.setValues(0, colorData.size(), colorData.data());
95 this->addChild(materialInfo);
98 SoMaterialBinding* binding =
new SoMaterialBinding();
99 binding->value = SoMaterialBinding::PER_PART;
100 this->addChild(binding);
102 coordinates->point.setValues(0, pointData.size(), pointData.data());
103 this->addChild(coordinates);
106 SoDrawStyle* sopointSize =
new SoDrawStyle();
107 sopointSize->pointSize = pointSize;
108 this->addChild(sopointSize);
111 SoPointSet* pointSet =
new SoPointSet();
112 this->addChild(pointSet);
120 return this->originalCloud;
123 visionx::PointContentType
126 return this->originalType;