From a6939d5abd4909688080994d7f06ab330c473980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=82=E4=B9=8B=E9=92=B3?= Date: Fri, 24 Jul 2026 14:42:41 +0000 Subject: [PATCH] fix: replace Eigen::SelfAdjointEigenSolver with cross product plane fitting --- src/brep/brep_boolean.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/brep/brep_boolean.cpp b/src/brep/brep_boolean.cpp index 51c4d2b..5e6f6df 100644 --- a/src/brep/brep_boolean.cpp +++ b/src/brep/brep_boolean.cpp @@ -521,18 +521,14 @@ std::vector split_face_by_face_ssi( for (const auto& p : valid_curve->points) centroid += p; centroid /= static_cast(valid_curve->points.size()); - // Fit plane via SVD on intersection points - Eigen::Matrix3d cov = Eigen::Matrix3d::Zero(); - for (const auto& p : valid_curve->points) { - Vector3D d = p - centroid; - cov += d * d.transpose(); + // Compute plane normal: use cross product of two spread directions, fall back to B face normal + Vector3D plane_n(0,0,0); + if (valid_curve->points.size() >= 3) { + Vector3D d1 = valid_curve->points[1] - valid_curve->points[0]; + Vector3D d2 = valid_curve->points.back() - valid_curve->points[0]; + plane_n = d1.cross(d2); } - - Eigen::SelfAdjointEigenSolver es(cov); - Vector3D plane_n = es.eigenvectors().col(0); // smallest eigenvector = normal - if (plane_n.norm() < 1e-12) { - // Degenerate: fall back to face normal of B plane_n = face_normal(body_b, face_b_id); }