fix: replace Eigen::SelfAdjointEigenSolver with cross product plane fitting
CI / Build & Test (push) Failing after 31s
CI / Release Build (push) Failing after 31s
Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled

This commit is contained in:
茂之钳
2026-07-24 14:42:41 +00:00
parent 38ebb963d0
commit a6939d5abd
+6 -10
View File
@@ -521,18 +521,14 @@ std::vector<BrepModel> split_face_by_face_ssi(
for (const auto& p : valid_curve->points) centroid += p;
centroid /= static_cast<double>(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<Eigen::Matrix3d> 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);
}