#pragma once /** * @file measure.h * @brief B-Rep 测量工具 * * 提供 B-Rep 实体的几何属性测量函数: * - 体积(散度定理) * - 表面积(三角剖分求和) * - 质心 * - 两实体间最小距离 * - 质量属性(惯性张量、回转半径) * - 装配体质量属性 + BOM 物料清单 * * @ingroup brep */ #include "vde/brep/brep.h" #include "vde/brep/assembly.h" #include "vde/core/point.h" #include #include #include namespace vde::brep { /// 质量属性结果:体积、质心、惯性张量、回转半径(ρ=1) struct MassProperties { double volume = 0.0; core::Point3D centroid{0, 0, 0}; Eigen::Matrix3d inertia{Eigen::Matrix3d::Zero()}; core::Vector3D gyration_radii{0, 0, 0}; }; /// BOM 条目:零件名 + 数量 + 体积 struct BomEntry { std::string name; int quantity = 0; double volume = 0.0; double total_volume = 0.0; }; // ── Basic measurements ── [[nodiscard]] double distance(const BrepModel& a, const BrepModel& b); [[nodiscard]] double surface_area(const BrepModel& body); [[nodiscard]] double volume(const BrepModel& body); [[nodiscard]] core::Point3D centroid(const BrepModel& body); // ── Mass properties ── [[nodiscard]] MassProperties mass_properties(const BrepModel& body); [[nodiscard]] MassProperties assembly_mass_properties(const AssemblyNode& node, const core::Transform3D& parent_tf = core::Transform3D::Identity()); // ── Gap analysis ── [[nodiscard]] double clearance(const BrepModel& a, const BrepModel& b); // ── BOM ── /// 生成扁平合并的物料清单(按名称排序) [[nodiscard]] std::vector generate_bom(const AssemblyNode& node); // ── Wall thickness analysis ── /// 壁厚分析结果 struct WallThicknessResult { double min_thickness = 0.0; ///< 最小壁厚 double max_thickness = 0.0; ///< 最大壁厚 double avg_thickness = 0.0; ///< 平均壁厚 int thin_regions = 0; ///< 薄壁区域数(< thin_threshold) int thick_regions = 0; ///< 厚壁区域数(> thick_threshold) double thin_threshold = 1.0; ///< 薄壁判定阈值 double thick_threshold = 10.0; ///< 厚壁判定阈值 }; /// 壁厚分析:沿各面法向采样,射线检测对面距离 /// @param body B-Rep 实体 /// @param samples_per_face 每个面的采样点数(默认 5×5=25) /// @return 壁厚统计结果 [[nodiscard]] WallThicknessResult analyze_wall_thickness(const BrepModel& body, int samples_per_face = 5); } // namespace vde::brep