fix(brep-heal): k=10 pinch vertex fan-split surgery + entry-front Step 0 (VDE-1193 9.11.58)
This commit is contained in:
@@ -1193,6 +1193,7 @@ public:
|
||||
friend StepResult step_stitch(BrepModel&, double);
|
||||
friend int remove_zero_width_slits(BrepModel&, double);
|
||||
friend int heal_coincident_twin_walls(BrepModel&, double);
|
||||
friend int heal_split_pinch_vertices(BrepModel&, double);
|
||||
friend StepResult step_simplify(BrepModel&, double);
|
||||
friend StepResult step_regularize(BrepModel&, double);
|
||||
friend StepResult step_orient(BrepModel&);
|
||||
|
||||
@@ -60,6 +60,24 @@ int heal_gaps(BrepModel& body, double tolerance = 1e-6);
|
||||
*/
|
||||
int heal_slivers(BrepModel& body);
|
||||
|
||||
/**
|
||||
* @brief 重合双棱(pinch / validate kind=10)拓扑手术:顶点扇区拆分
|
||||
*
|
||||
* 判据与 brep_validate.cpp 的 k10 检测同键:同一对顶点上存在 ≥2 条几何重合
|
||||
* 的边(曲线参数中点 1µm 桶指纹相同;无曲线时取端点弦中点),且这些边的邻接
|
||||
* 相异面并集 > 2 —— ≥3 片曲面沿同一空间曲线相触/自触、顶点 link 非单环。
|
||||
* 这类缺陷不能靠 stitch 合并(合并后即 ≥3 面共边的真非流形),只能"拆分为
|
||||
* 独立实体":把缺陷顶点的关联面按"绕该顶点经关联边相连"划成扇区,保留一个
|
||||
* 扇区在原顶点,其余扇区各复制一个**同坐标**新顶点并改指其关联边端点。
|
||||
* 几何完全不变(体积/面积/网格/导出不受影响),水密性、非流形计数、
|
||||
* untrimmed 计数均不变,只令顶点 link 回到单环并消散重合边组。
|
||||
*
|
||||
* @param body 待修复的 B-Rep 模型(原地修改)
|
||||
* @param tolerance 预留(当前判据为 1µm 桶,与 validate 口径一致)
|
||||
* @return 改指的边端点数(0 = 无缺陷或无可拆分处,模型未改动)
|
||||
*/
|
||||
int heal_split_pinch_vertices(BrepModel& body, double tolerance = 1e-6);
|
||||
|
||||
/**
|
||||
* @brief 统一面方向(全部向外),用欧拉示性数验证
|
||||
*
|
||||
|
||||
+212
-1
@@ -7,6 +7,7 @@
|
||||
#include "vde/brep/advanced_healing.h"
|
||||
#include "vde/mesh/mesh_repair.h"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
@@ -1384,6 +1385,164 @@ int heal_coincident_twin_walls(BrepModel& body, double tolerance) {
|
||||
return total;
|
||||
}
|
||||
|
||||
/// ═══ 重合双棱(pinch, validate kind=10)拓扑手术(VDE-1193 §9.11.58)═══
|
||||
///
|
||||
/// 判据与 brep_validate.cpp 的 k10 检测**同键**(改动须同步):同一对顶点
|
||||
/// (min/max(v_start,v_end)) 上存在 ≥2 条几何重合的边 —— 曲线参数中点 1µm 桶指纹
|
||||
/// 相同(无曲线时取端点弦中点;引擎口径 = curve->evaluate(0.5*(dom.first+dom.second)),
|
||||
/// 与 step_import §9.10 几何二级去重同键)—— 且这些边的**邻接相异面并集 > 2**。
|
||||
/// 含义:≥3 片曲面沿同一空间曲线"相触/自触",顶点 link 不是单一环,实体在该处
|
||||
/// 分支退化。与 non_manifold_edges 互为对偶:把这两条边并为一条即得"≥3 面共边"
|
||||
/// (更差的非流形),故 stitch 的合并口径在此被显式守卫挡住、必须做**拆分**。
|
||||
///
|
||||
/// 修复语义 = validate 提示的"拆分为独立实体":**顶点扇区拆分**(与
|
||||
/// mesh_repair.cpp 拆非流形顶点的同构做法,此处提升到 B-Rep 层)。对每个缺陷
|
||||
/// 顶点 v:
|
||||
/// 1. 取全部关联边(edge.v_start/v_end == v)与其邻接相异面;
|
||||
/// 2. 这些面按"绕 v 经同一条关联边相连"划成扇区(fan,并查集);
|
||||
/// 3. 扇区 ≥2 时保留一个(含最小面索引者,确定性),其余扇区各复制一个
|
||||
/// **同坐标**新顶点,并把"邻接面集完全落在该扇区"的关联边端点改指新顶点。
|
||||
/// 几何完全不变(新顶点坐标与原点逐位相同 ⇒ 体积/面积/网格/导出几何不受影响),
|
||||
/// 拓扑上顶点 link 由多环回到单环、重合边组因端点索引分化而消散 ⇒ k10 消除;
|
||||
/// 每条边仍挂原来那 2 个相异面 ⇒ 水密性、非流形计数、untrimmed 计数均不变。
|
||||
///
|
||||
/// 保守边界(不做任何不确定的事):
|
||||
/// · 扇区只有 1 个(顶点 link 已连通)⇒ 不动该顶点;
|
||||
/// · 关联边邻接面跨越多个扇区(真非流形边 ≥3 面)⇒ 该边不改指,保持原状。
|
||||
///
|
||||
/// @return 改指的边端点数(0 = 无缺陷或无可拆分处,模型未改动)。
|
||||
int heal_split_pinch_vertices(BrepModel& body, double /*tolerance*/) {
|
||||
const int F = static_cast<int>(body.faces_.size());
|
||||
const int E = static_cast<int>(body.edges_.size());
|
||||
if (F == 0 || E == 0) return 0;
|
||||
|
||||
// 边 → 邻接相异面(与 validate 同口径:周期面 seam 边被同一面正反引用两次只计一次)
|
||||
std::vector<std::vector<int>> edge_faces(static_cast<size_t>(E));
|
||||
for (int fi = 0; fi < F; ++fi) {
|
||||
std::vector<int> es = body.face_edges(fi);
|
||||
std::sort(es.begin(), es.end());
|
||||
es.erase(std::unique(es.begin(), es.end()), es.end());
|
||||
for (int ei : es)
|
||||
if (ei >= 0 && ei < E) edge_faces[static_cast<size_t>(ei)].push_back(fi);
|
||||
}
|
||||
|
||||
// 重合边分组(键 = 顶点对 + 参数中点 1µm 桶)
|
||||
auto bkt = [](double v) -> long long { return static_cast<long long>(std::llround(v * 1e6)); };
|
||||
std::map<std::array<long long, 5>, std::vector<int>> groups;
|
||||
for (int ei = 0; ei < E; ++ei) {
|
||||
const auto& e = body.edges_[static_cast<size_t>(ei)];
|
||||
if (e.v_start == e.v_end) continue; // 闭合边(整圆/整环)不参与
|
||||
if (edge_faces[static_cast<size_t>(ei)].empty()) continue;
|
||||
Point3D mid;
|
||||
if (e.curve) {
|
||||
const auto dom = e.curve->domain();
|
||||
mid = e.curve->evaluate(0.5 * (dom.first + dom.second));
|
||||
} else {
|
||||
const Point3D& a = body.vertices_[static_cast<size_t>(e.v_start)].point;
|
||||
const Point3D& b = body.vertices_[static_cast<size_t>(e.v_end)].point;
|
||||
mid = Point3D(0.5 * (a.x() + b.x()), 0.5 * (a.y() + b.y()),
|
||||
0.5 * (a.z() + b.z()));
|
||||
}
|
||||
const int lo = std::min(e.v_start, e.v_end);
|
||||
const int hi = std::max(e.v_start, e.v_end);
|
||||
groups[{static_cast<long long>(lo), static_cast<long long>(hi), bkt(mid.x()),
|
||||
bkt(mid.y()), bkt(mid.z())}]
|
||||
.push_back(ei);
|
||||
}
|
||||
|
||||
// 缺陷顶点集合(只处理"面并集 > 2"的组,与 validate 的 k10 口径一致)
|
||||
std::set<int> defect_verts;
|
||||
for (const auto& kv : groups) {
|
||||
if (kv.second.size() < 2) continue;
|
||||
std::set<int> uni;
|
||||
for (int ei : kv.second)
|
||||
for (int f : edge_faces[static_cast<size_t>(ei)]) uni.insert(f);
|
||||
if (uni.size() <= 2) continue; // 合并后仍是合法 2 面边
|
||||
defect_verts.insert(static_cast<int>(kv.first[0]));
|
||||
defect_verts.insert(static_cast<int>(kv.first[1]));
|
||||
}
|
||||
if (defect_verts.empty()) return 0;
|
||||
|
||||
const bool dbg = std::getenv("VDE_PINCH_DEBUG") != nullptr;
|
||||
int changed = 0;
|
||||
for (int v : defect_verts) { // std::set 升序 ⇒ 与容器遍历顺序无关的确定性
|
||||
std::vector<int> inc;
|
||||
for (int ei = 0; ei < E; ++ei) {
|
||||
const auto& e = body.edges_[static_cast<size_t>(ei)];
|
||||
if (e.v_start == v || e.v_end == v) inc.push_back(ei);
|
||||
}
|
||||
if (inc.empty()) continue;
|
||||
|
||||
// 关联面 + 扇区划分(并查集:同一条关联边的两个邻接面相连)
|
||||
std::vector<int> faces;
|
||||
std::map<int, int> fidx;
|
||||
for (int ei : inc)
|
||||
for (int f : edge_faces[static_cast<size_t>(ei)])
|
||||
if (!fidx.count(f)) { fidx[f] = static_cast<int>(faces.size()); faces.push_back(f); }
|
||||
if (faces.size() < 3) continue; // 面并集 >2 才可能构成 pinch
|
||||
std::vector<int> uf(faces.size());
|
||||
for (size_t k = 0; k < uf.size(); ++k) uf[k] = static_cast<int>(k);
|
||||
auto find = [&](int x) -> int {
|
||||
while (uf[static_cast<size_t>(x)] != x) {
|
||||
uf[static_cast<size_t>(x)] = uf[static_cast<size_t>(uf[static_cast<size_t>(x)])];
|
||||
x = uf[static_cast<size_t>(x)];
|
||||
}
|
||||
return x;
|
||||
};
|
||||
for (int ei : inc) {
|
||||
const auto& fs = edge_faces[static_cast<size_t>(ei)];
|
||||
for (size_t a = 1; a < fs.size(); ++a) {
|
||||
int ra = find(fidx[fs[0]]), rb = find(fidx[fs[a]]);
|
||||
if (ra != rb) uf[static_cast<size_t>(ra)] = rb;
|
||||
}
|
||||
}
|
||||
std::map<int, std::set<int>> fan_faces; // 扇区根 → 该扇区面集
|
||||
for (size_t k = 0; k < faces.size(); ++k)
|
||||
fan_faces[find(static_cast<int>(k))].insert(faces[k]);
|
||||
if (fan_faces.size() < 2) continue; // 顶点 link 已连通:非流形不在顶点处,不拆
|
||||
|
||||
// 保留扇区 = 含最小面索引者(确定性)
|
||||
int keep_root = -1, best = (1 << 30);
|
||||
for (const auto& kv : fan_faces) {
|
||||
const int mn = *kv.second.begin();
|
||||
if (mn < best) { best = mn; keep_root = kv.first; }
|
||||
}
|
||||
|
||||
const Point3D pv = body.vertices_[static_cast<size_t>(v)].point;
|
||||
const double tv = body.vertices_[static_cast<size_t>(v)].tolerance;
|
||||
for (const auto& kv : fan_faces) {
|
||||
if (kv.first == keep_root) continue;
|
||||
const std::set<int>& fan = kv.second;
|
||||
const int nv = body.add_vertex(pv); // 同坐标副本(几何不变)
|
||||
body.vertices_[static_cast<size_t>(nv)].tolerance = tv;
|
||||
for (int ei : inc) {
|
||||
const auto& fs = edge_faces[static_cast<size_t>(ei)];
|
||||
if (fs.empty()) continue; // 悬挂边:保持原状
|
||||
bool all_in = true;
|
||||
for (int f : fs)
|
||||
if (!fan.count(f)) { all_in = false; break; }
|
||||
if (!all_in) continue; // 跨扇区(≥3 面非流形边):保持原状
|
||||
if (body.edges_[static_cast<size_t>(ei)].v_start == v)
|
||||
body.edges_[static_cast<size_t>(ei)].v_start = nv;
|
||||
else if (body.edges_[static_cast<size_t>(ei)].v_end == v)
|
||||
body.edges_[static_cast<size_t>(ei)].v_end = nv;
|
||||
++changed;
|
||||
}
|
||||
}
|
||||
if (dbg)
|
||||
std::fprintf(stderr,
|
||||
"[pinch] vertex %d: fans=%zu -> split (%zu kept)\n", v,
|
||||
fan_faces.size(), fan_faces.size() - 1);
|
||||
}
|
||||
|
||||
if (changed > 0) {
|
||||
// 端点索引已变:作废 add_edge_unique 的惰性 (顶点对 → 边) 索引缓存
|
||||
// (其重建条件只看边缘数量,本次改动不改数量 ⇒ 必须显式置脏)
|
||||
body.edge_index_size_ = static_cast<size_t>(-1);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
// ═══════ Step 1: Stitch(缝合) ═══════
|
||||
|
||||
StepResult step_stitch(BrepModel& body, double tolerance) {
|
||||
@@ -2206,6 +2365,27 @@ AutoHealReport auto_heal_pipeline(BrepModel& body, double tolerance) {
|
||||
report.stitch.warnings.push_back("Stitch: 末次重合边合并异常终止");
|
||||
}
|
||||
|
||||
// Step 4.7: 重合双棱(k10)拓扑手术(VDE-1193 §9.11.58)。
|
||||
// 位置:所有变异步骤(Stitch/Simplify/Regularize/Orient/Fill + 两次收口合并)
|
||||
// 之后。上面两处 stitch 合并用"邻接面并集 ≤2 才合并"的守卫,并集 >2 的 pinch
|
||||
// 被显式保留(此前只能由 validate kind=10 报告、heal 拒绝处置 → 语料残留
|
||||
// 15 个 err 体中 10 个是它)。此处做 validate 提示的另一种处置——"拆分为
|
||||
// 独立实体":按顶点扇区复制同坐标顶点,几何零变化、水密性零变化,仅让顶点
|
||||
// link 回到单环、重合边组因端点索引分化而消散。放在最后是为了让前面所有
|
||||
// 步骤(含两次合并)先按原语义跑完,手术只处理它们的残留。
|
||||
try {
|
||||
HealStageTimer t("PinchSplit");
|
||||
int split = heal_split_pinch_vertices(body, tolerance);
|
||||
if (split > 0) {
|
||||
report.stitch.items_fixed += split;
|
||||
report.stitch.warnings.push_back(
|
||||
"Stitch: 重合双棱拓扑手术改指 " + std::to_string(split) +
|
||||
" 个边端点(顶点扇区拆分,几何不变;消 k10 重合双棱)");
|
||||
}
|
||||
} catch (...) {
|
||||
report.stitch.warnings.push_back("Stitch: 重合双棱拓扑手术异常终止");
|
||||
}
|
||||
|
||||
// Step 5: Check(验证)
|
||||
try {
|
||||
HealStageTimer t("Check");
|
||||
@@ -2250,6 +2430,25 @@ AutoHealReport automatic_heal(BrepModel& body, const AutoHealOptions& opts) {
|
||||
return r;
|
||||
}
|
||||
|
||||
// Step 0(VDE-1193 §9.11.58):重合双棱(k10)拓扑手术——**入口前置**。
|
||||
// 位置选择是关键:必须早于 `vraw` 与 `backup`,使二者都反映"已拆分"的体。
|
||||
// ① 若 raw 的唯一缺陷就是 k10,拆分后 `vraw.valid` 转为 true —— 守卫 1
|
||||
// (raw 有效而 heal 无效 ⇒ 回退)重新生效,保护更严(此前 raw 因 k10
|
||||
// 恒判 invalid,该守卫对该类体形同虚设)。
|
||||
// ② 若后续步骤触发任一回退(守卫 1-7),回退目标是**已拆分体**,
|
||||
// 本次修复不会被丢弃。实测正是该形态:agc HOUSING_FRONT(pinch 1 → 0,
|
||||
// err 1 → 0)、Factor_3D body233(pinch 2 → 0,err 1 → 0)、Projekt_1
|
||||
// body16/17(pinch 2 → 0,err 1 → 0)——它们 heal 后仍被守卫 2/7 回退到
|
||||
// "未拆分"的原始体,故此前 heal 对它们恒等于无操作。
|
||||
// 手术几何零变化(新顶点与原点逐位同坐标;体积/面积/网格/导出不变),
|
||||
// 只令顶点 link 回到单环,故前置无风险。流水线末尾还有 Step 4.7 处理
|
||||
// "流水线自身(stitch/合并)新造出来的"重合双棱,两者覆盖不同来源。
|
||||
int pre_split = 0;
|
||||
{
|
||||
HealStageTimer t("PinchSplit.pre");
|
||||
pre_split = heal_split_pinch_vertices(body, 1e-6);
|
||||
}
|
||||
|
||||
// 记录修复前的顶点/边/面数量
|
||||
size_t before_v = body.num_vertices();
|
||||
size_t before_e = body.num_edges();
|
||||
@@ -2276,7 +2475,11 @@ AutoHealReport automatic_heal(BrepModel& body, const AutoHealOptions& opts) {
|
||||
}
|
||||
|
||||
heal_report(HealStage::Backup, 6, "backup original body");
|
||||
BrepModel backup = body; // 取消时用于恢复入口状态
|
||||
// 取消时用于恢复入口状态。注意:入口前置的重合双棱手术(Step 0)发生在本行之前,
|
||||
// 故"入口状态"含该次**几何保持型**拓扑拆分(新顶点与原点逐位同坐标,体积/面积/
|
||||
// 网格/导出不变,面数不变)——取消路径不会把它撤掉,这是刻意的:拆分是修复的
|
||||
// 前置条件(供守卫回退时保留),不是需要回滚的"修复决策"。
|
||||
BrepModel backup = body;
|
||||
heal_report(HealStage::Backup, 9, "backup done");
|
||||
if (heal_cancelled()) { // 拷贝期间被取消:body 仍未改动
|
||||
AutoHealReport r;
|
||||
@@ -2296,6 +2499,14 @@ AutoHealReport automatic_heal(BrepModel& body, const AutoHealOptions& opts) {
|
||||
report = auto_heal_pipeline(body, tolerance);
|
||||
}
|
||||
|
||||
// 入口前置的重合双棱手术计入报告(与流水线内 Step 4.7 同口径累加)。
|
||||
if (pre_split > 0) {
|
||||
report.stitch.items_fixed += pre_split;
|
||||
report.stitch.warnings.push_back(
|
||||
"Stitch: 重合双棱拓扑手术(入口前置)改指 " + std::to_string(pre_split) +
|
||||
" 个边端点(顶点扇区拆分,几何不变;消 k10 重合双棱)");
|
||||
}
|
||||
|
||||
if (heal_cancelled()) {
|
||||
// 取消语义:body 恢复到入口状态,返回已执行阶段的报告并标记取消。
|
||||
body = std::move(backup);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "vde/brep/brep_validate.h"
|
||||
#include "vde/brep/tolerance.h"
|
||||
#include "vde/brep/advanced_healing.h"
|
||||
#include "vde/brep/brep_heal.h"
|
||||
#include "vde/curves/nurbs_surface.h"
|
||||
#include "vde/curves/nurbs_curve.h"
|
||||
|
||||
@@ -128,6 +129,39 @@ BrepModel make_sheet_with_mid_vertex() {
|
||||
return m;
|
||||
}
|
||||
|
||||
/// 重合双棱(pinch / validate kind=10)测试体:两个"双面薄片"沿同一对顶点
|
||||
/// (v0,v1) 相互贴合 —— e1/e3 同为直线 v0→v1(曲线参数中点相同)、e2/e4 同为
|
||||
/// 抛物线 v0→v1(参数中点相同)。每条边各挂 2 个相异面 ⇒ 水密性 1.0、无穿透,
|
||||
/// 唯一缺陷是两组"同一对顶点上几何重合的边、邻接面并集 4 > 2" —— 正是 VDE-1193
|
||||
/// §9.11.58 顶点扇区拆分手术要处理的 k10 形态("仅拓扑 pinched、几何完好")。
|
||||
BrepModel make_pinched_double_lune() {
|
||||
BrepModel m;
|
||||
int v0 = m.add_vertex(Point3D(0, 0, 0));
|
||||
int v1 = m.add_vertex(Point3D(1, 0, 0));
|
||||
// 直线:参数中点 evaluate(0.5) = (0.5, 0, 0)
|
||||
NurbsCurve c_line({Point3D(0,0,0), Point3D(1,0,0)}, {0,0,1,1}, {1,1}, 1);
|
||||
// 抛物线:参数中点 = 0.25·P0 + 0.5·P1 + 0.25·P2 = (0.5, 0, 0.5)
|
||||
NurbsCurve c_arc({Point3D(0,0,0), Point3D(0.5,0,1), Point3D(1,0,0)},
|
||||
{0,0,0,1,1,1}, {1,1,1}, 2);
|
||||
int e1 = m.add_edge(v0, v1, c_line);
|
||||
int e2 = m.add_edge(v0, v1, c_arc);
|
||||
int e3 = m.add_edge(v0, v1, c_line); // 与 e1 几何重合(同曲线 → 同参数中点)
|
||||
int e4 = m.add_edge(v0, v1, c_arc); // 与 e2 几何重合
|
||||
auto add_lune = [&](int ea, int eb) {
|
||||
int sid = m.add_surface(plane_surf(Point3D(0,0,0), Point3D(1,0,0),
|
||||
Point3D(1,1,0), Point3D(0,1,0)));
|
||||
int lp = m.add_loop({ea, eb}, true);
|
||||
return m.add_face(sid, {lp});
|
||||
};
|
||||
int f0 = add_lune(e1, e2);
|
||||
int f1 = add_lune(e1, e2); // 第一片"双面薄片":e1/e2 各挂 f0,f1
|
||||
int f2 = add_lune(e3, e4);
|
||||
int f3 = add_lune(e3, e4); // 第二片:e3/e4 各挂 f2,f3
|
||||
int sh = m.add_shell({f0, f1, f2, f3}, true);
|
||||
m.add_body({sh}, "pinched_double_lune");
|
||||
return m;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// ═══════════════════════════════════════════════════════════
|
||||
@@ -473,3 +507,46 @@ TEST(AdvancedHealingTest, Cleanup_MicroGap_ClosesAndStaysWatertight) {
|
||||
auto vt = watertight_verification(open);
|
||||
EXPECT_TRUE(vt.is_watertight);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════
|
||||
// VDE-1193 §9.11.58:重合双棱(validate kind=10)顶点扇区拆分手术
|
||||
// ═══════════════════════════════════════════════════════════
|
||||
|
||||
TEST(AdvancedHealingTest, PinchSplit_CoincidentDoubleLune_Cleared) {
|
||||
auto m = make_pinched_double_lune();
|
||||
ValidationResult pre = validate(m);
|
||||
// 两组几何重合边(直线组 + 抛物线组),每组邻接面并集 4 > 2
|
||||
EXPECT_EQ(pre.coincident_pinch_edges, 2);
|
||||
EXPECT_EQ(pre.non_manifold_edges, 0u);
|
||||
EXPECT_DOUBLE_EQ(pre.watertightness, 1.0);
|
||||
const size_t nf = m.num_faces();
|
||||
const size_t ne = m.num_edges();
|
||||
const size_t nv = m.num_vertices();
|
||||
|
||||
const int changed = heal_split_pinch_vertices(m, 1e-6);
|
||||
EXPECT_GT(changed, 0);
|
||||
|
||||
ValidationResult post = validate(m);
|
||||
EXPECT_EQ(post.coincident_pinch_edges, 0); // k10 消除
|
||||
EXPECT_EQ(post.non_manifold_edges, 0u); // 未引入 ≥3 面共边
|
||||
EXPECT_EQ(post.untrimmed_faces, 0u);
|
||||
EXPECT_DOUBLE_EQ(post.watertightness, 1.0); // 每条边仍挂原来那 2 个面
|
||||
EXPECT_EQ(m.num_faces(), nf); // 面/边数不变(纯拓扑改指)
|
||||
EXPECT_EQ(m.num_edges(), ne);
|
||||
EXPECT_GT(m.num_vertices(), nv); // 顶点按扇区复制
|
||||
// 几何零变化:全部顶点仍落在原两个坐标上(逐位相同,非近似)
|
||||
for (size_t i = 0; i < m.num_vertices(); ++i) {
|
||||
const Point3D& p = m.vertex(static_cast<int>(i)).point;
|
||||
const bool same = (p - Point3D(0, 0, 0)).norm() < 1e-15 ||
|
||||
(p - Point3D(1, 0, 0)).norm() < 1e-15;
|
||||
EXPECT_TRUE(same);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(AdvancedHealingTest, AutoHealPipeline_PinchedBody_PinchCleared) {
|
||||
auto m = make_pinched_double_lune();
|
||||
auto_heal_pipeline(m, 1e-6);
|
||||
ValidationResult post = validate(m);
|
||||
EXPECT_EQ(post.coincident_pinch_edges, 0);
|
||||
EXPECT_EQ(post.non_manifold_edges, 0u);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user