feat: initial commit - massive-cloud point cloud processing system

This commit is contained in:
2026-05-27 09:51:42 +00:00
commit 16811100d1
391 changed files with 78338 additions and 0 deletions

View File

@@ -0,0 +1,159 @@
"""coupler-panel 算法适配器 (v1.1)。
v1.1 变更:
- 入口从 compute_coupler_measurement → run_coupler_measurement_pipeline
- 新增 D_y_max_mm / D_z_max_mm 字段
- 支持可选 CAD STP 路径(cad_stp_path)和 ROI JSON(roi_json)
- PYTHONPATH 指向 delivery_v1.1/coupler_panel_release
"""
from __future__ import annotations
import os
import sys
import traceback
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent))
from _plugin_io import (
emit_progress,
ensure_ascii_ply,
first_pointcloud,
load_input,
write_error_result,
write_result,
)
def _status_for(value: float, tolerance: float | None) -> str:
if tolerance is None:
return "info"
if abs(value) <= tolerance:
return "pass"
if abs(value) <= tolerance * 1.5:
return "warning"
return "fail"
def main() -> int:
payload = load_input(sys.argv)
inputs = payload.get("inputs") or {}
config = inputs.get("config") or {}
out_dir = Path(payload["outDir"])
out_dir.mkdir(parents=True, exist_ok=True)
try:
emit_progress(0.05, "加载 coupler_panel v1.1 算法包")
from coupler_panel.pipeline import run_coupler_measurement_pipeline # type: ignore
pc_path = first_pointcloud(payload)
emit_progress(0.15, f"读取点云:{os.path.basename(pc_path)}")
# 若是二进制 PLY,先转成 ASCII PLY(算法内置 reader 不依赖 open3d)
pc_path = ensure_ascii_ply(pc_path, out_dir / "_ply_cache")
profile = str(config.get("profile") or "auto")
right_axis_sign = int(config.get("rightAxisSign") or 1)
# 可选 CAD STP 路径(前端传入 cadPath 时使用)
cad_stp_path = inputs.get("cadPath") or None
# 可选 ROI JSON 路径(前端传入 roiJson 时使用)
roi_json = inputs.get("roiJson") or None
emit_progress(0.25, "调用 run_coupler_measurement_pipeline")
def _on_progress(stage: str, fraction: float) -> None:
emit_progress(0.25 + min(1.0, max(0.0, fraction)) * 0.70, stage)
result = run_coupler_measurement_pipeline(
input_cloud=pc_path,
out_dir=str(out_dir),
profile=profile,
cad_stp_path=cad_stp_path,
roi_json=roi_json,
progress=_on_progress,
)
emit_progress(0.97, "整理结果")
# right_axis_sign 影响 theta_right_deg 的符号约定
theta_right = float(result.theta_right_deg) * right_axis_sign
theta_ref = float(result.theta_ref_deg)
dx_y = float(result.dx_y_max_mm)
dx_z = float(result.dx_z_max_mm)
D_y = float(result.D_y_max_mm)
D_z = float(result.D_z_max_mm)
measurements = [
{
"name": "偏转角 θ_right (右向)",
"value": theta_right,
"unit": "deg",
"tolerance": 0.5,
"status": _status_for(theta_right, 0.5),
},
{
"name": "偏转角 θ_ref (参考向)",
"value": theta_ref,
"unit": "deg",
"tolerance": 0.5,
"status": _status_for(theta_ref, 0.5),
},
{
"name": "最大 x 偏差 dx_y",
"value": dx_y,
"unit": "mm",
"tolerance": 1.0,
"status": _status_for(dx_y, 1.0),
},
{
"name": "最大 x 偏差 dx_z",
"value": dx_z,
"unit": "mm",
"tolerance": 1.0,
"status": _status_for(dx_z, 1.0),
},
{
"name": "面板 y 向最大偏差 D_y",
"value": D_y,
"unit": "mm",
"status": "info",
},
{
"name": "面板 z 向最大偏差 D_z",
"value": D_z,
"unit": "mm",
"status": "info",
},
]
payload_out = {
"schemaVersion": getattr(result, "schema_version", "1.1"),
"status": "completed",
"measurements": measurements,
"overlay3d": {"kind": "none"},
"extra": {
"algorithmVersion": getattr(result, "algorithm_version", None),
"qualityFlags": list(result.quality_flags or []),
"normal": list(result.normal) if result.normal else None,
"centerC": list(result.center_C) if result.center_C else None,
"report": result.report if isinstance(result.report, dict) else None,
},
}
write_result(out_dir, payload_out)
emit_progress(1.0, "完成")
return 0
except Exception as exc:
traceback.print_exc()
write_error_result(
out_dir,
f"coupler-panel 计算失败:{exc}",
extra={"traceback": traceback.format_exc()},
)
return 1
if __name__ == "__main__":
sys.exit(main())