From be6a1d4f8a2606416088459471cef4315e904db7 Mon Sep 17 00:00:00 2001 From: papush! Date: Sat, 27 Nov 2021 17:03:29 +0100 Subject: [PATCH] fix a bug in the implicit hole filling only the boundary vertices were used to find an implicit surface, when its 1-ring is needed too --- src/hole_filling.cpp | 29 +++++------------------------ src/hole_filling.h | 5 +---- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/src/hole_filling.cpp b/src/hole_filling.cpp index 9878849..2f43c76 100644 --- a/src/hole_filling.cpp +++ b/src/hole_filling.cpp @@ -239,14 +239,6 @@ pair&, vector&> Hole_Filling::solve_approx(const pair &vlist) return domain ; } -Mesh Hole_Filling::poly_n_out(const Implicit_RBF &implicit, Rect3 domain, string filename) +Mesh Hole_Filling::poly_n_out(const Implicit_RBF &implicit, Rect3 domain) { auto implicitEq = [&implicit](Vec3 const& pos) { @@ -306,7 +298,6 @@ Mesh Hole_Filling::poly_n_out(const Implicit_RBF &implicit, Rect3 domain, string cout << "cubesize "<< cubeSize << endl ; return MarchCube(implicitEq, domain, cubeSize); - // WriteObjFile(mesh, filename); } @@ -315,26 +306,16 @@ MyMesh fillHoleImplicit(MyMesh &mesh, Hole_Filling &hf, std::vector verts; for (HalfedgeHandle hh : hole) { verts.push_back(mesh.to_vertex_handle(hh)); + verts.push_back(mesh.to_vertex_handle( + mesh.next_halfedge_handle( + mesh.opposite_halfedge_handle(hh)))); } auto [system, pts_list] = hf.compute_approx_mat(verts); auto [alpha, beta] = hf.solve_approx(system, pts_list.size(), 10); Implicit_RBF rbf(alpha, beta, pts_list); - // qDebug() << ""; - // for (const Point &p : pts_list) { - // qDebug() << rbf.val(p); - // } - auto bb = hf.estimate_BB(verts) ; - const QString path = "out.obj"; - Mesh filling = hf.poly_n_out(rbf, bb, path.toStdString()); - // MyMesh out_mesh; - // OpenMesh::IO::Options options; - // options.set(OpenMesh::IO::Options::VertexNormal); - // if (!OpenMesh::IO::read_mesh(mesh, path.toUtf8().constData(), options)) { - // qWarning() << "Failed to read" << path; - // throw runtime_error("Failed to read marching cube output mesh"); - // } + Mesh filling = hf.poly_n_out(rbf, bb); MyMesh ret; for (const Vec3 &v : filling.vertices) { VertexHandle vh = ret.new_vertex({v.x, v.y, v.z}); diff --git a/src/hole_filling.h b/src/hole_filling.h index 700cc3c..d636c69 100644 --- a/src/hole_filling.h +++ b/src/hole_filling.h @@ -106,14 +106,11 @@ public: pair,vector &> compute_approx_mat(vector vlist) ; pair&, vector&> solve_approx(const pair &p, int n, int d) ; - // Hole filling - void fill_hole(string out) ; - // IO void colorize_prop() ; void colorize_verts(const vector &vlist) ; Rect3 estimate_BB(const vector &vlist) ; - Mesh poly_n_out (const Implicit_RBF & implicit, Rect3 domain, std::string filename) ; + Mesh poly_n_out (const Implicit_RBF & implicit, Rect3 domain) ; }; // Other ....