Merge branch 'stable_parameter_projection' into 'master'

more stable occ parameter space projection

See merge request ngsolve/netgen!548
This commit is contained in:
Schöberl, Joachim 2023-01-16 20:58:00 +01:00
commit 8e8e0498e0
4 changed files with 34 additions and 14 deletions

View File

@ -817,6 +817,7 @@ public:
: BoxTree(box.PMin(), box.PMax())
{ }
void SetTolerance(double _tol) { tol = _tol; }
double GetTolerance() { return tol; }
size_t GetNLeaves()

View File

@ -79,12 +79,17 @@ namespace netgen
Meshing2 :: ~Meshing2 ()
{ ; }
void Meshing2 :: AddPoint (const Point3d & p, PointIndex globind,
MultiPointGeomInfo * mgi,
bool pointonsurface)
int Meshing2 :: AddPoint (const Point3d & p, PointIndex globind,
MultiPointGeomInfo * mgi,
bool pointonsurface)
{
//(*testout) << "add point " << globind << endl;
adfront.AddPoint (p, globind, mgi, pointonsurface);
return adfront.AddPoint (p, globind, mgi, pointonsurface);
}
PointIndex Meshing2 :: GetGlobalIndex(int pi) const
{
return adfront.GetGlobalIndex(pi);
}
void Meshing2 :: AddBoundaryElement (int i1, int i2,

View File

@ -66,8 +66,9 @@ public:
///
DLL_HEADER void AddPoint (const Point3d & p, PointIndex globind, MultiPointGeomInfo * mgi = NULL,
DLL_HEADER int AddPoint (const Point3d & p, PointIndex globind, MultiPointGeomInfo * mgi = NULL,
bool pointonsurface = true);
DLL_HEADER PointIndex GetGlobalIndex(int pi) const;
///
DLL_HEADER void AddBoundaryElement (INDEX i1, INDEX i2,

View File

@ -350,6 +350,14 @@ namespace netgen
uv_box.Add( {seg.epgeominfo[i].u, seg.epgeominfo[i].v } );
BoxTree<2> uv_tree(uv_box);
double tol = 1e99;
for(auto& seg : segments)
{
Point<2> p1 = { seg.epgeominfo[0].u, seg.epgeominfo[0].v };
Point<2> p2 = { seg.epgeominfo[1].u, seg.epgeominfo[1].v };
tol = min2(tol, Dist(p1, p2));
}
uv_tree.SetTolerance(0.9 * tol);
Array<int> found_points;
for(auto & seg : segments)
@ -368,15 +376,21 @@ namespace netgen
Point<2> uv = {gi[j].u, gi[j].v};
uv_tree.GetIntersecting(uv, uv, found_points);
if(found_points.Size())
locpnum[j] = found_points[0];
else
bool found = false;
for(auto& fp : found_points)
{
if(meshing.GetGlobalIndex(fp - 1) == seg[j])
{
locpnum[j] = fp;
found = true;
}
}
if(!found)
{
PointIndex pi = seg[j];
meshing.AddPoint (mesh.Point(pi), pi);
glob2loc[pi] = ++cntpt;
locpnum[j] = meshing.AddPoint (mesh.Point(pi), pi) + 1;
glob2loc[pi] = locpnum[j];
gis.Append (gi[j]);
locpnum[j] = gis.Size();
uv_tree.Insert(uv, locpnum[j]);
}
}
@ -391,11 +405,10 @@ namespace netgen
auto gi = occface.Project(mesh[pi]);
MultiPointGeomInfo mgi;
mgi.AddPointGeomInfo(gi);
meshing.AddPoint(mesh[pi], pi, &mgi);
glob2loc[pi] = meshing.AddPoint(mesh[pi], pi, &mgi) + 1;
gis.Append(gi);
Point<2> uv = { gi.u, gi.v };
uv_tree.Insert(uv, gis.Size());
glob2loc[pi] = ++cntpt;
uv_tree.Insert(uv, glob2loc[pi]);
}
}
}