diff --git a/brep2sdf/data/sampler.py b/brep2sdf/data/sampler.py index 8f64795..2d5c79a 100644 --- a/brep2sdf/data/sampler.py +++ b/brep2sdf/data/sampler.py @@ -211,11 +211,20 @@ def sample_zero_surface_points_and_normals( # 获取每个点所在的三角面片的法线 normals = trimesh_mesh_ncs.face_normals[face_indices] + + # 检查 face_normals 是否已归一化 + normals_norm = np.linalg.norm(normals, axis=1) + if not np.allclose(normals_norm, 1.0, atol=1e-5): + print("⚠️ 注意:face_normals 未归一化,正在手动归一化...") + normals = normals / (normals_norm.reshape(-1, 1) + 1e-8) + + # 构造 sdf 标签为 0 的列 sdf_zeros = np.zeros((num_samples, 1), dtype=np.float32) # 合并为 (N, 7) 的数组 [xyz, normal, sdf=0] points_with_normals_sdf = np.hstack([points, normals, sdf_zeros], dtype=np.float32) + np.random.shuffle(points_with_normals_sdf) return points_with_normals_sdf