2026-07-13 18:56:01 +08:00
|
|
|
#ifndef CLOUD_VIEW_3D_TYPES_H
|
|
|
|
|
#define CLOUD_VIEW_3D_TYPES_H
|
|
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
struct Point3D
|
|
|
|
|
{
|
2026-08-18 12:26:28 +08:00
|
|
|
float x, y, z; // millimetres
|
2026-07-13 18:56:01 +08:00
|
|
|
Point3D() : x(0), y(0), z(0) {}
|
|
|
|
|
Point3D(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Point3DRGB
|
|
|
|
|
{
|
2026-08-18 12:26:28 +08:00
|
|
|
float x, y, z; // millimetres
|
2026-07-13 18:56:01 +08:00
|
|
|
uint8_t r, g, b;
|
|
|
|
|
float pointSize;
|
|
|
|
|
|
|
|
|
|
Point3DRGB() : x(0), y(0), z(0), r(255), g(255), b(255), pointSize(0) {}
|
|
|
|
|
Point3DRGB(float _x,
|
|
|
|
|
float _y,
|
|
|
|
|
float _z,
|
|
|
|
|
uint8_t _r = 255,
|
|
|
|
|
uint8_t _g = 255,
|
|
|
|
|
uint8_t _b = 255,
|
|
|
|
|
float _ps = 0)
|
|
|
|
|
: x(_x), y(_y), z(_z), r(_r), g(_g), b(_b), pointSize(_ps) {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<typename PointT>
|
|
|
|
|
class SimplePointCloud
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
std::vector<PointT> points;
|
|
|
|
|
std::vector<int> lineIndices;
|
2026-08-31 14:05:38 +08:00
|
|
|
// Each point's original position within its scan line (-1 when unknown).
|
|
|
|
|
std::vector<int> pointInLineIndices;
|
2026-07-13 18:56:01 +08:00
|
|
|
|
2026-08-31 14:05:38 +08:00
|
|
|
void clear()
|
|
|
|
|
{
|
|
|
|
|
points.clear();
|
|
|
|
|
lineIndices.clear();
|
|
|
|
|
pointInLineIndices.clear();
|
|
|
|
|
}
|
2026-07-13 18:56:01 +08:00
|
|
|
size_t size() const { return points.size(); }
|
|
|
|
|
bool empty() const { return points.empty(); }
|
2026-08-31 14:05:38 +08:00
|
|
|
void reserve(size_t n)
|
|
|
|
|
{
|
|
|
|
|
points.reserve(n);
|
|
|
|
|
lineIndices.reserve(n);
|
|
|
|
|
pointInLineIndices.reserve(n);
|
|
|
|
|
}
|
|
|
|
|
void push_back(const PointT& pt)
|
|
|
|
|
{
|
|
|
|
|
points.push_back(pt);
|
|
|
|
|
pointInLineIndices.push_back(-1);
|
|
|
|
|
}
|
2026-07-13 18:56:01 +08:00
|
|
|
void push_back(const PointT& pt, int lineIdx)
|
|
|
|
|
{
|
|
|
|
|
points.push_back(pt);
|
|
|
|
|
lineIndices.push_back(lineIdx);
|
2026-08-31 14:05:38 +08:00
|
|
|
pointInLineIndices.push_back(-1);
|
|
|
|
|
}
|
|
|
|
|
void push_back(const PointT& pt, int lineIdx, int pointInLineIdx)
|
|
|
|
|
{
|
|
|
|
|
points.push_back(pt);
|
|
|
|
|
lineIndices.push_back(lineIdx);
|
|
|
|
|
pointInLineIndices.push_back(pointInLineIdx);
|
2026-07-13 18:56:01 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
using PointCloudXYZ = SimplePointCloud<Point3D>;
|
|
|
|
|
using PointCloudXYZRGB = SimplePointCloud<Point3DRGB>;
|
|
|
|
|
|
|
|
|
|
#endif // CLOUD_VIEW_3D_TYPES_H
|