Commit b96a41dc authored by Mike Kremer's avatar Mike Kremer
Browse files

Added a series of unit tests

git-svn-id: http://www.openvolumemesh.org/svnrepo/OpenVolumeMesh/trunk@46 66977474-1d4b-4f09-8fe9-267525286df2
parent bcad4a61
......@@ -673,16 +673,13 @@ public:
private:
/// Erase vertex from vector and correct edge handles
void erase_vertex(typename Vertices::iterator& _v_it, const VertexHandle& _vh,
bool _fixHigherDim = true);
void erase_vertex(typename Vertices::iterator& _v_it, const VertexHandle& _vh);
/// Erase edge from vector and correct face handles
void erase_edge(typename Edges::iterator& _e_it, const EdgeHandle& _eh,
bool _fixHigherDim = true);
void erase_edge(typename Edges::iterator& _e_it, const EdgeHandle& _eh);
/// Erase face from vector and correct cell handles
void erase_face(typename Faces::iterator& _f_it, const FaceHandle& _fh,
bool _fixHigherDim = true);
void erase_face(typename Faces::iterator& _f_it, const FaceHandle& _fh);
/// Erase cell from vector
void erase_cell(typename Cells::iterator& _c_it, const CellHandle& _ch);
......
......@@ -939,7 +939,7 @@ void PolyhedralMesh<VecT>::garbage_collection(bool _preserveManifoldness) {
continue;
}
erase_edge(e_it, eh, true);
erase_edge(e_it, eh);
}
FaceHandle fh(0);
......@@ -951,7 +951,7 @@ void PolyhedralMesh<VecT>::garbage_collection(bool _preserveManifoldness) {
continue;
}
erase_face(f_it, fh, true);
erase_face(f_it, fh);
}
CellHandle ch(0);
......@@ -987,7 +987,7 @@ void PolyhedralMesh<VecT>::garbage_collection(bool _preserveManifoldness) {
// If neither of the half-faces is incident to a cell, delete face
if(incident_cell(hf0) == InvalidCellHandle && incident_cell(hf1) == InvalidCellHandle) {
erase_face(f_it, fh, true);
erase_face(f_it, fh);
update_face_caches();
......@@ -1015,7 +1015,7 @@ void PolyhedralMesh<VecT>::garbage_collection(bool _preserveManifoldness) {
if(!he0hf_it.valid() && !he1hf_it.valid()) {
erase_edge(e_it, eh, true);
erase_edge(e_it, eh);
update_edge_caches();
......@@ -1039,7 +1039,7 @@ void PolyhedralMesh<VecT>::garbage_collection(bool _preserveManifoldness) {
VertexOHalfedgeIter voh_it = voh_iter(vh);
if(!voh_it.valid()) {
erase_vertex(v_it, vh, true);
erase_vertex(v_it, vh);
update_vertex_caches();
......@@ -1061,8 +1061,7 @@ void PolyhedralMesh<VecT>::garbage_collection(bool _preserveManifoldness) {
//========================================================================================
template <typename VecT>
void PolyhedralMesh<VecT>::erase_vertex(typename Vertices::iterator& _v_it,
const VertexHandle& _vh, bool _fixHigherDim) {
void PolyhedralMesh<VecT>::erase_vertex(typename Vertices::iterator& _v_it, const VertexHandle& _vh) {
_v_it = vertices_.erase(_v_it);
......@@ -1097,8 +1096,7 @@ void PolyhedralMesh<VecT>::erase_vertex(typename Vertices::iterator& _v_it,
//========================================================================================
template <typename VecT>
void PolyhedralMesh<VecT>::erase_edge(typename Edges::iterator& _e_it,
const EdgeHandle& _eh, bool _fixHigherDim) {
void PolyhedralMesh<VecT>::erase_edge(typename Edges::iterator& _e_it, const EdgeHandle& _eh) {
_e_it = edges_.erase(_e_it);
......@@ -1140,8 +1138,7 @@ void PolyhedralMesh<VecT>::erase_edge(typename Edges::iterator& _e_it,
//========================================================================================
template <typename VecT>
void PolyhedralMesh<VecT>::erase_face(typename Faces::iterator& _f_it,
const FaceHandle& _fh, bool _fixHigherDim) {
void PolyhedralMesh<VecT>::erase_face(typename Faces::iterator& _f_it, const FaceHandle& _fh) {
_f_it = faces_.erase(_f_it);
......
......@@ -554,7 +554,45 @@ TEST_F(HexahedralMeshBase, GarbageCollectionTest2) {
EXPECT_EQ(8u, mesh_.n_faces());
}
TEST_F(HexahedralMeshBase, GarbageCollectionTestManifoldness) {
TEST_F(HexahedralMeshBase, GarbageCollectionTest3) {
generateHexahedralMesh(mesh_);
mesh_.request_vertex_status();
mesh_.request_edge_status();
mesh_.request_face_status();
mesh_.request_cell_status();
mesh_.delete_edge(EdgeHandle(0));
mesh_.garbage_collection(false);
EXPECT_EQ(1u, mesh_.n_cells());
EXPECT_EQ(12u, mesh_.n_vertices());
EXPECT_EQ(19u, mesh_.n_edges());
EXPECT_EQ(9u, mesh_.n_faces());
}
TEST_F(HexahedralMeshBase, GarbageCollectionTest4) {
generateHexahedralMesh(mesh_);
mesh_.request_vertex_status();
mesh_.request_edge_status();
mesh_.request_face_status();
mesh_.request_cell_status();
mesh_.delete_edge(EdgeHandle(5));
mesh_.garbage_collection(false);
EXPECT_EQ(0u, mesh_.n_cells());
EXPECT_EQ(12u, mesh_.n_vertices());
EXPECT_EQ(19u, mesh_.n_edges());
EXPECT_EQ(8u, mesh_.n_faces());
}
TEST_F(HexahedralMeshBase, GarbageCollectionTestManifoldness1) {
generateHexahedralMesh(mesh_);
......@@ -575,6 +613,90 @@ TEST_F(HexahedralMeshBase, GarbageCollectionTestManifoldness) {
EXPECT_EQ(8u, mesh_.n_vertices());
}
TEST_F(HexahedralMeshBase, GarbageCollectionTestManifoldness2) {
generateHexahedralMesh(mesh_);
mesh_.request_vertex_status();
mesh_.request_edge_status();
mesh_.request_face_status();
mesh_.request_cell_status();
mesh_.update_adjacencies();
mesh_.delete_edge(EdgeHandle(0));
mesh_.garbage_collection();
EXPECT_EQ(1u, mesh_.n_cells());
EXPECT_EQ(6u, mesh_.n_faces());
EXPECT_EQ(12u, mesh_.n_edges());
EXPECT_EQ(8u, mesh_.n_vertices());
}
TEST_F(HexahedralMeshBase, GarbageCollectionTestManifoldness3) {
generateHexahedralMesh(mesh_);
mesh_.request_vertex_status();
mesh_.request_edge_status();
mesh_.request_face_status();
mesh_.request_cell_status();
mesh_.update_adjacencies();
mesh_.delete_face(FaceHandle(0));
mesh_.garbage_collection();
EXPECT_EQ(1u, mesh_.n_cells());
EXPECT_EQ(6u, mesh_.n_faces());
EXPECT_EQ(12u, mesh_.n_edges());
EXPECT_EQ(8u, mesh_.n_vertices());
}
TEST_F(HexahedralMeshBase, GarbageCollectionTestManifoldness4) {
generateHexahedralMesh(mesh_);
mesh_.request_vertex_status();
mesh_.request_edge_status();
mesh_.request_face_status();
mesh_.request_cell_status();
mesh_.update_adjacencies();
mesh_.delete_cell(CellHandle(0));
mesh_.garbage_collection();
EXPECT_EQ(1u, mesh_.n_cells());
EXPECT_EQ(6u, mesh_.n_faces());
EXPECT_EQ(12u, mesh_.n_edges());
EXPECT_EQ(8u, mesh_.n_vertices());
}
TEST_F(HexahedralMeshBase, GarbageCollectionTestManifoldness5) {
generateHexahedralMesh(mesh_);
mesh_.request_vertex_status();
mesh_.request_edge_status();
mesh_.request_face_status();
mesh_.request_cell_status();
mesh_.update_adjacencies();
mesh_.delete_edge(EdgeHandle(5));
mesh_.garbage_collection();
EXPECT_EQ(0u, mesh_.n_cells());
EXPECT_EQ(0u, mesh_.n_faces());
EXPECT_EQ(0u, mesh_.n_edges());
EXPECT_EQ(0u, mesh_.n_vertices());
}
TEST_F(HexahedralMeshBase, GarbageCollectionTestProps1) {
generateHexahedralMesh(mesh_);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment