feat(v4.3): mass properties, clearance, assembly mass props
- MassProperties struct: volume, centroid, inertia tensor, gyration radii - mass_properties(): tetrahedral decomposition for inertia tensor - assembly_mass_properties(): recursive assembly traversal with parallel axis - clearance(): AABB-accelerated gap analysis - 11 new tests, 21/21 passing
This commit is contained in:
@@ -12,10 +12,25 @@
|
||||
* @ingroup brep
|
||||
*/
|
||||
#include "vde/brep/brep.h"
|
||||
#include "vde/brep/assembly.h"
|
||||
#include "vde/core/point.h"
|
||||
#include <Eigen/Dense>
|
||||
|
||||
namespace vde::brep {
|
||||
|
||||
/**
|
||||
* @brief 质量属性结果
|
||||
*
|
||||
* 包含体积、质心、惯性张量和回转半径。
|
||||
* 所有量基于单位密度 ρ=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}; ///< 回转半径 sqrt(I/m) 各轴
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 计算两个 B-Rep 实体间的最小距离
|
||||
*
|
||||
@@ -64,4 +79,27 @@ namespace vde::brep {
|
||||
*/
|
||||
[[nodiscard]] core::Point3D centroid(const BrepModel& body);
|
||||
|
||||
/**
|
||||
* @brief 单实体完整质量属性
|
||||
*
|
||||
* 绕质心的惯性张量(密度 ρ=1)。使用四面体分解。
|
||||
*/
|
||||
[[nodiscard]] MassProperties mass_properties(const BrepModel& body);
|
||||
|
||||
/**
|
||||
* @brief 装配体递归质量属性
|
||||
*
|
||||
* 遍历装配树,考虑每个零件的局部变换,合并所有质量属性。
|
||||
*/
|
||||
[[nodiscard]] MassProperties assembly_mass_properties(const AssemblyNode& node,
|
||||
const core::Transform3D& parent_tf = core::Transform3D::Identity());
|
||||
|
||||
/**
|
||||
* @brief 两实体间的最小间隙
|
||||
*
|
||||
* 比 distance() 更高效:先用 AABB 过滤,仅在接近时检测。
|
||||
* @return 最小间隙。若相交则返回 0。
|
||||
*/
|
||||
[[nodiscard]] double clearance(const BrepModel& a, const BrepModel& b);
|
||||
|
||||
} // namespace vde::brep
|
||||
|
||||
Reference in New Issue
Block a user