算法更新: delivery v1.2.1、平整度v1.5、测距v2.2、整车配准v1.3 适配器: vehicle-registration 新增、各算法 manifest 和 adapter 更新 后端: taskCadFiles/source 字段迁移、derivedPointClouds 注册、取消任务联动 前端: ElapsedTime 时长显示、两步算法流程、canRun 逻辑修复 文档: 新增5份算法性能分析报告
136 lines
4.8 KiB
Python
136 lines
4.8 KiB
Python
from __future__ import annotations
|
|
|
|
import shutil
|
|
from pathlib import Path
|
|
|
|
|
|
PACKAGING_DIR = Path(__file__).resolve().parent
|
|
PROJECT_ROOT = PACKAGING_DIR.parent
|
|
BUILD_DIR = PACKAGING_DIR / "build"
|
|
PACKAGE_DIR = BUILD_DIR / "geometry_measure"
|
|
|
|
SOURCE_FILES = [
|
|
"main.py",
|
|
"pipeline.py",
|
|
"io_handler.py",
|
|
"config_loader.py",
|
|
"cad_converter.py",
|
|
"registration.py",
|
|
"evaluation.py",
|
|
"visualization.py",
|
|
"config.yaml",
|
|
]
|
|
|
|
SOURCE_DIRS = [
|
|
"preprocessing",
|
|
]
|
|
|
|
ARCHIVE_FILES = [
|
|
"translate_align_pointcloud_to_cad.py",
|
|
]
|
|
|
|
IMPORT_REWRITES = {
|
|
"from pipeline import MeasurementPipeline": "from geometry_measure.pipeline import MeasurementPipeline",
|
|
"from cad_converter import CADConverter": "from geometry_measure.cad_converter import CADConverter",
|
|
"from config_loader import ConfigLoader": "from geometry_measure.config_loader import ConfigLoader",
|
|
"from evaluation import Evaluator": "from geometry_measure.evaluation import Evaluator",
|
|
"from io_handler import IOHandler": "from geometry_measure.io_handler import IOHandler",
|
|
"from preprocessing.curvature import CurvatureEstimator": (
|
|
"from geometry_measure.preprocessing.curvature import CurvatureEstimator"
|
|
),
|
|
"from preprocessing.filters import PreprocessingRunner": (
|
|
"from geometry_measure.preprocessing.filters import PreprocessingRunner"
|
|
),
|
|
"from preprocessing.noise import GaussianNoiseAdder": (
|
|
"from geometry_measure.preprocessing.noise import GaussianNoiseAdder"
|
|
),
|
|
"from preprocessing.plane import PlaneEstimator": "from geometry_measure.preprocessing.plane import PlaneEstimator",
|
|
"from preprocessing.plane import PlaneResult": "from geometry_measure.preprocessing.plane import PlaneResult",
|
|
"from registration import PointCloudRegistration": "from geometry_measure.registration import PointCloudRegistration",
|
|
"from visualization import Visualizer": "from geometry_measure.visualization import Visualizer",
|
|
}
|
|
|
|
PATH_REWRITES = {
|
|
"CAD/11.step": "datasets/CAD/11.step",
|
|
"Mesh/11.stl": "datasets/Mesh/11.stl",
|
|
"PointCloud/11.ply": "datasets/PointCloud/11.ply",
|
|
"Noise_PointCloud/11_noisy.ply": "datasets/Noise_PointCloud/11_noisy.ply",
|
|
}
|
|
|
|
|
|
def main() -> None:
|
|
rebuild_dir()
|
|
copy_packaging_metadata()
|
|
copy_sources()
|
|
write_package_markers()
|
|
rewrite_python_imports()
|
|
rewrite_default_paths()
|
|
print(f"Build package prepared at: {BUILD_DIR}")
|
|
print("Install with: pip install -e packaging/build")
|
|
|
|
|
|
def rebuild_dir() -> None:
|
|
if BUILD_DIR.exists():
|
|
shutil.rmtree(BUILD_DIR)
|
|
PACKAGE_DIR.mkdir(parents=True)
|
|
|
|
|
|
def copy_packaging_metadata() -> None:
|
|
shutil.copy2(PACKAGING_DIR / "pyproject.toml", BUILD_DIR / "pyproject.toml")
|
|
shutil.copy2(PACKAGING_DIR / "MANIFEST.in", BUILD_DIR / "MANIFEST.in")
|
|
shutil.copy2(PACKAGING_DIR / "README.md", BUILD_DIR / "README.md")
|
|
|
|
|
|
def copy_sources() -> None:
|
|
for relative in SOURCE_FILES:
|
|
src = PROJECT_ROOT / relative
|
|
if not src.exists():
|
|
raise FileNotFoundError(f"Missing source file: {src}")
|
|
shutil.copy2(src, PACKAGE_DIR / relative)
|
|
|
|
for relative in SOURCE_DIRS:
|
|
src = PROJECT_ROOT / relative
|
|
if not src.exists():
|
|
raise FileNotFoundError(f"Missing source directory: {src}")
|
|
shutil.copytree(src, PACKAGE_DIR / relative)
|
|
|
|
archive_dir = PACKAGE_DIR / "archive"
|
|
archive_dir.mkdir(parents=True, exist_ok=True)
|
|
for relative in ARCHIVE_FILES:
|
|
src = PROJECT_ROOT / "archive" / relative
|
|
if not src.exists():
|
|
raise FileNotFoundError(f"Missing archive file: {src}")
|
|
shutil.copy2(src, archive_dir / relative)
|
|
|
|
|
|
def write_package_markers() -> None:
|
|
(PACKAGE_DIR / "__init__.py").write_text(
|
|
'"""Industrial geometry measurement toolkit."""\n\n__version__ = "0.1.0"\n',
|
|
encoding="utf-8",
|
|
)
|
|
preprocessing_init = PACKAGE_DIR / "preprocessing" / "__init__.py"
|
|
preprocessing_init.write_text('"""Preprocessing tools for point-cloud workflows."""\n', encoding="utf-8")
|
|
archive_init = PACKAGE_DIR / "archive" / "__init__.py"
|
|
archive_init.write_text('"""Archived developer workflows exposed by the CLI."""\n', encoding="utf-8")
|
|
|
|
|
|
def rewrite_python_imports() -> None:
|
|
for path in PACKAGE_DIR.rglob("*.py"):
|
|
text = path.read_text(encoding="utf-8")
|
|
for old, new in IMPORT_REWRITES.items():
|
|
text = text.replace(old, new)
|
|
path.write_text(text, encoding="utf-8")
|
|
|
|
|
|
def rewrite_default_paths() -> None:
|
|
targets = [PACKAGE_DIR / "config.yaml", PACKAGE_DIR / "config_loader.py"]
|
|
for path in targets:
|
|
text = path.read_text(encoding="utf-8")
|
|
for old, new in PATH_REWRITES.items():
|
|
text = text.replace(old, new)
|
|
path.write_text(text, encoding="utf-8")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|