Commit e11747c8 authored by Mike Kremer's avatar Mike Kremer

Update TD incidences of higher order entities when deleting elements. This...

Update TD incidences of higher order entities when deleting elements. This issue always occurred when deleting the last element.
Thanks to Xiaoming Fu for making me aware of this problem.

git-svn-id: http://www.openvolumemesh.org/svnrepo/OpenVolumeMesh/trunk@224 66977474-1d4b-4f09-8fe9-267525286df2
parent b462a00b
......@@ -589,8 +589,8 @@ VertexIter TopologyKernel::delete_vertex(const VertexHandle& _h) {
incident_edges.push(edge_handle(*he_it));
}
// Decrease all vertex handles that are greater than _h in all edge definitions
for(int i = _h.idx() + 1, end = n_vertices(); i < end; ++i) {
// Decrease all vertex handles >= _h in all edge definitions
for(int i = _h.idx(), end = n_vertices(); i < end; ++i) {
const std::vector<HalfEdgeHandle>& hes = outgoing_hes_per_vertex_[i];
for(std::vector<HalfEdgeHandle>::const_iterator he_it = hes.begin(),
he_end = hes.end(); he_it != he_end; ++he_it) {
......@@ -604,27 +604,6 @@ VertexIter TopologyKernel::delete_vertex(const VertexHandle& _h) {
}
}
// The following is obsolete code and may be deleted in future revisions
// // Decrease all vertex handles that are greater than _h in all edge definitions
// for(std::vector<std::vector<HalfEdgeHandle> >::iterator he_it = (outgoing_hes_per_vertex_.begin() + _h.idx() + 1),
// he_end = outgoing_hes_per_vertex_.end(); he_it != he_end; ++he_it) {
// for(std::vector<HalfEdgeHandle>::const_iterator it = he_it->begin(),
// end = he_it->end(); it != end; ++it) {
//
// if(it->idx() % 2 == 0) {
// VertexHandle vh = edge(edge_handle(*it)).from_vertex();
// if(vh.is_valid())
// edge(edge_handle(*it)).set_from_vertex(VertexHandle(vh.idx() - 1));
// } else {
// VertexHandle vh = edge(edge_handle(*it)).to_vertex();
// if(vh.is_valid())
// edge(edge_handle(*it)).set_to_vertex(VertexHandle(vh.idx() - 1));
// }
// }
// }
} else {
// Iterate over all edges
......@@ -731,11 +710,12 @@ EdgeIter TopologyKernel::delete_edge(const EdgeHandle& _h) {
incident_faces.push(face_handle(*hf_it));
}
// Decrease all half-edge handles > he in face definitions
// Decrease all half-edge handles > he and
// delete all half-edge handles == he in face definitions
// Get all faces that need updates
std::set<FaceHandle> update_faces;
for(std::vector<std::vector<HalfFaceHandle> >::const_iterator iit =
(incident_hfs_per_he_.begin() + halfedge_handle(_h, 1).idx() + 1),
(incident_hfs_per_he_.begin() + halfedge_handle(_h, 0).idx()),
iit_end = incident_hfs_per_he_.end(); iit != iit_end; ++iit) {
for(std::vector<HalfFaceHandle>::const_iterator it = iit->begin(),
end = iit->end(); it != end; ++it) {
......@@ -878,8 +858,9 @@ FaceIter TopologyKernel::delete_face(const FaceHandle& _h) {
}
// Decrease all half-face handles > _h in all cells
// and delete all half-face handles == _h
std::set<CellHandle> update_cells;
for(std::vector<CellHandle>::const_iterator c_it = (incident_cell_per_hf_.begin() + halfface_handle(_h, 1).idx() + 1),
for(std::vector<CellHandle>::const_iterator c_it = (incident_cell_per_hf_.begin() + halfface_handle(_h, 0).idx()),
c_end = incident_cell_per_hf_.end(); c_it != c_end; ++c_it) {
if(!c_it->is_valid()) continue;
update_cells.insert(*c_it);
......
......@@ -762,6 +762,178 @@ TEST_F(PolyhedralMeshBase, STLCompliance) {
std::for_each(mesh_.cells_begin(), mesh_.cells_end(), p);
}
TEST_F(PolyhedralMeshBase, DeleteLastVertexTestBU) {
generatePolyhedralMesh(mesh_);
for(OpenVolumeMesh::HalfEdgeIter he_it = mesh_.halfedges_begin();
he_it != mesh_.halfedges_end(); ++he_it) {
const VertexHandle& fromVertex = mesh_.halfedge(*he_it).from_vertex();
const VertexHandle& toVertex = mesh_.halfedge(*he_it).to_vertex();
EXPECT_LE(fromVertex.idx(), 11);
EXPECT_LE(toVertex.idx(), 11);
}
mesh_.delete_vertex(VertexHandle(11));
for(OpenVolumeMesh::HalfEdgeIter he_it = mesh_.halfedges_begin();
he_it != mesh_.halfedges_end(); ++he_it) {
const VertexHandle& fromVertex = mesh_.halfedge(*he_it).from_vertex();
const VertexHandle& toVertex = mesh_.halfedge(*he_it).to_vertex();
EXPECT_LE(fromVertex.idx(), 10);
EXPECT_LE(toVertex.idx(), 10);
}
}
TEST_F(PolyhedralMeshBase, DeleteLastEdgeTestBU) {
generatePolyhedralMesh(mesh_);
for(OpenVolumeMesh::HalfFaceIter f_it = mesh_.halffaces_begin();
f_it != mesh_.halffaces_end(); ++f_it) {
std::vector<HalfEdgeHandle> hes = mesh_.halfface(*f_it).halfedges();
for(std::vector<HalfEdgeHandle>::const_iterator he_it = hes.begin();
he_it != hes.end(); ++he_it) {
EXPECT_LE(he_it->idx(), 39);
}
}
mesh_.delete_edge(EdgeHandle(19));
for(OpenVolumeMesh::HalfFaceIter f_it = mesh_.halffaces_begin();
f_it != mesh_.halffaces_end(); ++f_it) {
std::vector<HalfEdgeHandle> hes = mesh_.halfface(*f_it).halfedges();
for(std::vector<HalfEdgeHandle>::const_iterator he_it = hes.begin();
he_it != hes.end(); ++he_it) {
EXPECT_LE(he_it->idx(), 37);
}
}
}
TEST_F(PolyhedralMeshBase, DeleteLastFaceTestBU) {
generatePolyhedralMesh(mesh_);
for(OpenVolumeMesh::CellIter c_it = mesh_.cells_begin();
c_it != mesh_.cells_end(); ++c_it) {
std::vector<HalfFaceHandle> hfs = mesh_.cell(*c_it).halffaces();
for(std::vector<HalfFaceHandle>::const_iterator hf_it = hfs.begin();
hf_it != hfs.end(); ++hf_it) {
EXPECT_LE(hf_it->idx(), 21);
EXPECT_LE(mesh_.opposite_halfface_handle(*hf_it).idx(), 21);
}
}
mesh_.delete_face(FaceHandle(10));
for(OpenVolumeMesh::CellIter c_it = mesh_.cells_begin();
c_it != mesh_.cells_end(); ++c_it) {
std::vector<HalfFaceHandle> hfs = mesh_.cell(*c_it).halffaces();
for(std::vector<HalfFaceHandle>::const_iterator hf_it = hfs.begin();
hf_it != hfs.end(); ++hf_it) {
EXPECT_LE(hf_it->idx(), 19);
EXPECT_LE(mesh_.opposite_halfface_handle(*hf_it).idx(), 19);
}
}
}
TEST_F(PolyhedralMeshBase, DeleteLastVertexTestNoBU) {
generatePolyhedralMesh(mesh_);
mesh_.enable_bottom_up_incidences(false);
for(OpenVolumeMesh::HalfEdgeIter he_it = mesh_.halfedges_begin();
he_it != mesh_.halfedges_end(); ++he_it) {
const VertexHandle& fromVertex = mesh_.halfedge(*he_it).from_vertex();
const VertexHandle& toVertex = mesh_.halfedge(*he_it).to_vertex();
EXPECT_LE(fromVertex.idx(), 11);
EXPECT_LE(toVertex.idx(), 11);
}
mesh_.delete_vertex(VertexHandle(11));
for(OpenVolumeMesh::HalfEdgeIter he_it = mesh_.halfedges_begin();
he_it != mesh_.halfedges_end(); ++he_it) {
const VertexHandle& fromVertex = mesh_.halfedge(*he_it).from_vertex();
const VertexHandle& toVertex = mesh_.halfedge(*he_it).to_vertex();
EXPECT_LE(fromVertex.idx(), 10);
EXPECT_LE(toVertex.idx(), 10);
}
}
TEST_F(PolyhedralMeshBase, DeleteLastEdgeTestNoBU) {
generatePolyhedralMesh(mesh_);
mesh_.enable_bottom_up_incidences(false);
for(OpenVolumeMesh::HalfFaceIter f_it = mesh_.halffaces_begin();
f_it != mesh_.halffaces_end(); ++f_it) {
std::vector<HalfEdgeHandle> hes = mesh_.halfface(*f_it).halfedges();
for(std::vector<HalfEdgeHandle>::const_iterator he_it = hes.begin();
he_it != hes.end(); ++he_it) {
EXPECT_LE(he_it->idx(), 39);
}
}
mesh_.delete_edge(EdgeHandle(19));
for(OpenVolumeMesh::HalfFaceIter f_it = mesh_.halffaces_begin();
f_it != mesh_.halffaces_end(); ++f_it) {
std::vector<HalfEdgeHandle> hes = mesh_.halfface(*f_it).halfedges();
for(std::vector<HalfEdgeHandle>::const_iterator he_it = hes.begin();
he_it != hes.end(); ++he_it) {
EXPECT_LE(he_it->idx(), 37);
}
}
}
TEST_F(PolyhedralMeshBase, DeleteLastFaceTestNoBU) {
generatePolyhedralMesh(mesh_);
mesh_.enable_bottom_up_incidences(false);
for(OpenVolumeMesh::CellIter c_it = mesh_.cells_begin();
c_it != mesh_.cells_end(); ++c_it) {
std::vector<HalfFaceHandle> hfs = mesh_.cell(*c_it).halffaces();
for(std::vector<HalfFaceHandle>::const_iterator hf_it = hfs.begin();
hf_it != hfs.end(); ++hf_it) {
EXPECT_LE(hf_it->idx(), 21);
EXPECT_LE(mesh_.opposite_halfface_handle(*hf_it).idx(), 21);
}
}
mesh_.delete_face(FaceHandle(10));
for(OpenVolumeMesh::CellIter c_it = mesh_.cells_begin();
c_it != mesh_.cells_end(); ++c_it) {
std::vector<HalfFaceHandle> hfs = mesh_.cell(*c_it).halffaces();
for(std::vector<HalfFaceHandle>::const_iterator hf_it = hfs.begin();
hf_it != hfs.end(); ++hf_it) {
EXPECT_LE(hf_it->idx(), 19);
EXPECT_LE(mesh_.opposite_halfface_handle(*hf_it).idx(), 19);
}
}
}
/*
* Hexahedral mesh tests
*/
......
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