From 4a6abd904865a70b3eab8f2dbdd3e8f776319ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=82=E4=B9=8B=E9=92=B3?= Date: Tue, 28 Jul 2026 17:11:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(v1.0.3):=20=E4=BF=AE=E5=A4=8D=20get=5Fface?= =?UTF-8?q?=5Findex=5Fby=5Fposition=20=E4=B8=AD=20face=5Fcentroid=20?= =?UTF-8?q?=E4=BD=9C=E7=94=A8=E5=9F=9F=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit face_centroid 定义在 ssi_boolean.cpp 中,不在任何头文件中声明, 改为在 get_face_index_by_position 中内联计算面质心。 --- src/brep/modeling.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/brep/modeling.cpp b/src/brep/modeling.cpp index 0f910b8..898a8fe 100644 --- a/src/brep/modeling.cpp +++ b/src/brep/modeling.cpp @@ -1230,8 +1230,16 @@ int get_face_index_by_position(const BrepModel& body, const Point3D& nearPoint) int best_id = -1; double best_dist = std::numeric_limits::max(); for (size_t fi = 0; fi < body.num_faces(); ++fi) { - // Use face bounds center as reference point - Point3D center = face_centroid(body, static_cast(fi)); + // Compute face centroid from its edge vertices (same as face_centroid in ssi_boolean.cpp) + auto edges = body.face_edges(static_cast(fi)); + Point3D center(0, 0, 0); + int count = 0; + for (int ei : edges) { + const auto& e = body.edge(ei); + center += body.vertex_by_id(e.v_start).point; count++; + center += body.vertex_by_id(e.v_end).point; count++; + } + if (count > 0) center = center / static_cast(count); double d = (center - nearPoint).norm(); if (d < best_dist) { best_dist = d; best_id = static_cast(fi); } }