feat(brep): face-face closest point, normal and penetration query (VDE-1356)

This commit is contained in:
hm
2026-11-15 10:32:24 +08:00
parent 5b1d73a728
commit e13487edfb
3 changed files with 434 additions and 0 deletions
+43
View File
@@ -18,6 +18,7 @@
#include "vde/core/point.h"
#include <Eigen/Dense>
#include <algorithm>
#include <cstdint>
#include <string>
#include <vector>
@@ -265,6 +266,48 @@ struct FaceMeasure {
*/
[[nodiscard]] double clearance(const BrepModel& a, const BrepModel& b);
// ── Face-face query (VDE-1356) ──
enum class ClosestFeature { Unknown, Face, Edge, Vertex };
struct FaceFaceQueryOptions {
double max_distance = 1.0; ///< mm;超过直接返回 valid=false
double mesh_deflection = 0.05; ///< 曲面三角化弦高
bool compute_penetration = true;
};
struct FaceFaceResult {
bool valid = false;
double distance = 0.0;
bool intersecting = false;
double penetration = 0.0;
core::Point3D point_a{0, 0, 0};
core::Point3D point_b{0, 0, 0};
core::Vector3D normal{0, 0, 0};
ClosestFeature feature_a = ClosestFeature::Unknown;
ClosestFeature feature_b = ClosestFeature::Unknown;
int face_a = -1;
int face_b = -1;
std::uint64_t face_a_id = 0; ///< 预留给 VDE-1354 持久拓扑 ID
std::uint64_t face_b_id = 0;
std::string diagnostic;
};
[[nodiscard]] FaceFaceResult face_face_query(
const BrepModel& a, int face_a, const BrepModel& b, int face_b,
const FaceFaceQueryOptions& opts = {});
struct FacePairCandidate {
int face_a = -1;
int face_b = -1;
double lower_bound = 0.0;
};
/// 返回 AABB 下界 <= max_distance 的候选面对(确定性顺序)。
[[nodiscard]] std::vector<FacePairCandidate> face_face_candidates(
const BrepModel& a, const BrepModel& b, double max_distance,
const FaceFaceQueryOptions& opts = {});
// ── BOM ──
/**