/** * @file dbg_nm_edge.cpp * @brief 非流形边(≥3 面共边)结构归因工具(VDE-1193 §9.11 残余错误件归因) * * 背景:语料残余 err_bodies 绝大多数为 k=2「非流形边」。文件级扫描 * (build/sweep-heal914/step_nm_scan.py)证明这些 STEP 的 CLOSED_SHELL / * OPEN_SHELL 自身不含 ≥3 面共边(按面去重口径与逐引用口径都为 0)→ * 非流形边由导入器/修复流水线构造产生,需逐边看清结构再定修法。 * * 本工具输出每条 ≥3 面共边的: * - 环引用次数 occ(同一面在同一环里重复引用同一 ID 会推高 occ); * - 去重后的相异面数 nfac; * - 两端点坐标、边长; * - 每个关联面的 surface_id / 次数 / 度数与控制点规模 / 环规模 / * 该面在本边上出现次数 / 包围盒对角 / 平面法向。 * 判读: * - nfac<3 而 occ≥3 → 同一面重复引用(环内重复边,非真非流形); * - nfac≥3 且两面 surface_id 相同 / 面积与法向一致 → 同域双墙面; * - nfac≥3 且三面几何各异 → 真三面共边(壳内结构)。 * * 用法: dbg_nm_edge [--heal] [--diag] [--seams] [--dup] [--loops] [--stage ] [...] (ASCII 路径) * --heal 导入后先跑 automatic_heal(复现 sweep 的口径),可对比 raw/heal 结构 * --diag 额外跑 diagnose_body 打印错误 kind(0=壳内穿透 2=非流形 3=水密性 ...) * --seams 同时打印「周期面 seam 边」(同面正反引用两次,nfac==1 而 occ==2) * --loops 打印逐面环规模与「相异面数 <2 的边」端点:核对导入是否忠实保留 * 源环引用(源 CLOSED_SHELL 每边 2 面时应全为 2;缺口即导入丢环引用) * --edges 转储全部边的几何签名(端点字典序归一 + 曲线中点),与另一份 * 导入结果逐行比对即可定位往返丢失/新增的具体边 * --dup 打印「重合边对」诊断(VDE-1193 §9.11.21 归因用): * ①同顶点下标对的多条边(导出 1:1、reimport 会按邻接面并集 ≤2 合并的那类) * ②端点坐标在容差内重合的多条边(= step_stitch 的检测口径) * 两者都打印邻接面并集与曲线中点,用于判断为什么 heal 未合并而 reimport 合并。 * --stage 顺序施加修复阶段(默认 raw):raw | gaps(仅 heal_gaps) * | stitch(heal_gaps 后 step_stitch)| full(= automatic_heal) * | pipe(裸 auto_heal_pipeline,无回退守卫,用于区分"守卫回退"与 * "流水线本身未达成") * | chain(逐步复刻流水线,每步打印 F/E/V/open/nm,用于定位哪一步破坏体) * --face : 转储指定体的指定面的逐环边序列(边 id + 两端 * 顶点下标/坐标 + 是否有曲线),用于看清零宽缝隙/透镜面的环组织 * --only 只处理这些体下标(其余体跳过 heal 与转储):用于 * 单件 heal 极慢时把验证范围收敛到目标体(导入/诊断仍全件) */ #include "vde/brep/brep.h" #include "vde/brep/step_import.h" #include "vde/brep/brep_heal.h" #include "vde/brep/brep_validate.h" #include "vde/brep/advanced_healing.h" // GapFillReport(--stage chain 逐步复刻) #include #include #include #include #include #include #include using vde::brep::BrepModel; using vde::core::Point3D; using vde::core::Vector3D; namespace vde::brep { // brep_heal.cpp 内部阶段(未在头文件导出):仅调试工具按需声明 StepResult step_stitch(BrepModel& body, double tolerance); StepResult step_simplify(BrepModel& body, double tolerance); StepResult step_regularize(BrepModel& body, double tolerance); StepResult step_orient(BrepModel& body); GapFillReport gap_fill(BrepModel& body, double tolerance); AutoHealReport auto_heal_pipeline(BrepModel& body, double tolerance); } // namespace vde::brep /// 重合边对诊断(--dup):见文件头注释。 static void dump_dup_pairs(const BrepModel& b, size_t bi, double tol) { const int F = static_cast(b.num_faces()); const int E = static_cast(b.num_edges()); std::vector> faces(E); for (int fi = 0; fi < F; ++fi) for (int ei : b.face_edges(fi)) if (ei >= 0 && ei < E) faces[ei].insert(fi); std::printf(" [dup] body%zu F=%d E=%d V=%zu tol=%.3g\n", bi, F, E, b.num_vertices(), tol); // ① 同顶点下标对 { std::map, std::vector> g; for (int i = 0; i < E; ++i) { const auto& e = b.edge(i); g[{std::min(e.v_start, e.v_end), std::max(e.v_start, e.v_end)}].push_back(i); } for (const auto& kv : g) { if (kv.second.size() < 2) continue; std::set uni; for (int ei : kv.second) uni.insert(faces[ei].begin(), faces[ei].end()); std::printf(" [dup] SAME-INDEX v(%d,%d) nedges=%zu union=%zu\n", kv.first.first, kv.first.second, kv.second.size(), uni.size()); for (int ei : kv.second) { const auto& e = b.edge(ei); Point3D mid; if (e.curve) { const auto d = e.curve->domain(); mid = e.curve->evaluate(0.5 * (d.first + d.second)); } std::printf(" [dup] e%d (v%d->v%d) curve=%d mid=(%.9g,%.9g,%.9g) faces={", ei, e.v_start, e.v_end, e.curve ? 1 : 0, mid.x(), mid.y(), mid.z()); for (int f : faces[ei]) std::printf("%d,", f); std::printf("}\n"); } } } // ② 端点坐标重合(stitch 口径) { std::vector p0(E), p1(E); for (int i = 0; i < E; ++i) { const auto& e = b.edge(i); p0[i] = b.vertex(e.v_start).point; p1[i] = b.vertex(e.v_end).point; } for (int i = 0; i < E; ++i) { for (int j = i + 1; j < E; ++j) { const bool sd = (p0[i] - p0[j]).norm() < tol && (p1[i] - p1[j]).norm() < tol; const bool od = (p0[i] - p1[j]).norm() < tol && (p1[i] - p0[j]).norm() < tol; if (!(sd || od)) continue; std::set uni(faces[i].begin(), faces[i].end()); uni.insert(faces[j].begin(), faces[j].end()); std::printf(" [dup] COORD-PAIR e%d(v%d->%d)/e%d(v%d->%d) %s union=%zu%s\n", i, b.edge(i).v_start, b.edge(i).v_end, j, b.edge(j).v_start, b.edge(j).v_end, sd ? "same_dir" : "opp_dir", uni.size(), uni.size() > 2 ? " (stitch 守卫: 跳过)" : " (stitch 守卫: 可合并)"); } } } } /// 逐面环结构转储(--face :):打印指定面的每个环的 /// 边序列及边的两端顶点/坐标/曲线,用于看清零宽缝隙/透镜面的真实环组织。 static void dump_faces(const BrepModel& b, size_t bi, const std::vector& fids) { const int F = static_cast(b.num_faces()); const int E = static_cast(b.num_edges()); std::printf(" [face] body%zu F=%d E=%d V=%zu\n", bi, F, E, b.num_vertices()); for (int fi : fids) { if (fi < 0 || fi >= F) continue; const auto& f = b.face(fi); const auto& ns = b.face_surface(fi); std::printf(" [face] f%d sid=%d rev=%d loops=%zu deg=%dx%d\n", fi, f.surface_id, f.reversed ? 1 : 0, f.loops.size(), ns.degree_u(), ns.degree_v()); for (int li : f.loops) { const auto& lp = b.loop_by_id(li); const int m = static_cast(lp.edges.size()); // 链式方向解算(与 heal_split_pinch_vertices::dirs_in_face 同口径): // 锚定首边两种朝向各试一次,逐边要求"起点 ≈ 前一边终点";末边终点 // 回到首边起点才算闭合。dir[k]=+1 表示沿 edge.v_start→v_end 遍历。 // chained=0 说明该环的边序**不**成链(环内自触/断链),此时 dir 全 0。 std::vector dir(static_cast(std::max(m, 0)), 0); bool chained = false; auto samep = [&](int va, int vb) { return (b.vertex(va).point - b.vertex(vb).point).norm() < 1e-6; }; for (int sign : {1, -1}) { if (m < 2) break; std::vector d(static_cast(m), 0); int prev_end = -1; bool ok = true; for (int k = 0; k < m; ++k) { const auto& e = b.edge(lp.edges[static_cast(k)]); int s = 0; if (k == 0) { s = (sign > 0) ? e.v_start : e.v_end; } else { s = samep(e.v_start, prev_end) ? e.v_start : (samep(e.v_end, prev_end) ? e.v_end : -1); if (s < 0) { ok = false; break; } } d[static_cast(k)] = (s == e.v_start) ? 1 : -1; prev_end = (d[static_cast(k)] == 1) ? e.v_end : e.v_start; } if (!ok) continue; const auto& e0 = b.edge(lp.edges[0]); const int start0 = (d[0] == 1) ? e0.v_start : e0.v_end; if (!samep(prev_end, start0)) continue; dir = d; chained = true; break; } std::printf(" [face] loop%d outer=%d edges=%d chained=%d:", li, lp.is_outer ? 1 : 0, m, chained ? 1 : 0); for (int k = 0; k < m; ++k) { int ei = lp.edges[static_cast(k)]; if (ei < 0 || ei >= E) { std::printf(" e?%d", ei); continue; } const auto& e = b.edge(ei); const Point3D p0 = b.vertex_by_id(e.v_start).point; const Point3D p1 = b.vertex_by_id(e.v_end).point; std::printf(" e%d[v%d->v%d dir=%+d cur=%d (%.6g,%.6g,%.6g)]", ei, e.v_start, e.v_end, dir[static_cast(k)], e.curve ? 1 : 0, p0.x(), p0.y(), p0.z()); } std::printf("\n"); } } } /// 一行拓扑摘要(--stage chain 逐步打印):F/E/V + 开放边数(相异面 <2)+ 非流形边数 static void print_stats(const char* tag, const BrepModel& b) { const int F = static_cast(b.num_faces()); const int E = static_cast(b.num_edges()); std::vector nf(static_cast(E), 0); for (int fi = 0; fi < F; ++fi) { std::set seen; for (int ei : b.face_edges(fi)) if (ei >= 0 && ei < E && seen.insert(ei).second) ++nf[static_cast(ei)]; } size_t open = 0, nm = 0; for (int ei = 0; ei < E; ++ei) { if (nf[static_cast(ei)] < 2) ++open; if (nf[static_cast(ei)] >= 3) ++nm; } std::printf(" [chain] %-20s F=%d E=%d V=%zu open=%zu nm=%zu\n", tag, F, E, b.num_vertices(), open, nm); } /// 逐壳面清单(--shells):判定"非流形自触"是壳内自触还是跨壳相触 /// (k10 诊断文案"实体沿曲线自触 / 双壳相触"二选一需要壳归属佐证)。 static void dump_shells(const BrepModel& b) { const auto& shs = b.all_shells(); std::printf(" [shells] bodies=%zu shells=%zu\n", b.num_bodies(), shs.size()); for (size_t si = 0; si < shs.size(); ++si) { const auto& sh = shs[si]; std::printf(" [shells] shell%zu id=%d closed=%d nfaces=%zu:", si, sh.id, sh.closed ? 1 : 0, sh.faces.size()); for (int fi : sh.faces) std::printf(" %d", fi); std::printf("\n"); } } static void dump_body(const BrepModel& b, size_t bi, bool diag, bool seams, bool loops, bool dump_edges) { const int F = static_cast(b.num_faces()); const int E = static_cast(b.num_edges()); std::vector> inc(E); // edge -> distinct faces std::vector> occ(E); // edge -> face occurrences (with dup) for (int fi = 0; fi < F; ++fi) { std::set seen; for (int ei : b.face_edges(fi)) { if (ei < 0 || ei >= E) continue; occ[ei].push_back(fi); if (seen.insert(ei).second) inc[ei].push_back(fi); } } // 汇总:≥3 相异面(真非流形候选)、≥3 逐引用(含同面重复)、0/1 面(悬边/边界) size_t n_nm = 0, n_dup = 0, n_open = 0, n_two = 0; for (int ei = 0; ei < E; ++ei) { const size_t nfac = inc[ei].size(), nocc = occ[ei].size(); if (nfac >= 3) ++n_nm; else if (nocc >= 3) ++n_dup; if (nfac == 0 || nfac == 1) ++n_open; else if (nfac == 2) ++n_two; } const double wt = E ? static_cast(n_two) / E : 1.0; std::printf(" body%zu: F=%d E=%d V=%zu nm3(diff-face)=%zu occ3(same-face-dup)=%zu " "open<=1=%zu wt=%.4f\n", bi, F, E, b.num_vertices(), n_nm, n_dup, n_open, wt); if (diag) { const vde::brep::BodyDiagnostics d = vde::brep::diagnose_body(b); for (const auto& it : d.errors) { std::printf(" ERR kind=%d nfaces=%zu: %s\n", it.kind, it.faces.size(), it.message.c_str()); } } if (loops) { // 逐面环规模 + 逐边相异面数:用于核对导入是否忠实保留源环引用 // (源 CLOSED_SHELL 每边 2 面闭合时,此处也应全为 2)。 std::printf(" [loops] per-face loop edges:"); for (int fi = 0; fi < F; ++fi) { size_t n = 0; for (int li : b.face(fi).loops) n += b.loop_by_id(li).edges.size(); std::printf(" %zu", n); } std::printf("\n [loops] edges with <2 faces:"); bool any = false; for (int ei = 0; ei < E; ++ei) { if (inc[ei].size() >= 2) continue; any = true; const auto& e = b.edge(ei); const Point3D p0 = b.vertex_by_id(e.v_start).point; const Point3D p1 = b.vertex_by_id(e.v_end).point; std::printf("\n e%d nfac=%zu v(%d->%d) len=%.6g p0=(%.5g,%.5g,%.5g)", ei, inc[ei].size(), e.v_start, e.v_end, (p1 - p0).norm(), p0.x(), p0.y(), p0.z()); } if (!any) std::printf(" (none)"); std::printf("\n"); } if (dump_edges) { // 全边签名转储(--edges):与另一份导入结果逐行比对,定位往返 // 消失/新增的具体边。签名不含顶点下标(raw 与 reimport 下标不可比), // 端点按字典序归一(方向无关),曲线中点区分同端点对的多条边。 for (int ei = 0; ei < E; ++ei) { const auto& e = b.edge(ei); const Point3D p0 = b.vertex_by_id(e.v_start).point; const Point3D p1 = b.vertex_by_id(e.v_end).point; Point3D m = (p0 + p1) * 0.5; if (e.curve) { const auto d = e.curve->domain(); m = e.curve->evaluate(0.5 * (d.first + d.second)); } Point3D a = p0, c = p1; if (p1.x() < p0.x() || (p1.x() == p0.x() && (p1.y() < p0.y() || (p1.y() == p0.y() && p1.z() < p0.z())))) { a = p1; c = p0; } std::printf(" [edge] b%zu nfac=%zu A=(%.9g,%.9g,%.9g) " "B=(%.9g,%.9g,%.9g) M=(%.9g,%.9g,%.9g)\n", bi, inc[ei].size(), a.x(), a.y(), a.z(), c.x(), c.y(), c.z(), m.x(), m.y(), m.z()); } } for (int ei = 0; ei < E; ++ei) { const size_t nfac = inc[ei].size(); const size_t nocc = occ[ei].size(); const bool nm_case = (nfac >= 3 || nocc >= 3); const bool seam_case = (nfac == 1 && nocc >= 2); // 周期面 seam(同面正反两次) if (!(nm_case || (seams && seam_case))) continue; const auto& e = b.edge(ei); const Point3D p0 = b.vertex_by_id(e.v_start).point; const Point3D p1 = b.vertex_by_id(e.v_end).point; std::printf(" body%zu F=%d E=%d edge#%d %s occ=%zu nfac=%zu len=%.6g " "v0=(%.5g,%.5g,%.5g) v1=(%.5g,%.5g,%.5g)\n", bi, F, E, ei, seam_case ? "SEAM" : "NM", nocc, nfac, (p1 - p0).norm(), p0.x(), p0.y(), p0.z(), p1.x(), p1.y(), p1.z()); for (int fi : inc[ei]) { const auto& f = b.face(fi); const auto& ns = b.face_surface(fi); int this_face_occ = 0; for (int x : occ[ei]) if (x == fi) ++this_face_occ; size_t nloop_edges = 0; for (int li : f.loops) nloop_edges += b.loop_by_id(li).edges.size(); double mn[3] = {1e300, 1e300, 1e300}, mx[3] = {-1e300, -1e300, -1e300}; for (int li : f.loops) { for (int le : b.loop_by_id(li).edges) { if (le < 0 || le >= E) continue; const auto& ee = b.edge(le); for (int v : {ee.v_start, ee.v_end}) { const Point3D& q = b.vertex_by_id(v).point; double c[3] = {q.x(), q.y(), q.z()}; for (int k = 0; k < 3; ++k) { mn[k] = std::min(mn[k], c[k]); mx[k] = std::max(mx[k], c[k]); } } } } const double diag = std::sqrt((mx[0]-mn[0])*(mx[0]-mn[0]) + (mx[1]-mn[1])*(mx[1]-mn[1]) + (mx[2]-mn[2])*(mx[2]-mn[2])); std::printf(" f%d sid=%d occ_in_face=%d deg=%dx%d cp=%zux%zu " "loops=%zu loop_edges=%zu diag=%.6g rev=%d", fi, f.surface_id, this_face_occ, ns.degree_u(), ns.degree_v(), ns.control_points().size(), ns.control_points().empty() ? 0 : ns.control_points()[0].size(), f.loops.size(), nloop_edges, diag, f.reversed ? 1 : 0); if (ns.degree_u() == 1 && ns.degree_v() == 1 && ns.control_points().size() >= 2) { const auto& c0 = ns.control_points()[0][0]; const auto& c1 = ns.control_points()[0][1]; const auto& c2 = ns.control_points()[1][0]; Vector3D n = Vector3D(c1 - c0).cross(Vector3D(c2 - c0)); if (n.norm() > 1e-12) { n = n.normalized(); std::printf(" plane_n=(%.6g,%.6g,%.6g) d=%.6g", n.x(), n.y(), n.z(), n.dot(Vector3D(c0))); } } std::printf("\n"); } } } int main(int argc, char** argv) { bool heal = false, diag = false, seams = false, dup = false, loops = false; bool edges = false, shells_dump = false; std::string stage = "raw"; int face_body = -1; std::vector face_ids; std::vector only; // --only a,b:只处理这些 body 下标(heal 逐体极慢时用) std::vector files; for (int i = 1; i < argc; ++i) { const std::string a = argv[i]; if (a == "--heal") { heal = true; stage = "full"; continue; } if (a == "--diag") { diag = true; continue; } if (a == "--seams") { seams = true; continue; } if (a == "--dup") { dup = true; continue; } if (a == "--loops") { loops = true; continue; } if (a == "--edges") { edges = true; continue; } if (a == "--shells") { shells_dump = true; continue; } if (a == "--only" && i + 1 < argc) { std::string rest = argv[++i]; size_t pos = 0; while (pos <= rest.size()) { const size_t comma = rest.find(',', pos); const std::string tok = rest.substr( pos, comma == std::string::npos ? std::string::npos : comma - pos); if (!tok.empty()) only.push_back(std::stoi(tok)); if (comma == std::string::npos) break; pos = comma + 1; } continue; } if (a == "--face" && i + 1 < argc) { std::string spec = argv[++i]; const size_t colon = spec.find(':'); if (colon != std::string::npos) { face_body = std::stoi(spec.substr(0, colon)); std::string rest = spec.substr(colon + 1); size_t pos = 0; while (pos <= rest.size()) { const size_t comma = rest.find(',', pos); const std::string tok = rest.substr( pos, comma == std::string::npos ? std::string::npos : comma - pos); if (!tok.empty()) face_ids.push_back(std::stoi(tok)); if (comma == std::string::npos) break; pos = comma + 1; } } continue; } if (a == "--stage" && i + 1 < argc) { stage = argv[++i]; continue; } files.push_back(a); } const double tol = 1e-6; // 与 automatic_heal 的 pipeline tolerance 一致 for (const std::string& path : files) { std::printf("=== %s%s\n", path.c_str(), heal ? " [heal]" : ""); std::vector bodies; try { bodies = vde::brep::import_step(path, {}); } catch (const std::exception& ex) { std::printf(" import failed: %s\n", ex.what()); continue; } std::printf(" bodies=%zu\n", bodies.size()); for (size_t bi = 0; bi < bodies.size(); ++bi) { if (!only.empty() && std::find(only.begin(), only.end(), static_cast(bi)) == only.end()) continue; if (stage != "raw") { std::printf(" [stage %s] before: F=%d E=%d V=%zu\n", stage.c_str(), static_cast(bodies[bi].num_faces()), static_cast(bodies[bi].num_edges()), bodies[bi].num_vertices()); } if (stage == "gaps") { int m = vde::brep::heal_gaps(bodies[bi], tol); std::printf(" [stage gaps] merged=%d -> F=%d E=%d V=%zu\n", m, static_cast(bodies[bi].num_faces()), static_cast(bodies[bi].num_edges()), bodies[bi].num_vertices()); } else if (stage == "stitch") { int m = vde::brep::heal_gaps(bodies[bi], tol); auto s1 = vde::brep::step_stitch(bodies[bi], tol); auto s2 = vde::brep::step_stitch(bodies[bi], tol); std::printf(" [stage stitch] gaps_merged=%d stitch1=%d post_stitch=%d" " -> F=%d E=%d V=%zu\n", m, s1.items_fixed, s2.items_fixed, static_cast(bodies[bi].num_faces()), static_cast(bodies[bi].num_edges()), bodies[bi].num_vertices()); } else if (stage == "chain") { // 逐步复刻 auto_heal_pipeline(无守卫),每步后打印拓扑摘要: // 用于定位哪一步把 Stitch 已修好的体再次破坏(进而被守卫回退)。 vde::brep::heal_split_pinch_vertices(bodies[bi], 1e-6); // Step 0(入口前置) print_stats("step0_pinch_pre", bodies[bi]); vde::brep::step_stitch(bodies[bi], tol); print_stats("stitch", bodies[bi]); int m = vde::brep::heal_gaps(bodies[bi], tol); print_stats("heal_gaps", bodies[bi]); if (m > 0) { vde::brep::step_stitch(bodies[bi], tol); print_stats("stitch_post_gaps", bodies[bi]); } vde::brep::step_simplify(bodies[bi], tol); print_stats("simplify", bodies[bi]); vde::brep::step_regularize(bodies[bi], tol); print_stats("regularize", bodies[bi]); vde::brep::step_orient(bodies[bi]); print_stats("orient", bodies[bi]); vde::brep::gap_fill(bodies[bi], tol); print_stats("gap_fill", bodies[bi]); vde::brep::step_stitch(bodies[bi], tol); print_stats("stitch_post_fill", bodies[bi]); vde::brep::heal_split_pinch_vertices(bodies[bi], tol); print_stats("pinch_split", bodies[bi]); } else if (stage == "pipe") { // 无守卫的裸流水线(对照 automatic_heal 以区分"守卫回退"与 // "流水线本身未达成")。 auto r = vde::brep::auto_heal_pipeline(bodies[bi], tol); std::printf(" [stage pipe] st=%d si=%d re=%d or=%d fi=%d ch=%d score=%d" " -> F=%d E=%d V=%zu\n", r.stitch.items_fixed, r.simplify.items_fixed, r.regularize.items_fixed, r.orient.items_fixed, r.fill.items_fixed, r.check.items_fixed, r.overall_score, static_cast(bodies[bi].num_faces()), static_cast(bodies[bi].num_edges()), bodies[bi].num_vertices()); for (const auto& w : r.warnings) std::printf(" [pipe warn] %s\n", w.c_str()); } else if (stage == "full") { const auto hr = vde::brep::automatic_heal(bodies[bi]); std::printf(" [heal body%zu] st=%d si=%d re=%d or=%d fi=%d ch=%d score=%d\n", bi, hr.stitch.items_fixed, hr.simplify.items_fixed, hr.regularize.items_fixed, hr.orient.items_fixed, hr.fill.items_fixed, hr.check.items_fixed, hr.overall_score); for (const auto& w : hr.warnings) std::printf(" [heal warn] %s\n", w.c_str()); } if (dup) dump_dup_pairs(bodies[bi], bi, tol); if (shells_dump) dump_shells(bodies[bi]); if (face_body >= 0 && static_cast(face_body) == bi) dump_faces(bodies[bi], bi, face_ids); dump_body(bodies[bi], bi, diag, seams, loops, edges); } } return 0; }