diff --git a/libsrc/geom2d/genmesh2d.cpp b/libsrc/geom2d/genmesh2d.cpp index 53c33e3b..582c59c7 100644 --- a/libsrc/geom2d/genmesh2d.cpp +++ b/libsrc/geom2d/genmesh2d.cpp @@ -238,6 +238,29 @@ namespace netgen } } + // first add all vertices (for compatible orientation on periodic bnds) + { + double diam2 = Dist2(pmin, pmax); + for (int i = 0; i < splines.Size(); i++) + for (int j : { 1, 2 }) + { + Point<2> hnewp = (j == 1) ? splines[i]->StartPI() : splines[i]->EndPI(); + Point<3> newp(hnewp(0), hnewp(1), 0); + int layer = GetSpline(i).layer; + int npi = -1; + for (PointIndex pi = PointIndex::BASE; + pi < mesh2d.GetNP()+PointIndex::BASE; pi++) + if (Dist2 (mesh2d.Point(pi), newp) < 1e-12 * diam2 && mesh2d.Point(pi).GetLayer() == layer) + npi = pi; + + if (npi == -1) + { + npi = mesh2d.AddPoint (newp, layer); + searchtree.Insert (newp, npi); + } + } + } + for (int i = 0; i < splines.Size(); i++) if (GetSpline(i).copyfrom == -1) {