diff --git a/src/hole_filling.cpp b/src/hole_filling.cpp index d522d16..1aa4402 100644 --- a/src/hole_filling.cpp +++ b/src/hole_filling.cpp @@ -2,6 +2,7 @@ #include "IO.h" #include "util.h" #include +#include static std::vector> findHoles(MyMesh &mesh) { @@ -153,7 +154,7 @@ vector Hole_Filling::next_neighbors(const vector, vector &> Hole_Filling::compute_approx_mat(vector vlist) +pair, vector &> Hole_Filling::compute_approx_mat(vector vlist, double normal_scale) { const int n(vlist.size()), d(10) ; Eigen::MatrixXd & A = *(new Eigen::MatrixXd(3*n+d,3*n+d)) ; @@ -170,12 +171,12 @@ pair, vector &> Hole_F //Append vertices+normals to pts_list for (int i=0; i + (mesh, "bounding_box"); + } catch (const std::runtime_error &e) { + auto mesh_bb = OpenMesh::getOrMakeProperty + (mesh, "bounding_box"); + std::vector verts; + for (VertexHandle vh : mesh.vertices()) { + verts.push_back(vh); + } + *mesh_bb = hf.estimate_BB(verts); + } +} + + MyMesh fillHoleImplicit(MyMesh &mesh, Hole_Filling &hf, std::vector &hole) { + computeMeshBoundingBox(mesh, hf); + Rect3 mesh_bb = *OpenMesh::getProperty(mesh, "bounding_box"); + double diag = mesh_bb.size.Norm(); + std::vector verts; for (HalfedgeHandle hh : hole) { verts.push_back(mesh.to_vertex_handle(hh)); } auto bb = hf.estimate_BB(verts) ; verts = hf.next_neighbors(verts); - auto [system, pts_list] = hf.compute_approx_mat(verts); + auto [system, pts_list] = hf.compute_approx_mat(verts, diag * .1); auto [alpha, beta] = hf.solve_approx(system, pts_list.size(), 10); Implicit_RBF rbf(alpha, beta, pts_list); diff --git a/src/hole_filling.h b/src/hole_filling.h index d636c69..939054e 100644 --- a/src/hole_filling.h +++ b/src/hole_filling.h @@ -103,7 +103,7 @@ public: vector next_neighbors(const vector & bnd) ; // Computation of RBF - pair,vector &> compute_approx_mat(vector vlist) ; + pair,vector &> compute_approx_mat(vector vlist, double normal_scale=1) ; pair&, vector&> solve_approx(const pair &p, int n, int d) ; // IO