From 2291221719925ba58174b795133ce394a4486df1 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Sat, 28 Dec 2024 00:11:26 +0100 Subject: [PATCH] fixes for PointIndex::BASE=0 --- libsrc/geom2d/genmesh2d.cpp | 6 +++--- libsrc/meshing/bisect.cpp | 4 ++-- libsrc/meshing/meshclass.cpp | 8 ++++---- libsrc/meshing/meshtype.hpp | 2 ++ libsrc/meshing/topology.cpp | 8 ++++---- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/libsrc/geom2d/genmesh2d.cpp b/libsrc/geom2d/genmesh2d.cpp index b31fe042..54f624d0 100644 --- a/libsrc/geom2d/genmesh2d.cpp +++ b/libsrc/geom2d/genmesh2d.cpp @@ -278,7 +278,7 @@ namespace netgen mesh2d.AddLockedPoint(npi); Element0d el(npi, npi); el.name = point.name; - mesh2d.SetCD2Name(npi, point.name); + mesh2d.SetCD2Name(npi-IndexBASE()+1, point.name); mesh2d.pointelements.Append (el); searchtree.Insert (newp, npi); } @@ -303,9 +303,9 @@ namespace netgen npi = mesh2d.AddPoint (newp, layer); searchtree.Insert (newp, npi); mesh2d.AddLockedPoint(npi); - Element0d el(npi, npi); + Element0d el(npi, npi-IndexBASE()+1); el.name = ""; - mesh2d.SetCD2Name(npi, ""); + mesh2d.SetCD2Name(npi-IndexBASE()+1, ""); mesh2d.pointelements.Append (el); } } diff --git a/libsrc/meshing/bisect.cpp b/libsrc/meshing/bisect.cpp index d7a4062d..038e30af 100644 --- a/libsrc/meshing/bisect.cpp +++ b/libsrc/meshing/bisect.cpp @@ -3495,8 +3495,8 @@ namespace netgen } else { - Point<3> npt = Center (mesh.Point (edge.I1()), - mesh.Point (edge.I2())); + Point<3> npt = Center (mesh.Point (edge[0]), + mesh.Point (edge[1])); newp = mesh.AddPoint (npt); cutedges.Set (edge, newp); geo.PointBetween (mesh.Point (oldpi1), mesh.Point (oldpi2), diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 77bbc67b..02dccf0e 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -4075,7 +4075,7 @@ namespace netgen */ for (int i = 0; i < volelements.Size(); i++) - if (volelements[i][0] <= PointIndex::BASE-1 || + if (!volelements[i][0].IsValid() || volelements[i].IsDeleted()) { volelements.DeleteElement(i); @@ -4091,7 +4091,7 @@ namespace netgen } for (int i = 0; i < segments.Size(); i++) - if (segments[i][0] <= PointIndex::BASE-1) + if (!segments[i][0].IsValid()) { segments.DeleteElement(i); i--; @@ -7010,8 +7010,8 @@ namespace netgen for (int i = mlold+PointIndex::BASE; i < np+PointIndex::BASE; i++) { - mlbetweennodes[i].I1() = PointIndex::BASE-1; - mlbetweennodes[i].I2() = PointIndex::BASE-1; + mlbetweennodes[i][0].Invalidate(); + mlbetweennodes[i][1].Invalidate(); } GetIdentifications().SetMaxPointNr (np + PointIndex::BASE-1); diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index 92026a60..97848e86 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -194,6 +194,8 @@ namespace netgen } */ + + // #define BASE0 class PointIndex { diff --git a/libsrc/meshing/topology.cpp b/libsrc/meshing/topology.cpp index c35e0a21..bf953140 100644 --- a/libsrc/meshing/topology.cpp +++ b/libsrc/meshing/topology.cpp @@ -480,15 +480,15 @@ namespace netgen // for (int i = mesh->mlbetweennodes.Begin(); i < mesh->mlbetweennodes.End(); i++) for (int i : mesh->mlbetweennodes.Range()) { - INDEX_2 parents = Sort (mesh->mlbetweennodes[i]); - if (parents[0] >= PointIndex::BASE) cnt[parents[0]]++; + PointIndices<2> parents = Sort (mesh->mlbetweennodes[i]); + if (parents[0].IsValid()) cnt[parents[0]]++; } TABLE vert2vertcoarse (cnt); // for (int i = mesh->mlbetweennodes.Begin(); i < mesh->mlbetweennodes.End(); i++) for (int i : mesh->mlbetweennodes.Range()) { - INDEX_2 parents = Sort (mesh->mlbetweennodes[i]); - if (parents[0] >= PointIndex::BASE) vert2vertcoarse.AddSave (parents[0], parents[1]); + PointIndices<2> parents = Sort (mesh->mlbetweennodes[i]); + if (parents[0].IsValid()) vert2vertcoarse.AddSave (parents[0], parents[1]); }