#pragma once /** * @file measure.h * @brief B-Rep 测量工具 * * 提供 B-Rep 实体的几何属性测量函数: * - 体积(散度定理) * - 表面积(三角剖分求和) * - 质心 * - 两实体间最小距离 * * @ingroup brep */ #include "vde/brep/brep.h" #include "vde/core/point.h" namespace vde::brep { /** * @brief 计算两个 B-Rep 实体间的最小距离 * * 通过将两个实体 tessellate 为三角网格, * 计算所有三角形对之间的最小距离。 * * @param a 第一个 B-Rep 实体 * @param b 第二个 B-Rep 实体 * @return 最小距离(≥ 0)。若两实体相交则返回 0。 */ [[nodiscard]] double distance(const BrepModel& a, const BrepModel& b); /** * @brief 计算 B-Rep 实体的表面积 * * 将所有面 tessellate 为三角形,求和三角形面积。 * * @param body B-Rep 实体 * @return 表面积(平方单位) */ [[nodiscard]] double surface_area(const BrepModel& body); /** * @brief 计算封闭 B-Rep 实体的体积 * * 使用散度定理(divergence theorem): * * V = (1/3) Σ (面心 · 面法向量 * 三角形面积) * * 对 tessellated 网格的所有三角形求和。 * * @param body 封闭 B-Rep 实体 * @return 体积(立方单位) * * @pre body 应为封闭实体(水密) */ [[nodiscard]] double volume(const BrepModel& body); /** * @brief 计算 B-Rep 实体的质心 * * 使用 tessellated 网格计算面积加权质心。 * * @param body B-Rep 实体 * @return 质心坐标 */ [[nodiscard]] core::Point3D centroid(const BrepModel& body); } // namespace vde::brep