From 617b5e78de82c2e8dbb0dbb01b385a2c79214fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 10 Dec 2018 08:54:25 +0100 Subject: [PATCH] =?UTF-8?q?Fixed=20PolyConnectivity=20is=5Fcollapse=5Fok,?= =?UTF-8?q?=20missing=20some=20configurations=20(Thanks=20to=20Simon=20Fl?= =?UTF-8?q?=C3=B6ry=20for=20the=20patch)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/OpenMesh/Core/Mesh/PolyConnectivity.cc | 15 +++++++++++---- src/Unittests/unittests_trimesh_collapse.cc | 1 - 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/OpenMesh/Core/Mesh/PolyConnectivity.cc b/src/OpenMesh/Core/Mesh/PolyConnectivity.cc index e311f5cb..d8de07fc 100644 --- a/src/OpenMesh/Core/Mesh/PolyConnectivity.cc +++ b/src/OpenMesh/Core/Mesh/PolyConnectivity.cc @@ -364,14 +364,16 @@ bool PolyConnectivity::is_collapse_ok(HalfedgeHandle v0v1) //the edges v1-vl and vl-v0 must not be both boundary edges //this test makes only sense in a polymesh if the side face is a triangle + VertexHandle vl; if (!is_boundary(v0v1)) { if (v0v1_triangle) { - //VertexHandle vl = to_vertex_handle(next_halfedge_handle(v0v1)); - HalfedgeHandle h1 = next_halfedge_handle(v0v1); HalfedgeHandle h2 = next_halfedge_handle(h1); + + vl = to_vertex_handle(h1); + if (is_boundary(opposite_halfedge_handle(h1)) && is_boundary(opposite_halfedge_handle(h2))) return false; } @@ -379,19 +381,24 @@ bool PolyConnectivity::is_collapse_ok(HalfedgeHandle v0v1) //the edges v0-vr and vr-v1 must not be both boundary edges //this test makes only sense in a polymesh if the side face is a triangle + VertexHandle vr; if (!is_boundary(v1v0)) { if (v1v0_triangle) { - //VertexHandle vr = to_vertex_handle(next_halfedge_handle(v1v0)); - HalfedgeHandle h1 = next_halfedge_handle(v1v0); HalfedgeHandle h2 = next_halfedge_handle(h1); + + vr = to_vertex_handle(h1); + if (is_boundary(opposite_halfedge_handle(h1)) && is_boundary(opposite_halfedge_handle(h2))) return false; } } + // if vl and vr are equal and valid (e.g. triangle case) -> fail + if ( vl.is_valid() && (vl == vr)) return false; + // edge between two boundary vertices should be a boundary edge if ( is_boundary(v0) && is_boundary(v1) && !is_boundary(v0v1) && !is_boundary(v1v0)) return false; diff --git a/src/Unittests/unittests_trimesh_collapse.cc b/src/Unittests/unittests_trimesh_collapse.cc index fea9307a..99640d8e 100644 --- a/src/Unittests/unittests_trimesh_collapse.cc +++ b/src/Unittests/unittests_trimesh_collapse.cc @@ -741,5 +741,4 @@ TEST_F(OpenMeshCollapse, DeletedStatus) { EXPECT_FALSE(mesh_.status(mesh_.opposite_halfedge_handle(bottom_right)).deleted()) << "Halfedge from vertex 5 to vertex 3 is deleted"; } - }