Merge branch 'FIx_collapse_ok' into 'master'
F ix collapse ok See merge request OpenMesh/OpenMesh!198
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
<b>Core</b>
|
<b>Core</b>
|
||||||
<ul>
|
<ul>
|
||||||
<li>TriConnectivity: Added two functions split_edge and split_edge_copy to mask the PolyConnectivity functions of the same name (Prevents creation of valence 2 vertices on trimeshes)</li>
|
<li>TriConnectivity: Added two functions split_edge and split_edge_copy to mask the PolyConnectivity functions of the same name (Prevents creation of valence 2 vertices on trimeshes)</li>
|
||||||
|
<li>PolyConnectivity: Fixed PolyConnectivity is_collapse_ok, missing some configurations (Thanks to Simon Flöry for the patch)</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<b>IO</b>
|
<b>IO</b>
|
||||||
|
|||||||
@@ -364,14 +364,16 @@ bool PolyConnectivity::is_collapse_ok(HalfedgeHandle v0v1)
|
|||||||
|
|
||||||
//the edges v1-vl and vl-v0 must not be both boundary edges
|
//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
|
//this test makes only sense in a polymesh if the side face is a triangle
|
||||||
|
VertexHandle vl;
|
||||||
if (!is_boundary(v0v1))
|
if (!is_boundary(v0v1))
|
||||||
{
|
{
|
||||||
if (v0v1_triangle)
|
if (v0v1_triangle)
|
||||||
{
|
{
|
||||||
//VertexHandle vl = to_vertex_handle(next_halfedge_handle(v0v1));
|
|
||||||
|
|
||||||
HalfedgeHandle h1 = next_halfedge_handle(v0v1);
|
HalfedgeHandle h1 = next_halfedge_handle(v0v1);
|
||||||
HalfedgeHandle h2 = next_halfedge_handle(h1);
|
HalfedgeHandle h2 = next_halfedge_handle(h1);
|
||||||
|
|
||||||
|
vl = to_vertex_handle(h1);
|
||||||
|
|
||||||
if (is_boundary(opposite_halfedge_handle(h1)) && is_boundary(opposite_halfedge_handle(h2)))
|
if (is_boundary(opposite_halfedge_handle(h1)) && is_boundary(opposite_halfedge_handle(h2)))
|
||||||
return false;
|
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
|
//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
|
//this test makes only sense in a polymesh if the side face is a triangle
|
||||||
|
VertexHandle vr;
|
||||||
if (!is_boundary(v1v0))
|
if (!is_boundary(v1v0))
|
||||||
{
|
{
|
||||||
if (v1v0_triangle)
|
if (v1v0_triangle)
|
||||||
{
|
{
|
||||||
//VertexHandle vr = to_vertex_handle(next_halfedge_handle(v1v0));
|
|
||||||
|
|
||||||
HalfedgeHandle h1 = next_halfedge_handle(v1v0);
|
HalfedgeHandle h1 = next_halfedge_handle(v1v0);
|
||||||
HalfedgeHandle h2 = next_halfedge_handle(h1);
|
HalfedgeHandle h2 = next_halfedge_handle(h1);
|
||||||
|
|
||||||
|
vr = to_vertex_handle(h1);
|
||||||
|
|
||||||
if (is_boundary(opposite_halfedge_handle(h1)) && is_boundary(opposite_halfedge_handle(h2)))
|
if (is_boundary(opposite_halfedge_handle(h1)) && is_boundary(opposite_halfedge_handle(h2)))
|
||||||
return false;
|
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
|
// edge between two boundary vertices should be a boundary edge
|
||||||
if ( is_boundary(v0) && is_boundary(v1) && !is_boundary(v0v1) && !is_boundary(v1v0))
|
if ( is_boundary(v0) && is_boundary(v1) && !is_boundary(v0v1) && !is_boundary(v1v0))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
70
src/Unittests/unittests_polymesh_collapse.cc
Normal file
70
src/Unittests/unittests_polymesh_collapse.cc
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <Unittests/unittests_common.hh>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class OpenMeshCollapsePoly : public OpenMeshBasePoly {
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// This function is called before each test is run
|
||||||
|
virtual void SetUp() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function is called after all tests are through
|
||||||
|
virtual void TearDown() {
|
||||||
|
|
||||||
|
// Do some final stuff with the member data here...
|
||||||
|
}
|
||||||
|
|
||||||
|
// Member already defined in OpenMeshBase
|
||||||
|
//Mesh mesh_;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ====================================================================
|
||||||
|
* Define tests below
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This code tests is_collapse_ok on a double sided triangle. The
|
||||||
|
* test mesh comprises three vertices, that are connected to form two
|
||||||
|
* triangles of opposite orientation. All halfedges should be non collapsable.
|
||||||
|
*/
|
||||||
|
TEST_F(OpenMeshCollapsePoly, CheckCollapseOkDoublesidedTriangle) {
|
||||||
|
|
||||||
|
mesh_.clear();
|
||||||
|
|
||||||
|
Mesh::VertexHandle vh0 = mesh_.add_vertex(Mesh::Point(0,0,0));
|
||||||
|
Mesh::VertexHandle vh1 = mesh_.add_vertex(Mesh::Point(1,0,0));
|
||||||
|
Mesh::VertexHandle vh2 = mesh_.add_vertex(Mesh::Point(1,1,0));
|
||||||
|
mesh_.add_face(vh0, vh1, vh2);
|
||||||
|
mesh_.add_face(vh0, vh2, vh1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mesh_.request_vertex_status();
|
||||||
|
mesh_.request_face_status();
|
||||||
|
mesh_.request_edge_status();
|
||||||
|
|
||||||
|
int collapsable = 0;
|
||||||
|
|
||||||
|
for ( const auto hh : mesh_.all_halfedges() )
|
||||||
|
{
|
||||||
|
if (mesh_.is_collapse_ok(hh) )
|
||||||
|
collapsable++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EXPECT_EQ(collapsable,0) << "No collapse should be ok when we have only a double sided Triangle";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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";
|
EXPECT_FALSE(mesh_.status(mesh_.opposite_halfedge_handle(bottom_right)).deleted()) << "Halfedge from vertex 5 to vertex 3 is deleted";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user