From 30347e72101e1e081b3c969f49dc504e07f7dbb7 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Fri, 26 May 2017 13:58:43 +0200 Subject: [PATCH 1/4] fix edge split --- .../Mesh/TetrahedralMeshTopologyKernel.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/OpenVolumeMesh/Mesh/TetrahedralMeshTopologyKernel.cc b/src/OpenVolumeMesh/Mesh/TetrahedralMeshTopologyKernel.cc index 68f5243..eec10b5 100644 --- a/src/OpenVolumeMesh/Mesh/TetrahedralMeshTopologyKernel.cc +++ b/src/OpenVolumeMesh/Mesh/TetrahedralMeshTopologyKernel.cc @@ -429,19 +429,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)); -- GitLab From 4d50cc7389373f1510e492146e7d7579fc459be1 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Fri, 26 May 2017 13:59:05 +0200 Subject: [PATCH 2/4] fix comment --- src/OpenVolumeMesh/Core/TopologyKernel.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenVolumeMesh/Core/TopologyKernel.cc b/src/OpenVolumeMesh/Core/TopologyKernel.cc index 23c9093..d822b79 100644 --- a/src/OpenVolumeMesh/Core/TopologyKernel.cc +++ b/src/OpenVolumeMesh/Core/TopologyKernel.cc @@ -2074,7 +2074,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)]; -- GitLab From dfd4d3b7c97da309049b8f5918d3e6962e989b06 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Fri, 26 May 2017 14:00:23 +0200 Subject: [PATCH 3/4] ensure list of halffaces around a halfedge starts with a boundary face after deleting elements. --- src/OpenVolumeMesh/Core/TopologyKernel.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/OpenVolumeMesh/Core/TopologyKernel.cc b/src/OpenVolumeMesh/Core/TopologyKernel.cc index d822b79..a7bb453 100644 --- a/src/OpenVolumeMesh/Core/TopologyKernel.cc +++ b/src/OpenVolumeMesh/Core/TopologyKernel.cc @@ -330,7 +330,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; @@ -1230,6 +1234,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)); } } @@ -1390,6 +1396,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()) -- GitLab From 44f95107a618dd85ee4b4121b4ba98a2675a170c Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Wed, 12 Jun 2019 16:29:25 +0200 Subject: [PATCH 4/4] update changelog --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 5606312..fb727f1 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 -- GitLab