fix(v1.0.3): 修复 get_face_index_by_position 中 face_centroid 作用域错误
Build & Test / build-and-test (push) Waiting to run
Build & Test / python-bindings (push) Blocked by required conditions
CI / Build & Test (push) Failing after 37s
CI / Release Build (push) Failing after 27s

face_centroid 定义在 ssi_boolean.cpp 中,不在任何头文件中声明,
改为在 get_face_index_by_position 中内联计算面质心。
This commit is contained in:
茂之钳
2026-07-28 17:11:30 +08:00
parent aeb29ab87c
commit 4a6abd9048
+10 -2
View File
@@ -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<double>::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<int>(fi));
// Compute face centroid from its edge vertices (same as face_centroid in ssi_boolean.cpp)
auto edges = body.face_edges(static_cast<int>(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<double>(count);
double d = (center - nearPoint).norm();
if (d < best_dist) { best_dist = d; best_id = static_cast<int>(fi); }
}