2026-10-10 19:02:17 +08:00
|
|
|
#ifndef POINT_CLOUD_XYZ_RANGE_H
|
|
|
|
|
#define POINT_CLOUD_XYZ_RANGE_H
|
|
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
#include <limits>
|
|
|
|
|
|
|
|
|
|
// XYZ 范围外点的处理方式。
|
|
|
|
|
//
|
|
|
|
|
// ReplaceWithZero 保留点在线内的原始槽位,并仅把三维坐标置为零;
|
|
|
|
|
// Remove 则删除范围外点并压缩扫描线。保留槽位对于按扫描线/网格
|
|
|
|
|
// 处理的调用方很重要,因此它也是启用范围过滤时的默认模式。
|
|
|
|
|
enum class PointCloudXYZRangeFilterMode
|
|
|
|
|
{
|
|
|
|
|
ReplaceWithZero = 0,
|
|
|
|
|
Remove = 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 兼容不需要区分 XYZ 范围限定名称的调用方。
|
|
|
|
|
using PointCloudRangeFilterMode = PointCloudXYZRangeFilterMode;
|
|
|
|
|
|
|
|
|
|
// 点云加载使用的可选轴对齐范围;默认关闭以保持原有读取行为。
|
|
|
|
|
struct PointCloudXYZRange
|
|
|
|
|
{
|
|
|
|
|
using FilterMode = PointCloudXYZRangeFilterMode;
|
|
|
|
|
|
|
|
|
|
bool enabled = false;
|
|
|
|
|
double minX = -std::numeric_limits<double>::infinity();
|
|
|
|
|
double maxX = std::numeric_limits<double>::infinity();
|
|
|
|
|
double minY = -std::numeric_limits<double>::infinity();
|
|
|
|
|
double maxY = std::numeric_limits<double>::infinity();
|
|
|
|
|
double minZ = -std::numeric_limits<double>::infinity();
|
|
|
|
|
double maxZ = std::numeric_limits<double>::infinity();
|
|
|
|
|
// Keep this after the legacy bounds so aggregate initialization remains compatible.
|
|
|
|
|
PointCloudXYZRangeFilterMode filterMode =
|
|
|
|
|
PointCloudXYZRangeFilterMode::ReplaceWithZero;
|
|
|
|
|
|
|
|
|
|
bool isValid() const
|
|
|
|
|
{
|
|
|
|
|
if (!enabled)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return !std::isnan(minX) && !std::isnan(maxX)
|
|
|
|
|
&& !std::isnan(minY) && !std::isnan(maxY)
|
|
|
|
|
&& !std::isnan(minZ) && !std::isnan(maxZ)
|
|
|
|
|
&& minX <= maxX && minY <= maxY && minZ <= maxZ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool contains(double x, double y, double z) const
|
|
|
|
|
{
|
|
|
|
|
if (!enabled)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (!isValid() || !std::isfinite(x) || !std::isfinite(y) || !std::isfinite(z))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return x >= minX && x <= maxX
|
|
|
|
|
&& y >= minY && y <= maxY
|
|
|
|
|
&& z >= minZ && z <= maxZ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isEnabled() const
|
|
|
|
|
{
|
|
|
|
|
return enabled && isValid();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
using PointCloudRange = PointCloudXYZRange;
|
|
|
|
|
|
|
|
|
|
#endif // POINT_CLOUD_XYZ_RANGE_H
|