72 lines
3.1 KiB
C++
72 lines
3.1 KiB
C++
#ifndef POINTCLOUDIMAGEUTILS_H
|
||
#define POINTCLOUDIMAGEUTILS_H
|
||
|
||
#include <QImage>
|
||
#include <QColor>
|
||
#include <vector>
|
||
#include <map>
|
||
|
||
#include "VZNL_Types.h"
|
||
#include "SG_baseDataType.h"
|
||
|
||
struct PointRenderData {
|
||
double x, y;
|
||
|
||
PointRenderData(double x_, double y_)
|
||
: x(x_), y(y_) {}
|
||
};
|
||
|
||
class PointCloudImageUtils
|
||
{
|
||
public:
|
||
// 点云转图像 - 使用std::vector格式的扫描线数据
|
||
static QImage GeneratePointCloudImage(const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
||
const std::vector<std::vector<SVzNL3DPoint>>& detectionResults,
|
||
int imageWidth, int imageHeight);
|
||
|
||
|
||
private:
|
||
|
||
// 快速计算点云范围
|
||
static bool CalculateRangeFast(const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
||
double& xMin, double& xMax,
|
||
double& yMin, double& yMax);
|
||
|
||
// 直接绘制点云到图像数据,避免QPainter开销
|
||
static void DrawPointCloudDirect(QImage& image,
|
||
const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
||
double xMin, double xMax, double yMin, double yMax,
|
||
int imageWidth, int imageHeight);
|
||
|
||
// 计算scan lines格式点云的范围 (原始版本)
|
||
static void CalculateScanLinesRange(const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
||
double& xMin, double& xMax,
|
||
double& yMin, double& yMax);
|
||
|
||
// 优化版本:同时计算范围和准备渲染数据
|
||
static void CalculateScanLinesRangeOptimized(const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
||
double& xMin, double& xMax,
|
||
double& yMin, double& yMax,
|
||
std::vector<PointRenderData>& renderData);
|
||
|
||
// 绘制LapWeld检测结果
|
||
static void DrawLapWeldResults(QPainter& painter,
|
||
const std::vector<std::vector<SVzNL3DPoint>>& weldResults,
|
||
double xMin, double xMax, double yMin, double yMax,
|
||
int imageWidth, int imageHeight);
|
||
|
||
// 绘制scan lines点云数据 (原始版本)
|
||
static void DrawScanLinesPointCloud(QPainter& painter,
|
||
const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
||
double xMin, double xMax, double yMin, double yMax,
|
||
int imageWidth, int imageHeight);
|
||
|
||
// 优化版本:批量绘制点云
|
||
static void DrawPointCloudOptimized(QPainter& painter,
|
||
const std::vector<PointRenderData>& renderData,
|
||
double xMin, double xMax, double yMin, double yMax,
|
||
int imageWidth, int imageHeight);
|
||
};
|
||
|
||
#endif // POINTCLOUDIMAGEUTILS_H
|