fix(v1.0.3): 修复 get_face_index_by_position 中 face_centroid 作用域错误
face_centroid 定义在 ssi_boolean.cpp 中,不在任何头文件中声明, 改为在 get_face_index_by_position 中内联计算面质心。
This commit is contained in:
+10
-2
@@ -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); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user