diff --git a/include/cinolib/merge_meshes_at_coincident_vertices.cpp b/include/cinolib/merge_meshes_at_coincident_vertices.cpp index 75949c95..8f9abf04 100644 --- a/include/cinolib/merge_meshes_at_coincident_vertices.cpp +++ b/include/cinolib/merge_meshes_at_coincident_vertices.cpp @@ -39,6 +39,51 @@ namespace cinolib { +template +CINO_INLINE +void merge_meshes_at_coincident_vertices(const AbstractPolygonMesh & m1, + const AbstractPolygonMesh & m2, + AbstractPolygonMesh & res) +{ + cinolib::Octree octree; + octree.build_from_mesh_points(m1); + + res = m1; + + std::map vmap; + for(uint vid=0; vid ids; + if(octree.contains(p, false, ids)) + { + // WARNING: I am assuming that the mapping is one to one at most + assert(ids.size()==1); + vmap[vid] = *ids.begin(); + } + else + { + uint fresh_id = res.vert_add(p); + vmap[vid] = fresh_id; + } + } + + for(uint pid=0; pid CINO_INLINE void merge_meshes_at_coincident_vertices(const AbstractPolyhedralMesh & m1, diff --git a/include/cinolib/merge_meshes_at_coincident_vertices.h b/include/cinolib/merge_meshes_at_coincident_vertices.h index 205906c3..097a59d0 100644 --- a/include/cinolib/merge_meshes_at_coincident_vertices.h +++ b/include/cinolib/merge_meshes_at_coincident_vertices.h @@ -41,6 +41,12 @@ namespace cinolib { +template +CINO_INLINE +void merge_meshes_at_coincident_vertices(const AbstractPolygonMesh & m1, + const AbstractPolygonMesh & m2, + AbstractPolygonMesh & res); + template CINO_INLINE void merge_meshes_at_coincident_vertices(const AbstractPolyhedralMesh & m1,