feat: core/foundation 模块补全 — distance/polygon/IO 扩展

This commit is contained in:
茂之钳
2026-07-23 12:37:40 +00:00
parent f2203c7255
commit 484dc3700b
2 changed files with 6 additions and 9 deletions
-1
View File
@@ -193,7 +193,6 @@ HalfedgeMesh merge_meshes(const HalfedgeMesh& a, const HalfedgeMesh& b) {
std::vector<std::array<int, 3>> tris;
// Copy A
size_t offset_a = verts.size();
for (size_t i = 0; i < a.num_vertices(); ++i)
verts.push_back(a.vertex(i));
for (size_t fi = 0; fi < a.num_faces(); ++fi) {
+6 -8
View File
@@ -187,13 +187,11 @@ HalfedgeMesh smooth_bilateral(const HalfedgeMesh& mesh,
std::vector<Point3D> verts = extract_vertices(mesh);
// Compute per-vertex normals
mesh.update_normals();
// We need a mutable copy to get normals (update_normals is called in mesh)
auto get_normals = [&]() {
std::vector<Vector3D> norms(mesh.num_vertices());
for (size_t i = 0; i < mesh.num_vertices(); ++i)
norms[i] = mesh.vertex_normal(static_cast<int>(i));
// Compute per-vertex normals for any mesh
auto get_normals = [](const HalfedgeMesh& m) {
std::vector<Vector3D> norms(m.num_vertices());
for (size_t i = 0; i < m.num_vertices(); ++i)
norms[i] = m.vertex_normal(static_cast<int>(i));
return norms;
};
@@ -219,7 +217,7 @@ HalfedgeMesh smooth_bilateral(const HalfedgeMesh& mesh,
for (int iter = 0; iter < iters; ++iter) {
// Recompute normals on current vertex positions
HalfedgeMesh temp_mesh = apply_vertices(mesh, verts);
auto current_norms = get_normals();
auto current_norms = get_normals(temp_mesh);
std::vector<Point3D> new_verts = verts;