diff --git a/CHANGELOG b/CHANGELOG index 56063123c93d7a23b4d006f6078c37b6966b8cd5..fb727f1ebc86c4809ac1b56495103896828ec392 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,8 @@ Version X (?/?/?) - Made property handle constructors explicit - Enable range iterators on MSVC - Fix mesh copying by implementing copy constructors and clone methods +- Fix bug in edge split of tetrahedral meshes +- Ensure that halfface iterators start with a boundary halffaces when cells are deleted diff --git a/src/OpenVolumeMesh/Core/TopologyKernel.cc b/src/OpenVolumeMesh/Core/TopologyKernel.cc index 5519eed4e9ea561d18ded84ed8ef89b9fae7210e..ff3c94c05ca8571e45c031997d720682ba68d5c5 100644 --- a/src/OpenVolumeMesh/Core/TopologyKernel.cc +++ b/src/OpenVolumeMesh/Core/TopologyKernel.cc @@ -314,7 +314,11 @@ void TopologyKernel::reorder_incident_halffaces(const EdgeHandle& _eh) { cur_hf = adjacent_halfface_in_cell(cur_hf, cur_he); if(cur_hf != InvalidHalfFaceHandle) + { + if (is_deleted(incident_cell(cur_hf))) + break; // pretend we ran into a boundary cur_hf = opposite_halfface_handle(cur_hf); + } // End when we're through if(cur_hf == start_hf) break; @@ -1229,6 +1233,8 @@ FaceIter TopologyKernel::delete_face_core(const FaceHandle& _h) { std::remove(incident_hfs_per_he_[opposite_halfedge_handle(*he_it).idx()].begin(), incident_hfs_per_he_[opposite_halfedge_handle(*he_it).idx()].end(), halfface_handle(h, 1)), incident_hfs_per_he_[opposite_halfedge_handle(*he_it).idx()].end()); + + reorder_incident_halffaces(edge_handle(*he_it)); } } @@ -1389,6 +1395,15 @@ CellIter TopologyKernel::delete_cell_core(const CellHandle& _h) { if (incident_cell_per_hf_[hf_it->idx()] == h) incident_cell_per_hf_[hf_it->idx()] = InvalidCellHandle; } + std::set edges; + for(std::vector::const_iterator hf_it = hfs.begin(), + hf_end = hfs.end(); hf_it != hf_end; ++hf_it) { + const auto& hf = halfface(*hf_it); + for (const auto& heh : hf.halfedges()) + edges.insert(edge_handle(heh)); + } + for (auto eh : edges) + reorder_incident_halffaces(eh); } if (deferred_deletion_enabled()) @@ -2074,7 +2089,7 @@ OpenVolumeMeshFace TopologyKernel::halfface(const HalfFaceHandle& _halfFaceHandl assert((size_t)_halfFaceHandle.idx() < (faces_.size() * 2)); assert(_halfFaceHandle.idx() >= 0); - // In case the handle is not even, just return the corresponding face + // In case the handle is even, just return the corresponding face // Otherwise return the opposite halfface via opposite() if(_halfFaceHandle.idx() % 2 == 0) return faces_[(int)(_halfFaceHandle.idx() / 2)]; diff --git a/src/OpenVolumeMesh/Mesh/TetrahedralMeshTopologyKernel.cc b/src/OpenVolumeMesh/Mesh/TetrahedralMeshTopologyKernel.cc index 1967a488566e0e7a08568047670567224c2699f3..f70e21cd1536becc237ce285ad93d76a8e625321 100644 --- a/src/OpenVolumeMesh/Mesh/TetrahedralMeshTopologyKernel.cc +++ b/src/OpenVolumeMesh/Mesh/TetrahedralMeshTopologyKernel.cc @@ -406,19 +406,24 @@ void TetrahedralMeshTopologyKernel::split_edge(HalfEdgeHandle _heh, VertexHandle if (!deferred_deletion_tmp) enable_deferred_deletion(true); + std::vector incident_halffaces_with_cells; for (HalfEdgeHalfFaceIter hehf_it = hehf_iter(_heh); hehf_it.valid(); ++hehf_it) { CellHandle ch = incident_cell(*hehf_it); if (ch.is_valid()) - { - std::vector vertices = get_cell_vertices(*hehf_it, _heh); + incident_halffaces_with_cells.push_back(*hehf_it); + } - delete_cell(ch); + for (auto hfh : incident_halffaces_with_cells) + { + CellHandle ch = incident_cell(hfh); - add_cell(vertices[0], _vh, vertices[2], vertices[3]); - add_cell(_vh, vertices[1], vertices[2], vertices[3]); - } + std::vector vertices = get_cell_vertices(hfh, _heh); + + delete_cell(ch); + add_cell(vertices[0], _vh, vertices[2], vertices[3]); + add_cell(_vh, vertices[1], vertices[2], vertices[3]); } delete_edge(edge_handle(_heh));