Files
ViewDesignEngine/include/vde/brep/measure.h
T
茂之钳 1e196473bc
CI / Build & Test (push) Failing after 39s
CI / Release Build (push) Failing after 29s
Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled
feat(v4.3): BOM (bill of materials) — flat merged, name-sorted
- BomEntry struct: name, quantity, volume, total_volume
- generate_bom(): recursive assembly traversal, same-name merging
- 5 new tests, 26/26 passing
2026-07-25 07:14:27 +00:00

64 lines
1.7 KiB
C++

#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 <Eigen/Dense>
#include <string>
#include <vector>
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<BomEntry> generate_bom(const AssemblyNode& node);
} // namespace vde::brep