From c361d1712d954d751da63f44c4f1e27c77f8430a Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Wed, 23 Oct 2019 14:44:07 +0200 Subject: [PATCH] little cleanup in adfront2 --- libsrc/gprim/adtree.hpp | 8 ++++++++ libsrc/meshing/adfront2.cpp | 39 ++++++++++++++++++------------------- libsrc/meshing/meshing2.cpp | 8 ++++++++ 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/libsrc/gprim/adtree.hpp b/libsrc/gprim/adtree.hpp index 11db1d78..bff29157 100644 --- a/libsrc/gprim/adtree.hpp +++ b/libsrc/gprim/adtree.hpp @@ -904,6 +904,14 @@ public: GetFirstIntersecting(pmin, pmax, [&pis](auto pi) { pis.Append(pi); return false;}); } + void GetIntersecting(const Point & pmin, + const Point & pmax, + Array & pis) const + { + pis.SetSize0(); + GetFirstIntersecting(pmin, pmax, [&pis](auto pi) { pis.Append(pi); return false;}); + } + void Insert (const Box & box, T pi) { Insert (box.PMin(), box.PMax(), pi); diff --git a/libsrc/meshing/adfront2.cpp b/libsrc/meshing/adfront2.cpp index 62cd1580..fc858ca4 100644 --- a/libsrc/meshing/adfront2.cpp +++ b/libsrc/meshing/adfront2.cpp @@ -292,7 +292,7 @@ namespace netgen loclines.Append(lines[baselineindex].L()); lindex.Append(baselineindex); - NgArrayMem nearlines(0); + ArrayMem nearlines(0); NgArrayMem nearpoints(0); // dominating costs !! @@ -300,14 +300,14 @@ namespace netgen p0 + Vec3d(xh, xh, xh), nearlines); - // only cone points, other points are from linesearchtree - cpointsearchtree.GetIntersecting (p0 - Vec3d(xh, xh, xh), - p0 + Vec3d(xh, xh, xh), - nearpoints); + // only special points that are not in adfront, + // other points are from linesearchtree + cpointsearchtree.GetIntersecting(p0 - Vec3d(xh, xh, xh), + p0 + Vec3d(xh, xh, xh), + nearpoints); - for (int ii = 0; ii < nearlines.Size(); ii++) + for(auto i : nearlines) { - int i = nearlines[ii]; if (lines[i].Valid() && i != baselineindex) { loclines.Append(lines[i].L()); @@ -318,38 +318,37 @@ namespace netgen // static NgArray invpindex; invpindex.SetSize (points.Size()); // invpindex = -1; - for (int i = 0; i < nearpoints.Size(); i++) - invpindex[nearpoints[i]] = -1; + for(auto pi : nearpoints) + invpindex[pi] = -1; - for (int i = 0; i < loclines.Size(); i++) + for(const auto& li : loclines) { - invpindex[loclines[i].I1()] = 0; - invpindex[loclines[i].I2()] = 0; + invpindex[li.I1()] = 0; + invpindex[li.I2()] = 0; } - for (int i = 0; i < loclines.Size(); i++) + for(auto& line : loclines) { - for (int j = 0; j < 2; j++) - { - int pi = loclines[i][j]; + for(auto i : Range(2)) + { + auto& pi = line[i]; if (invpindex[pi] == 0) { pindex.Append (pi); invpindex[pi] = pindex.Size(); locpoints.Append (points[pi].P()); - loclines[i][j] = locpoints.Size(); + pi = locpoints.Size(); } else - loclines[i][j] = invpindex[pi]; + pi = invpindex[pi]; } } // double xh2 = xh*xh; - for (int ii = 0; ii < nearpoints.Size(); ii++) + for(auto i : nearpoints) { - int i = nearpoints[ii]; if (points[i].Valid() && points[i].OnSurface() && // Dist2 (points.Get(i).P(), p0) <= xh2 && diff --git a/libsrc/meshing/meshing2.cpp b/libsrc/meshing/meshing2.cpp index f407e995..e4cabded 100644 --- a/libsrc/meshing/meshing2.cpp +++ b/libsrc/meshing/meshing2.cpp @@ -6,6 +6,14 @@ namespace netgen { + ostream& operator << (ostream& ost, const MultiPointGeomInfo& mpgi) + { + for(auto i : Range(mpgi.GetNPGI())) + { + ost << "gi[" << i << "] = " << mpgi.GetPGI(i+1) << endl; + } + return ost; + } static void glrender (int wait); #ifdef OPENGL extern DLL_HEADER void Render(bool blocking = false);