From e8286776df792a425c84964d5418778ce8316ff8 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Fri, 19 May 2023 14:45:56 +0200 Subject: [PATCH] hash-table with optional Get --- libsrc/general/hashtabl.hpp | 9 +++++++++ libsrc/meshing/bisect.cpp | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libsrc/general/hashtabl.hpp b/libsrc/general/hashtabl.hpp index 5ed31517..34c3f641 100644 --- a/libsrc/general/hashtabl.hpp +++ b/libsrc/general/hashtabl.hpp @@ -772,6 +772,15 @@ public: int pos = Position0 (ahash); return (pos != -1); } + + inline optional GetIfUsed (const INDEX_2 & ahash) const + { + int pos = Position0 (ahash); + if (pos != -1) + return cont[pos]; + else + return nullopt; + } inline void SetData0 (int pos, const INDEX_2 & ahash, const T & acont) { diff --git a/libsrc/meshing/bisect.cpp b/libsrc/meshing/bisect.cpp index 7f281f8e..0347814c 100644 --- a/libsrc/meshing/bisect.cpp +++ b/libsrc/meshing/bisect.cpp @@ -3279,10 +3279,16 @@ namespace netgen edge.Sort(); PointIndex newp; + /* if (cutedges.Used (edge)) { newp = cutedges.Get(edge); } + */ + if (auto optnewp = cutedges.GetIfUsed(edge)) + { + newp = *optnewp; + } else { Point<3> npt = Center (mesh.Point (edge.I1()), @@ -3296,7 +3302,6 @@ namespace netgen mtets.Elem(i) = newtet1; mtets.Append (newtet2); - mesh.mlparentelement.Append (i); } NgProfiler::StopTimer (timer_bisecttet);