Given the 8 corner points, I want to reconstruct them and fill up the cube full of point cloud data. Using Point Cloud Library, how can I do that?
Asked
Active
Viewed 266 times
0
-
What do you mean by "reconstruct"? Do you want to mesh them and then fill the cube with random points? Could you explain yourself better? – Finfa811 May 11 '16 at 06:42
1 Answers
0
I have the following, it's lengthy and just constructs the surface of the cube, some tweaking and you'll get what you want :
struct Dimensions // min and max points of cube
{
float min_x, min_y, min_z, max_x, max_y, max_z;
}
PointCloudColoredPtr draw_box(Dimensions& dim, uint32_t rgb)
{
float step = 0.4;
PointCloudColoredPtr box(new PointCloudColored);
PointTColored point_min, point_max;
point_min.rgb = *reinterpret_cast<float*>(&rgb);
point_max.rgb = *reinterpret_cast<float*>(&rgb);
// add points according to X
point_min.x = dim.min_x;
point_max.x = dim.max_x;
float b1, b2;
for (b1 = dim.min_y; b1 < dim.max_y; b1 += step)
{
for (b2 = dim.min_z; b2 < dim.max_z; b2 += step)
{
point_min.y = b1; point_max.y = b1;
point_min.z = b2; point_max.z = b2;
box->points.push_back(point_min);
box->points.push_back(point_max);
}
}
// add points according to Y
point_min.y = dim.min_y;
point_max.y = dim.max_y;
for (b1 = dim.min_x; b1 < dim.max_x; b1 += step)
{
for (b2 = dim.min_z; b2 < dim.max_z; b2 += step)
{
point_min.x = b1; point_max.x = b1;
point_min.z = b2; point_max.z = b2;
box->points.push_back(point_min);
box->points.push_back(point_max);
}
}
// add points according to Z
point_min.z = dim.min_z;
point_max.z = dim.max_z;
for (b1 = dim.min_x; b1 < dim.max_x; b1 += step)
{
for (b2 = dim.min_y; b2 < dim.max_y; b2 += step)
{
point_min.x = b1; point_max.x = b1;
point_min.y = b2; point_max.y = b2;
box->points.push_back(point_min);
box->points.push_back(point_max);
}
}
return box;
}

Vtik
- 3,073
- 2
- 23
- 38