fix: replace Eigen::SelfAdjointEigenSolver with cross product plane fitting
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user