From ceddf31f87dc66da5d397a7bec86ae3c54ff7797 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Fri, 27 Dec 2024 18:05:04 +0100 Subject: [PATCH] PointIndex --- libsrc/csg/genmesh.cpp | 4 +-- libsrc/geom2d/genmesh2d.cpp | 12 ++++--- libsrc/interface/nginterface.cpp | 4 +-- libsrc/interface/writeabaqus.cpp | 4 +-- libsrc/interface/writetet.cpp | 8 ++--- libsrc/meshing/basegeom.cpp | 7 ++-- libsrc/meshing/improve2gen.cpp | 2 +- libsrc/meshing/improve3.cpp | 27 +++++++-------- libsrc/meshing/meshclass.cpp | 58 +++++++++++++++----------------- libsrc/meshing/meshing2.cpp | 4 +-- libsrc/meshing/meshtype.hpp | 8 ++--- libsrc/meshing/parallelmesh.cpp | 5 +-- libsrc/meshing/paralleltop.cpp | 2 +- libsrc/meshing/python_mesh.cpp | 10 +++--- libsrc/meshing/refine.cpp | 18 +++++----- libsrc/meshing/smoothing3.cpp | 2 +- libsrc/meshing/topology.cpp | 6 ++-- libsrc/meshing/validate.cpp | 8 ++--- 18 files changed, 95 insertions(+), 94 deletions(-) diff --git a/libsrc/csg/genmesh.cpp b/libsrc/csg/genmesh.cpp index c78efd8b..70d3f514 100644 --- a/libsrc/csg/genmesh.cpp +++ b/libsrc/csg/genmesh.cpp @@ -473,8 +473,8 @@ namespace netgen { PointGeomInfo gi; gi.trignum = k; - meshing.AddBoundaryElement (segments[si][0] + 1 - PointIndex::BASE, - segments[si][1] + 1 - PointIndex::BASE, + meshing.AddBoundaryElement (segments[si][0] + 1 - IndexBASE(), + segments[si][1] + 1 - IndexBASE(), gi, gi); } diff --git a/libsrc/geom2d/genmesh2d.cpp b/libsrc/geom2d/genmesh2d.cpp index 6d40bd0d..b31fe042 100644 --- a/libsrc/geom2d/genmesh2d.cpp +++ b/libsrc/geom2d/genmesh2d.cpp @@ -564,13 +564,17 @@ namespace netgen NgArray pts ( (nex+1) * (ney+1) ); // x ... inner loop pts = -1; - for (PointIndex pi = c1, i = 0; pi != c2; pi = nextpi[pi], i++) + int i = 0; + for (PointIndex pi = c1; pi != c2; pi = nextpi[pi], i++) pts[i] = pi; - for (PointIndex pi = c2, i = 0; pi != c3; pi = nextpi[pi], i++) + i = 0; + for (PointIndex pi = c2; pi != c3; pi = nextpi[pi], i++) pts[(nex+1)*i+nex] = pi; - for (PointIndex pi = c3, i = 0; pi != c4; pi = nextpi[pi], i++) + i = 0; + for (PointIndex pi = c3; pi != c4; pi = nextpi[pi], i++) pts[(nex+1)*(ney+1)-i-1] = pi; - for (PointIndex pi = c4, i = 0; pi != c1; pi = nextpi[pi], i++) + i = 0; + for (PointIndex pi = c4; pi != c1; pi = nextpi[pi], i++) pts[(nex+1)*(ney-i)] = pi; diff --git a/libsrc/interface/nginterface.cpp b/libsrc/interface/nginterface.cpp index ea66ef41..1e96cfdd 100644 --- a/libsrc/interface/nginterface.cpp +++ b/libsrc/interface/nginterface.cpp @@ -2240,7 +2240,7 @@ int Ng_GetClosureNodes (int nt, int nodenr, int nodeset, int * nodes) for (int i = 0; i < el.GetNP(); i++) { nodes[cnt++] = 0; - nodes[cnt++] = el[i] - PointIndex::BASE; + nodes[cnt++] = el[i] - IndexBASE(); } } @@ -2322,7 +2322,7 @@ int Ng_GetElementClosureNodes (int dim, int elementnr, int nodeset, int * nodes) for (int i = 0; i < el.GetNP(); i++) { nodes[cnt++] = 0; - nodes[cnt++] = el[i] - PointIndex::BASE; + nodes[cnt++] = el[i] - IndexBASE(); } } diff --git a/libsrc/interface/writeabaqus.cpp b/libsrc/interface/writeabaqus.cpp index 8799ef0f..34535a63 100644 --- a/libsrc/interface/writeabaqus.cpp +++ b/libsrc/interface/writeabaqus.cpp @@ -60,7 +60,7 @@ static void WritePoints ( const Mesh & mesh, ostream & out ) out << "*Node" << endl; for(auto pi : mesh.Points().Range() ) { - out << pi+1-PointIndex::BASE << ", "; + out << pi+1-IndexBASE() << ", "; auto p = mesh[pi]; out << p[0] << ", " << p[1] << ", " << p[2] << '\n'; } @@ -73,7 +73,7 @@ static void WriteElement(ostream & out, const Mesh& mesh, ElIndex ei, const vect auto el = mesh[ei]; out << el_counter; for(auto i : Range(el.PNums())) - out << ", " << el[permutation[i]]+1-PointIndex::BASE; + out << ", " << el[permutation[i]]+1-IndexBASE(); out << '\n'; } diff --git a/libsrc/interface/writetet.cpp b/libsrc/interface/writetet.cpp index 912a3fa4..ab1726bf 100644 --- a/libsrc/interface/writetet.cpp +++ b/libsrc/interface/writetet.cpp @@ -502,7 +502,7 @@ namespace netgen << mesh[i](0) << " " << mesh[i](1) << " " << mesh[i](2) << " " << id_type[i] << " "; - if(i-PointIndex::BASE < point_ids.Size()) + if(i-IndexBASE() < point_ids.Size()) outfile << point_ids[i]; else outfile << "0"; @@ -1066,13 +1066,13 @@ namespace netgen // for(PointIndex i = mesh.Points().Begin(); i < mesh.Points().End(); i++) for(PointIndex i : mesh.Points().Range()) { - if(i-PointIndex::BASE < point_ids.Size()) + if(i-IndexBASE() < point_ids.Size()) { if(uid_to_group_0D[point_ids[i]] >= 0) - groups[uid_to_group_0D[point_ids[i]]]->Append(i+1-PointIndex::BASE); + groups[uid_to_group_0D[point_ids[i]]]->Append(i+1-IndexBASE()); } else - groups[uid_to_group_0D[0]]->Append(i+1-PointIndex::BASE); + groups[uid_to_group_0D[0]]->Append(i+1-IndexBASE()); } diff --git a/libsrc/meshing/basegeom.cpp b/libsrc/meshing/basegeom.cpp index caafb7f6..c7aae2d5 100644 --- a/libsrc/meshing/basegeom.cpp +++ b/libsrc/meshing/basegeom.cpp @@ -584,16 +584,17 @@ namespace netgen Array vert2meshpt(vertices.Size()); vert2meshpt = PointIndex::INVALID; + for(auto & vert : vertices) { auto pi = mesh.AddPoint(vert->GetPoint(), vert->properties.layer); vert2meshpt[vert->nr] = pi; mesh[pi].Singularity(vert->properties.hpref); mesh[pi].SetType(FIXEDPOINT); - - Element0d el(pi, pi); + + Element0d el(pi, pi-IndexBASE()+1); el.name = vert->properties.GetName(); - mesh.SetCD3Name(pi, el.name); + mesh.SetCD3Name(pi-IndexBASE()+1, el.name); mesh.pointelements.Append (el); } diff --git a/libsrc/meshing/improve2gen.cpp b/libsrc/meshing/improve2gen.cpp index 6a5f1371..75e3fb14 100644 --- a/libsrc/meshing/improve2gen.cpp +++ b/libsrc/meshing/improve2gen.cpp @@ -342,7 +342,7 @@ namespace netgen possible = 1; for (int k = 0; k < rel.GetNP(); k++) - if (pmap.Elem(rel[k]) != -1 && + if (pmap.Elem(rel[k]).IsValid() && pmap.Elem(rel[k]) != el.PNumMod (k+elrot[i]+1)) possible = 0; diff --git a/libsrc/meshing/improve3.cpp b/libsrc/meshing/improve3.cpp index 13c90f1f..c081e6ba 100644 --- a/libsrc/meshing/improve3.cpp +++ b/libsrc/meshing/improve3.cpp @@ -1170,10 +1170,7 @@ double MeshOptimize3d :: SwapImproveEdge ( for (int k2 = 0; k2 < 4 && !newpi.IsValid(); k2++) if (nel[k2] == oldpi) { - newpi = - nel[0] + nel[1] + nel[2] + nel[3] - - pi1 - pi2 - oldpi; - + newpi = nel[0] - pi1 + nel[1] - pi2 + nel[2] - oldpi + nel[3]; tetused[k] = true; suroundpts[l] = newpi; } @@ -1830,7 +1827,7 @@ void MeshOptimize3d :: SwapImproveSurface ( int nsuround = hasbothpoints.Size(); int nsuroundother = hasbothpointsother.Size(); - NgArray < int > outerpoints(nsuround+1); + NgArray < PointIndex > outerpoints(nsuround+1); outerpoints[0] = sp1; for(int i=0; i 0) + if(mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][0].IsValid()) (*testout) << mesh[hasbothpoints[ii]][jj] << " between " << mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][0] << " and " << mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][1] << endl; @@ -1875,11 +1872,11 @@ void MeshOptimize3d :: SwapImproveSurface ( << "sel2 " << mesh[sel2] << endl; for(int ii=0; ii<3; ii++) { - if(mesh.mlbetweennodes[mesh[sel1][ii]][0] > 0) + if(mesh.mlbetweennodes[mesh[sel1][ii]][0].IsValid()) (*testout) << mesh[sel1][ii] << " between " << mesh.mlbetweennodes[mesh[sel1][ii]][0] << " and " << mesh.mlbetweennodes[mesh[sel1][ii]][1] << endl; - if(mesh.mlbetweennodes[mesh[sel2][ii]][0] > 0) + if(mesh.mlbetweennodes[mesh[sel2][ii]][0].IsValid()) (*testout) << mesh[sel2][ii] << " between " << mesh.mlbetweennodes[mesh[sel2][ii]][0] << " and " << mesh.mlbetweennodes[mesh[sel2][ii]][1] << endl; @@ -1887,7 +1884,7 @@ void MeshOptimize3d :: SwapImproveSurface ( } - NgArray < int > outerpointsother; + NgArray < PointIndex > outerpointsother; if(nsuroundother > 0) { @@ -1928,7 +1925,7 @@ void MeshOptimize3d :: SwapImproveSurface ( { (*testout) << mesh[hasbothpoints[ii]] << endl; for(int jj=0; jj 0) + if(mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][0].IsValid()) (*testout) << mesh[hasbothpoints[ii]][jj] << " between " << mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][0] << " and " << mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][1] << endl; @@ -1938,11 +1935,11 @@ void MeshOptimize3d :: SwapImproveSurface ( << "sel2 " << mesh[sel2] << endl; for(int ii=0; ii<3; ii++) { - if(mesh.mlbetweennodes[mesh[sel1][ii]][0] > 0) + if(mesh.mlbetweennodes[mesh[sel1][ii]][0].IsValid()) (*testout) << mesh[sel1][ii] << " between " << mesh.mlbetweennodes[mesh[sel1][ii]][0] << " and " << mesh.mlbetweennodes[mesh[sel1][ii]][1] << endl; - if(mesh.mlbetweennodes[mesh[sel2][ii]][0] > 0) + if(mesh.mlbetweennodes[mesh[sel2][ii]][0].IsValid()) (*testout) << mesh[sel2][ii] << " between " << mesh.mlbetweennodes[mesh[sel2][ii]][0] << " and " << mesh.mlbetweennodes[mesh[sel2][ii]][1] << endl; @@ -1954,7 +1951,7 @@ void MeshOptimize3d :: SwapImproveSurface ( { (*testout) << mesh[hasbothpointsother[ii]] << endl; for(int jj=0; jj 0) + if(mesh.mlbetweennodes[mesh[hasbothpointsother[ii]][jj]][0].IsValid()) (*testout) << mesh[hasbothpointsother[ii]][jj] << " between " << mesh.mlbetweennodes[mesh[hasbothpointsother[ii]][jj]][0] << " and " << mesh.mlbetweennodes[mesh[hasbothpointsother[ii]][jj]][1] << endl; @@ -1964,11 +1961,11 @@ void MeshOptimize3d :: SwapImproveSurface ( << "sel2other " << mesh[sel2other] << endl; for(int ii=0; ii<3; ii++) { - if(mesh.mlbetweennodes[mesh[sel1other][ii]][0] > 0) + if(mesh.mlbetweennodes[mesh[sel1other][ii]][0].IsValid()) (*testout) << mesh[sel1other][ii] << " between " << mesh.mlbetweennodes[mesh[sel1other][ii]][0] << " and " << mesh.mlbetweennodes[mesh[sel1other][ii]][1] << endl; - if(mesh.mlbetweennodes[mesh[sel2other][ii]][0] > 0) + if(mesh.mlbetweennodes[mesh[sel2other][ii]][0].IsValid()) (*testout) << mesh[sel2other][ii] << " between " << mesh.mlbetweennodes[mesh[sel2other][ii]][0] << " and " << mesh.mlbetweennodes[mesh[sel2other][ii]][1] << endl; diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index dd783130..77bbc67b 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -2867,7 +2867,7 @@ namespace netgen tval i2 = faceht.Get(i3); if (i2.index == el.GetIndex()) { - i2.index = PointIndex::BASE-1; + i2.index = long(PointIndex::BASE)-1; faceht.Set (i3, i2); } else @@ -2911,7 +2911,7 @@ namespace netgen faceht.GetData (i, i3, i2); if (i2.index != PointIndex::BASE-1) { - Element2d tri ( (i2.p4 == PointIndex::BASE-1) ? TRIG : QUAD); + Element2d tri ( (!i2.p4.IsValid()) ? TRIG : QUAD); for (int l = 0; l < 3; l++) tri[l] = i3.I(l+1); tri.PNum(4) = i2.p4; @@ -3323,7 +3323,7 @@ namespace netgen */ for (auto & el : VolumeElements()) { - if (el[0] == -1 || el.IsDeleted()) continue; + if (!el[0].IsValid() || el.IsDeleted()) continue; int elmin = large; for (int j = 0; j < el.GetNP(); j++) @@ -3346,7 +3346,7 @@ namespace netgen */ for (auto & el : VolumeElements()) { - if (el[0] == -1 || el.IsDeleted()) continue; + if (!el[0].IsValid() || el.IsDeleted()) continue; int elmin = large; for (int j = 0; j < el.GetNP(); j++) @@ -3363,8 +3363,8 @@ namespace netgen PrintMessage (5, "free: ", cntfree, ", fixed: ", GetNE()-cntfree); (*testout) << "free: " << cntfree << ", fixed: " << GetNE()-cntfree << endl; - for (PointIndex pi = PointIndex::BASE; - pi < GetNP()+PointIndex::BASE; pi++) + for (PointIndex pi = IndexBASE(); + pi < GetNP()+IndexBASE(); pi++) { if (dist[pi] > layers+1) points[pi].SetType(FIXEDPOINT); @@ -3664,18 +3664,16 @@ namespace netgen SetLocalH (pmin, pmax, grading, layer); } - PointIndex i,j; - double hl; + // double hl; - - for (i = PointIndex::BASE; - i < GetNP()+PointIndex::BASE; i++) + for (PointIndex i = IndexBASE(); + i < GetNP()+IndexBASE(); i++) { - for(j=i+1; j(); j++) { const Point3d & p1 = points[i]; const Point3d & p2 = points[j]; - hl = Dist(p1,p2); + double hl = Dist(p1,p2); RestrictLocalH(p1,hl); RestrictLocalH(p2,hl); //cout << "restricted h at " << p1 << " and " << p2 << " to " << hl << endl; @@ -3718,7 +3716,7 @@ namespace netgen continue; for (j = 1; j <= 3; j++) { - INDEX_2 i2(sel.PNumMod(j), sel.PNumMod(j+1)); + PointIndices<2> i2(sel.PNumMod(j), sel.PNumMod(j+1)); i2.Sort(); if (bedges.Used(i2)) continue; @@ -3728,22 +3726,22 @@ namespace netgen const Element2d & elother = SurfaceElement(other); - int pi3 = 1; - while ( (sel.PNum(pi3) == i2.I1()) || - (sel.PNum(pi3) == i2.I2())) - pi3++; - pi3 = sel.PNum(pi3); + int pi3_ = 1; + while ( (sel.PNum(pi3_) == i2[0]) || + (sel.PNum(pi3_) == i2[1])) + pi3_++; + PointIndex pi3 = sel.PNum(pi3_); - int pi4 = 1; - while ( (elother.PNum(pi4) == i2.I1()) || - (elother.PNum(pi4) == i2.I2())) - pi4++; - pi4 = elother.PNum(pi4); + int pi4_ = 1; + while ( (elother.PNum(pi4_) == i2[0]) || + (elother.PNum(pi4_) == i2[1])) + pi4_++; + PointIndex pi4 = elother.PNum(pi4_); - double rad = ComputeCylinderRadius (Point (PointIndex(i2.I1())), - Point (PointIndex(i2.I2())), - Point (PointIndex(pi3)), - Point (PointIndex(pi4))); + double rad = ComputeCylinderRadius (Point (i2[0]), + Point (i2[1]), + Point (pi3), + Point (pi4)); RestrictLocalHLine (Point(PointIndex(i2.I1())), Point(PointIndex(i2.I2())), rad/elperr); @@ -6634,8 +6632,8 @@ namespace netgen SurfaceElementIndex si = facedecoding[facenr-1].firstelement; while (si != -1) { - if ( (*this)[si].GetIndex () == facenr && (*this)[si][0] >= PointIndex::BASE && - !(*this)[si].IsDeleted() ) + if ( (*this)[si].GetIndex () == facenr && (*this)[si][0].IsValid() && + !(*this)[si].IsDeleted() ) { sei.Append (si); } diff --git a/libsrc/meshing/meshing2.cpp b/libsrc/meshing/meshing2.cpp index a1696143..c830ff28 100644 --- a/libsrc/meshing/meshing2.cpp +++ b/libsrc/meshing/meshing2.cpp @@ -541,8 +541,8 @@ namespace netgen // problem recognition ! if (found && - (gpi1 < illegalpoint.Size()+PointIndex::BASE) && - (gpi2 < illegalpoint.Size()+PointIndex::BASE) ) + (gpi1 < illegalpoint.Size()+IndexBASE()) && + (gpi2 < illegalpoint.Size()+IndexBASE()) ) { if (illegalpoint[gpi1] || illegalpoint[gpi2]) found = 0; diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index 46889487..92026a60 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -235,7 +235,7 @@ namespace netgen friend bool operator!= (PointIndex a, PointIndex b); */ public: - constexpr PointIndex (t_invalid inv) : i(PointIndex::BASE-1) { ; } + constexpr PointIndex (t_invalid inv) : i(long(PointIndex::BASE)-1) { ; } // PointIndex & operator= (const PointIndex &ai) { i = ai.i; return *this; } // private: constexpr operator const int& () const { return i; } @@ -246,8 +246,8 @@ namespace netgen PointIndex & operator++ () { i++; return *this; } PointIndex operator-- () { i--; return *this; } PointIndex operator+= (int add) { i += add; return *this; } - void Invalidate() { i = PointIndex::BASE-1; } - bool IsValid() const { return i != PointIndex::BASE-1; } + void Invalidate() { i = long(PointIndex::BASE)-1; } + bool IsValid() const { return i+1 != PointIndex::BASE; } // operator bool() const { return IsValid(); } #ifdef BASE0 static constexpr size_t BASE = 0; @@ -816,7 +816,7 @@ namespace netgen void Delete () { - deleted = 1; + deleted = true; // for (PointIndex & p : pnum) p.Invalidate(); } diff --git a/libsrc/meshing/parallelmesh.cpp b/libsrc/meshing/parallelmesh.cpp index a8b5b63b..767e8ca7 100644 --- a/libsrc/meshing/parallelmesh.cpp +++ b/libsrc/meshing/parallelmesh.cpp @@ -438,7 +438,8 @@ namespace netgen local vertex numbers on distant procs (I think this was only used for debugging??) **/ - for (int vert = 1; vert <= GetNP(); vert++ ) + // for (int vert = 1; vert <= GetNP(); vert++ ) + for (PointIndex vert : Points().Range()) { NgFlatArray procs = procs_of_vert[vert]; for (int j = 0; j < procs.Size(); j++) @@ -1017,7 +1018,7 @@ namespace netgen for (int vert = 0; vert < numvert; vert++) { - int globvert = verts[vert] + IndexBASE(); + PointIndex globvert = verts[vert] + IndexBASE(); // paralleltop->SetLoc2Glob_Vert ( vert+1, globvert ); paralleltop->L2G (PointIndex(vert+PointIndex::BASE)) = globvert; glob2loc_vert_ht.Set (globvert, vert+1); diff --git a/libsrc/meshing/paralleltop.cpp b/libsrc/meshing/paralleltop.cpp index 7462f5ad..17968129 100644 --- a/libsrc/meshing/paralleltop.cpp +++ b/libsrc/meshing/paralleltop.cpp @@ -93,7 +93,7 @@ namespace netgen comm.AllGather (num_master_points, first_master_point); auto max_oldv = comm.AllReduce (Max (glob_vert.Range(0, oldnv)), NG_MPI_MAX); if (comm.AllReduce (oldnv, NG_MPI_SUM) == 0) - max_oldv = PointIndex::BASE-1; + max_oldv = long(PointIndex::BASE)-1; size_t num_glob_points = max_oldv+1; for (int i = 0; i < comm.Size(); i++) diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index a9e6630d..3faa7d51 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -1561,7 +1561,7 @@ py::arg("point_tolerance") = -1.) { const auto & seg = segs[i]; for(auto k : Range(2)) - output[2*i+k] = seg[k]-PointIndex::BASE; + output[2*i+k] = seg[k]-IndexBASE(); } }); return output; }) @@ -1580,8 +1580,8 @@ py::arg("point_tolerance") = -1.) // PointIndex p0,p1; // topo.GetEdgeVertices(i+1, p0, p1); auto [p0,p1] = topo.GetEdgeVertices(i); - output[2*i] = p0-PointIndex::BASE; - output[2*i+1] = p1-PointIndex::BASE; + output[2*i] = p0-IndexBASE(); + output[2*i+1] = p1-IndexBASE(); } }); return output; }) @@ -1599,7 +1599,7 @@ py::arg("point_tolerance") = -1.) const auto & sel = surfels[i]; auto * trig = &trigs[3*i]; for(auto k : Range(3)) - trig[k] = sel[k]-PointIndex::BASE; + trig[k] = sel[k]-IndexBASE(); // todo: quads (store the second trig in thread-local extra array, merge them at the end (mutex) } }); return trigs; @@ -1617,7 +1617,7 @@ py::arg("point_tolerance") = -1.) const auto & el = els[i]; auto * trig = &tets[4*i]; for(auto k : Range(4)) - trig[k] = el[k]-PointIndex::BASE; + trig[k] = el[k]-IndexBASE(); // todo: prisms etc (store the extra tets in thread-local extra array, merge them at the end (mutex) } }); return tets; diff --git a/libsrc/meshing/refine.cpp b/libsrc/meshing/refine.cpp index b6b27369..8bbbb5ef 100644 --- a/libsrc/meshing/refine.cpp +++ b/libsrc/meshing/refine.cpp @@ -189,8 +189,8 @@ namespace netgen mesh.Point(pinew) = pnew; // between.Set (i2, pinew); - if (pinew >= epgi.Size()+PointIndex::BASE) - epgi.SetSize (pinew+1-PointIndex::BASE); + if (pinew >= epgi.Size()+IndexBASE()) + epgi.SetSize (pinew+1-IndexBASE()); epgi[pinew] = ngi; } @@ -208,7 +208,7 @@ namespace netgen PrintMessage (5, "have 1d elements"); // refine surface elements - NgArray surfgi (8*mesh.GetNP()); + Array surfgi (8*mesh.GetNP()); for (int i = PointIndex::BASE; i < surfgi.Size()+PointIndex::BASE; i++) surfgi[i].trignum = -1; @@ -273,9 +273,9 @@ namespace netgen between.Set (i2, pnums.Get(4+j)); } */ - if (surfgi.Size() < pnums.Elem(4+j)) - surfgi.SetSize (pnums.Elem(4+j)); - surfgi.Elem(pnums.Elem(4+j)) = pgis.Elem(4+j); + if (surfgi.Size() < pnums.Elem(4+j)-IndexBASE()+1) + surfgi.SetSize (pnums.Elem(4+j)-IndexBASE()+1); + surfgi[pnums.Elem(4+j)] = pgis.Elem(4+j); } @@ -356,9 +356,9 @@ namespace netgen mesh.Point(pinew) = pb; } - if (surfgi.Size() < pnums[4+j]) - surfgi.SetSize (pnums[4+j]); - surfgi.Elem(pnums[4+j]) = pgis[4+j]; + if (surfgi.Size() < pnums[4+j]-IndexBASE()+1) + surfgi.SetSize (pnums[4+j]-IndexBASE()+1); + surfgi[pnums[4+j]] = pgis[4+j]; } static int reftab[4][4] = diff --git a/libsrc/meshing/smoothing3.cpp b/libsrc/meshing/smoothing3.cpp index 0d8a1c5e..311b8315 100644 --- a/libsrc/meshing/smoothing3.cpp +++ b/libsrc/meshing/smoothing3.cpp @@ -1736,7 +1736,7 @@ void Mesh :: ImproveMeshJacobianOnSurface (const MeshingParameters & mp, { for(int j=0; brother == -1 && jSize(); j++) { - if(pi < (*used_idmaps)[j]->Size() + PointIndex::BASE) + if(pi < (*used_idmaps)[j]->Size() + IndexBASE()) { brother = (*(*used_idmaps)[j])[pi]; if(brother == pi || brother == 0) diff --git a/libsrc/meshing/topology.cpp b/libsrc/meshing/topology.cpp index e7a87032..c35e0a21 100644 --- a/libsrc/meshing/topology.cpp +++ b/libsrc/meshing/topology.cpp @@ -969,7 +969,7 @@ namespace netgen { PointIndex v0 = pa[k]; // also in face PointIndex v1 = pa[1-k]; - PointIndex v2 = f3[0]+f3[1]+f3[2] - v - v0; + PointIndex v2 = f3[0]-v+f3[1]-v0+f3[2]; // if there is an edge connecting v1 and v2, accept // the new face IVec<2> parentedge(v1, v2); @@ -1000,7 +1000,7 @@ namespace netgen { PointIndex v0 = pa[k]; // also in face PointIndex v1 = pa[1-k]; - PointIndex v2 = f3[0]+f3[1]+f3[2] - v - v0; + PointIndex v2 = f3[0]-v+f3[1]-v0+f3[2]; // if there is an edge connecting v1 and v2, accept // the new face IVec<2> parentedge(v1, v2); @@ -1428,7 +1428,7 @@ namespace netgen PointIndex v1 = parents[1-j]; // the third one, on the tip - PointIndex v2 = f3[0]+f3[1]+f3[2] - v0 - vb; + PointIndex v2 = f3[0]-v0+f3[1]-vb+f3[2]; // if there is an edge connecting v1 and v2, accept // the new face diff --git a/libsrc/meshing/validate.cpp b/libsrc/meshing/validate.cpp index 7e5dbe7d..c4214cc7 100644 --- a/libsrc/meshing/validate.cpp +++ b/libsrc/meshing/validate.cpp @@ -209,7 +209,7 @@ namespace netgen if(!isedgepoint.Test(sel.PNum(j))) { isboundarypoint.SetBit(sel.PNum(j)); - surfaceindex[sel.PNum(j) - PointIndex::BASE] = + surfaceindex[sel.PNum(j) - IndexBASE()] = mesh.GetFaceDescriptor(sel.GetIndex()).SurfNr(); } @@ -259,8 +259,8 @@ namespace netgen if(isnewpoint.Test(i+PointIndex::BASE) && //working_points.Test(i+PointIndex::BASE) && mesh.mlbetweennodes[i+PointIndex::BASE][0] > 0) - *can[i] = Center(*can[mesh.mlbetweennodes[i+PointIndex::BASE][0]-PointIndex::BASE], - *can[mesh.mlbetweennodes[i+PointIndex::BASE][1]-PointIndex::BASE]); + *can[i] = Center(*can[mesh.mlbetweennodes[i+PointIndex::BASE][0]-IndexBASE()], + *can[mesh.mlbetweennodes[i+PointIndex::BASE][1]-IndexBASE()]); else *can[i] = mesh.Point(i+1); } @@ -320,7 +320,7 @@ namespace netgen auxvec.Normalize(); for (int j = 1; j <= sel.GetNP(); j++) if(!isedgepoint.Test(sel.PNum(j))) - *nv[sel.PNum(j) - PointIndex::BASE] += auxvec; + *nv[sel.PNum(j) - IndexBASE()] += auxvec; } for(int i=0; iNormalize();