29 #include <Inventor/nodes/SoMaterial.h>
30 #include <Inventor/nodes/SoMaterialBinding.h>
31 #include <Inventor/nodes/SoCoordinate3.h>
32 #include <Inventor/nodes/SoDrawStyle.h>
33 #include <Inventor/nodes/SoPointSet.h>
34 #include <Inventor/SbColor.h>
35 #include <Inventor/SbVec3f.h>
37 #include <pcl/common/colors.h>
43 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),
56 originalType(originalType)
59 SoMaterial* materialInfo =
new SoMaterial();
60 std::vector<SbColor> colorData;
61 colorData.reserve(originalCloud->points.size());
63 SoCoordinate3* coordinates =
new SoCoordinate3();
64 std::vector<SbVec3f> pointData;
65 pointData.reserve(originalCloud->points.size());
66 for (
const PointT& p : originalCloud->points)
70 SbColor colorContainer;
75 const pcl::RGB color = pcl::GlasbeyLUT::at(p.label % pcl::GlasbeyLUT::size());
83 colorContainer.setValue(colorArray);
84 colorData.push_back(colorContainer);
86 SbVec3f pointContainer;
87 pointContainer[0] = p.x;
88 pointContainer[1] = p.y;
89 pointContainer[2] = p.z;
91 pointData.push_back(pointContainer);
95 materialInfo->diffuseColor.setValues(0, colorData.size(), colorData.data());
96 this->addChild(materialInfo);
99 SoMaterialBinding* binding =
new SoMaterialBinding();
100 binding->value = SoMaterialBinding::PER_PART;
101 this->addChild(binding);
103 coordinates->point.setValues(0, pointData.size(), pointData.data());
104 this->addChild(coordinates);
107 SoDrawStyle* sopointSize =
new SoDrawStyle();
108 sopointSize->pointSize = pointSize;
109 this->addChild(sopointSize);
112 SoPointSet* pointSet =
new SoPointSet();
113 this->addChild(pointSet);
120 return this->originalCloud;
125 return this->originalType;