From abe18a9b74eb40e3f4996a536d08d8a56420b875 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Tue, 24 Dec 2024 00:52:38 +0100 Subject: [PATCH] little polish --- libsrc/general/ngbitarray.hpp | 5 ++--- libsrc/gprim/geomobjects.hpp | 2 -- libsrc/meshing/adfront2.hpp | 4 ++-- libsrc/meshing/delaunay.cpp | 18 +++++++++--------- libsrc/meshing/delaunay2d.cpp | 4 ++-- libsrc/meshing/localh.cpp | 28 ++++++++++++++-------------- libsrc/meshing/localh.hpp | 8 ++++---- libsrc/meshing/meshclass.cpp | 21 ++++++++++++++++++++- libsrc/meshing/meshing3.cpp | 10 +++++----- libsrc/meshing/meshing3.hpp | 2 +- 10 files changed, 59 insertions(+), 43 deletions(-) diff --git a/libsrc/general/ngbitarray.hpp b/libsrc/general/ngbitarray.hpp index e4f145b5..15295593 100644 --- a/libsrc/general/ngbitarray.hpp +++ b/libsrc/general/ngbitarray.hpp @@ -29,11 +29,10 @@ class NgBitArray public: - [[ deprecated ("use BitArray instead")]] + // [[ deprecated ("use BitArray instead")]] DLL_HEADER NgBitArray (); /// - [[ deprecated ("use BitArray instead")]] - + // [[ deprecated ("use BitArray instead")]] DLL_HEADER NgBitArray (INDEX asize); /// DLL_HEADER ~NgBitArray (); diff --git a/libsrc/gprim/geomobjects.hpp b/libsrc/gprim/geomobjects.hpp index f675794a..5e8e0318 100644 --- a/libsrc/gprim/geomobjects.hpp +++ b/libsrc/gprim/geomobjects.hpp @@ -341,8 +341,6 @@ namespace netgen pmin(i) = 1e99; pmax(i) = -1e99; } - // pmin = Point (1e99, 1e99, 1e99); - // pmax = Point (-1e99, -1e99, -1e99); } const Point & PMin () const { return pmin; } diff --git a/libsrc/meshing/adfront2.hpp b/libsrc/meshing/adfront2.hpp index 081aaa25..a6364827 100644 --- a/libsrc/meshing/adfront2.hpp +++ b/libsrc/meshing/adfront2.hpp @@ -210,8 +210,8 @@ public: /// int GetNFL () const { return nfl; } - const FrontLine & GetLine (int nr) { return lines[nr]; } - const FrontPoint2 & GetPoint (int nr) { return points[nr]; } + const FrontLine & GetLine (int nr) const { return lines[nr]; } + const FrontPoint2 & GetPoint (int nr) const { return points[nr]; } const auto & GetLines () const { return lines; } /// diff --git a/libsrc/meshing/delaunay.cpp b/libsrc/meshing/delaunay.cpp index 1f583abd..aa9a0536 100644 --- a/libsrc/meshing/delaunay.cpp +++ b/libsrc/meshing/delaunay.cpp @@ -562,7 +562,7 @@ namespace netgen - void Delaunay1 (Mesh & mesh, int domainnr, const MeshingParameters & mp, AdFront3 * adfront, + void Delaunay1 (Mesh & mesh, int domainnr, const MeshingParameters & mp, const AdFront3 & adfront, NgArray & tempels, int oldnp, DelaunayTet & startel, Point3d & pmin, Point3d & pmax) { @@ -573,7 +573,7 @@ namespace netgen Box<3> bbox(Box<3>::EMPTY_BOX); - for (auto & face : adfront->Faces()) + for (auto & face : adfront.Faces()) for (PointIndex pi : face.Face().PNums()) bbox.Add (mesh.Point(pi)); @@ -610,7 +610,7 @@ namespace netgen Array usep(np); usep = false; - for (auto & face : adfront->Faces()) + for (auto & face : adfront.Faces()) for (PointIndex pi : face.Face().PNums()) usep[pi] = true; @@ -1088,7 +1088,7 @@ namespace netgen } } - void DelaunayRemoveOuter( const Mesh & mesh, NgArray & tempels, AdFront3 * adfront ) + void DelaunayRemoveOuter( const Mesh & mesh, NgArray & tempels, const AdFront3 & adfront ) { static Timer trem_outer("Delaunay - remove outer"); RegionTimer rt(trem_outer); @@ -1326,7 +1326,7 @@ namespace netgen Point3d ci = Center (p1, p2, p3, p4); - inside = adfront->Inside (ci); + inside = adfront.Inside (ci); /* cout << "startel: " << i << endl; @@ -1408,7 +1408,7 @@ namespace netgen // if (adfront->Inside (ci) != adfront->Inside (Center (ci, p1))) // cout << "ERROR: outer test unclear !!!" << endl; - if (inner.Test(i) != adfront->Inside (ci)) + if (inner.Test(i) != adfront.Inside (ci)) { /* cout << "ERROR: outer test wrong !!!" @@ -1436,7 +1436,7 @@ namespace netgen } - if (adfront->Inside(ci)) + if (adfront.Inside(ci)) outer.Clear(i); else outer.SetBit(i); @@ -1565,7 +1565,7 @@ namespace netgen int np = mesh.GetNP(); - Delaunay1 (mesh, domainnr, mp, adfront, tempels, oldnp, startel, pmin, pmax); + Delaunay1 (mesh, domainnr, mp, *adfront, tempels, oldnp, startel, pmin, pmax); { // improve delaunay - mesh by swapping !!!! @@ -1668,7 +1668,7 @@ namespace netgen NgArray openels; DelaunayRemoveTwoTriaTets(mesh, tempels, openels); DelaunayRemoveIntersecting(mesh, tempels, openels, pmin, pmax); - DelaunayRemoveOuter(mesh, tempels, adfront); + DelaunayRemoveOuter(mesh, tempels, *adfront); for (int i = 0; i < tempels.Size(); i++) { diff --git a/libsrc/meshing/delaunay2d.cpp b/libsrc/meshing/delaunay2d.cpp index 787fd7cc..8a58ba57 100644 --- a/libsrc/meshing/delaunay2d.cpp +++ b/libsrc/meshing/delaunay2d.cpp @@ -427,7 +427,7 @@ namespace netgen } tcut.Stop(); - mesh.LocalHFunction().FindInnerBoxes (&adfront, NULL); + mesh.LocalHFunction().FindInnerBoxes (adfront, NULL); npoints.SetSize(0); mesh.LocalHFunction().GetInnerPoints (npoints); @@ -521,7 +521,7 @@ namespace netgen loch2.CutBoundary (bbox); } - loch2.FindInnerBoxes (&adfront, NULL); + loch2.FindInnerBoxes (adfront, NULL); // outer points : smooth mesh-grading npoints.SetSize(0); diff --git a/libsrc/meshing/localh.cpp b/libsrc/meshing/localh.cpp index b8121b8f..ab9715d5 100644 --- a/libsrc/meshing/localh.cpp +++ b/libsrc/meshing/localh.cpp @@ -489,14 +489,14 @@ namespace netgen - void LocalH :: FindInnerBoxes (AdFront3 * adfront, + void LocalH :: FindInnerBoxes (const AdFront3 & adfront, int (*testinner)(const Point3d & p1)) { static Timer timer("LocalH::FindInnerBoxes"); RegionTimer reg (timer); - int nf = adfront->GetNF(); + int nf = adfront.GetNF(); for (int i = 0; i < boxes.Size(); i++) boxes[i] -> flags.isinner = 0; @@ -509,7 +509,7 @@ namespace netgen // Point3d rx1 = rpmid - rv; - root->flags.pinner = !adfront->SameSide (rpmid, rx2); + root->flags.pinner = !adfront.SameSide (rpmid, rx2); if (testinner) (*testout) << "inner = " << root->flags.pinner << " =?= " @@ -521,7 +521,7 @@ namespace netgen for (int i = 1; i <= nf; i++) { faceinds.Elem(i) = i; - adfront->GetFaceBoundingBox(i, faceboxes.Elem(i)); + adfront.GetFaceBoundingBox(i, faceboxes.Elem(i)); } for (int i = 0; i < 8; i++) @@ -531,7 +531,7 @@ namespace netgen void LocalH :: FindInnerBoxesRec2 (GradingBox * box, - class AdFront3 * adfront, + const AdFront3 & adfront, NgArray & faceboxes, NgArray & faceinds, int nfinbox) { @@ -592,7 +592,7 @@ namespace netgen box->flags.pinner = 1; else { - if (adfront->SameSide (c, cf, &faceused2)) + if (adfront.SameSide (c, cf, &faceused2)) box->flags.pinner = father->flags.pinner; else box->flags.pinner = 1 - father->flags.pinner; @@ -644,7 +644,7 @@ namespace netgen - void LocalH :: FindInnerBoxes (AdFront2 * adfront, + void LocalH :: FindInnerBoxes (const AdFront2 & adfront, int (*testinner)(const Point<2> & p1)) { static Timer t("LocalH::FindInnerBoxes 2d"); RegionTimer reg (t); @@ -667,23 +667,23 @@ namespace netgen // Point<2> rx1 = rpmid - rv; - root->flags.pinner = !adfront->SameSide (rpmid, rx2); + root->flags.pinner = !adfront.SameSide (rpmid, rx2); if (testinner) (*testout) << "inner = " << root->flags.pinner << " =?= " << testinner(rpmid) << endl; - int nf = adfront->GetNFL(); + int nf = adfront.GetNFL(); Array faceinds(nf); Array> faceboxes(nf); for (int i = 0; i < nf; i++) { faceinds[i] = i; - const FrontLine & line = adfront->GetLine(i); - Point<3> p1 = adfront->GetPoint (line.L().I1()); - Point<3> p2 = adfront->GetPoint (line.L().I2()); + const FrontLine & line = adfront.GetLine(i); + Point<3> p1 = adfront.GetPoint (line.L().I1()); + Point<3> p2 = adfront.GetPoint (line.L().I2()); faceboxes[i].Set (Point<2> (p1(0), p1(1))); faceboxes[i].Add (Point<2> (p2(0), p2(1))); @@ -697,7 +697,7 @@ namespace netgen void LocalH :: FindInnerBoxesRec2 (GradingBox * box, - class AdFront2 * adfront, + const class AdFront2 & adfront, FlatArray> faceboxes, FlatArray faceinds) // , int nfinbox) { @@ -743,7 +743,7 @@ namespace netgen // bool sameside = adfront->SameSide (c2d, cf2d, &faceused2); auto sub = faceinds.Range(0, iused); - bool sameside = adfront->SameSide (c, fc, &sub); + bool sameside = adfront.SameSide (c, fc, &sub); if (sameside) box->flags.pinner = father->flags.pinner; else diff --git a/libsrc/meshing/localh.hpp b/libsrc/meshing/localh.hpp index 979a7ec3..5671542a 100644 --- a/libsrc/meshing/localh.hpp +++ b/libsrc/meshing/localh.hpp @@ -121,10 +121,10 @@ namespace netgen { CutBoundaryRec (box.PMin(), box.PMax(), root); } /// find inner boxes - void FindInnerBoxes (class AdFront3 * adfront, + void FindInnerBoxes (const class AdFront3 & adfront, int (*testinner)(const Point3d & p1)); - void FindInnerBoxes (class AdFront2 * adfront, + void FindInnerBoxes (const class AdFront2 & adfront, int (*testinner)(const Point<2> & p1)); @@ -166,7 +166,7 @@ namespace netgen /// void FindInnerBoxesRec2 (GradingBox * box, - class AdFront3 * adfront, + const class AdFront3 & adfront, NgArray & faceboxes, NgArray & finds, int nfinbox); @@ -177,7 +177,7 @@ namespace netgen /// void FindInnerBoxesRec2 (GradingBox * box, - class AdFront2 * adfront, + const class AdFront2 & adfront, FlatArray> faceboxes, FlatArray finds); // , int nfinbox); diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index aa54fe3d..4e036170 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -2232,7 +2232,7 @@ namespace netgen cerr << "illegal element for buildboundaryedges" << endl; } - + /* for (int i = 0; i < openelements.Size(); i++) { const Element2d & sel = openelements[i]; @@ -2247,7 +2247,18 @@ namespace netgen points[sel[j]].SetType(FIXEDPOINT); } } + */ + for (const Element2d & sel : openelements) + for (int j = 0; j < sel.GetNP(); j++) + { + PointIndices<2> i2 { sel.PNumMod(j+1), sel.PNumMod(j+2) }; + i2.Sort(); + boundaryedges->Set (i2, 1); + points[sel[j]].SetType(FIXEDPOINT); + } + + /* for (int i = 0; i < GetNSeg(); i++) { const Segment & seg = segments[i]; @@ -2257,7 +2268,15 @@ namespace netgen boundaryedges -> Set (i2, 2); //segmentht -> Set (i2, i); } + */ + for (const Segment & seg : segments) + { + PointIndices<2> i2 { seg[0], seg[1] }; + i2.Sort(); + boundaryedges -> Set (i2, 2); + //segmentht -> Set (i2, i); + } } diff --git a/libsrc/meshing/meshing3.cpp b/libsrc/meshing/meshing3.cpp index 9d03f5b9..65c7edb4 100644 --- a/libsrc/meshing/meshing3.cpp +++ b/libsrc/meshing/meshing3.cpp @@ -24,7 +24,7 @@ Meshing3 :: Meshing3 (const string & rulefilename) tolfak = 1; LoadRules (rulefilename.c_str(), NULL); - adfront = new AdFront3; + adfront = make_unique(); problems.SetSize (rules.Size()); foundmap.SetSize (rules.Size()); @@ -46,7 +46,7 @@ Meshing3 :: Meshing3 (const char ** rulep) tolfak = 1; LoadRules (NULL, rulep); - adfront = new AdFront3; + adfront = make_unique(); problems.SetSize (rules.Size()); foundmap.SetSize (rules.Size()); @@ -64,7 +64,7 @@ Meshing3 :: Meshing3 (const char ** rulep) Meshing3 :: ~Meshing3 () { - delete adfront; + // delete adfront; for (int i = 0; i < rules.Size(); i++) { delete [] problems[i]; @@ -1185,7 +1185,7 @@ void Meshing3 :: BlockFillLocalH (Mesh & mesh, tbox.Stop(); // locadfront = adfront; - loch.FindInnerBoxes (adfront, NULL); + loch.FindInnerBoxes (*adfront, NULL); npoints.SetSize(0); loch.GetInnerPoints (npoints); @@ -1271,7 +1271,7 @@ void Meshing3 :: BlockFillLocalH (Mesh & mesh, tloch2.Stop(); // locadfront = adfront; - loch2.FindInnerBoxes (adfront, NULL); + loch2.FindInnerBoxes (*adfront, NULL); npoints.SetSize(0); loch2.GetOuterPoints (npoints); diff --git a/libsrc/meshing/meshing3.hpp b/libsrc/meshing/meshing3.hpp index 2289826b..36f8c142 100644 --- a/libsrc/meshing/meshing3.hpp +++ b/libsrc/meshing/meshing3.hpp @@ -22,7 +22,7 @@ enum MESHING3_RESULT class Meshing3 { /// current state of front - AdFront3 * adfront; + unique_ptr adfront; /// 3d generation rules NgArray rules; /// counts how often a rule is used