little modernization

This commit is contained in:
Joachim Schöberl 2019-07-28 23:22:47 +02:00
parent 168df170ec
commit f7fcc67fc7
3 changed files with 72 additions and 53 deletions

View File

@ -293,6 +293,11 @@ namespace netgen
size = nsize;
}
void SetSize0()
{
size = 0;
}
/// Change physical size. Keeps logical size. Keeps contents.
void SetAllocSize (size_t nallocsize)
{

View File

@ -53,13 +53,7 @@ namespace netgen
Meshing2 :: ~Meshing2 ()
{
// delete adfront;
/*
for (int i = 0; i < rules.Size(); i++)
delete rules[i];
*/
}
{ ; }
void Meshing2 :: AddPoint (const Point3d & p, PointIndex globind,
MultiPointGeomInfo * mgi,
@ -239,7 +233,6 @@ namespace netgen
int z1, z2, oldnp(-1);
bool found;
int rulenr(-1);
Point<3> p1, p2;
const PointGeomInfo * blgeominfo1;
const PointGeomInfo * blgeominfo2;
@ -247,8 +240,7 @@ namespace netgen
bool morerisc;
bool debugflag;
double h, his, hshould;
// double h;
NgArray<Point3d> locpoints;
NgArray<int> legalpoints;
@ -369,6 +361,10 @@ namespace netgen
NgProfiler::StopTimer (ts3);
static Timer tloop("surfacemeshing mainloop");
static Timer tgetlocals("surfacemeshing getlocals");
{
RegionTimer rloop(tloop);
while (!adfront.Empty() && !multithread.terminate)
{
NgProfiler::RegionTimer reg1 (timer1);
@ -384,13 +380,13 @@ namespace netgen
multithread.percent = 0;
*/
locpoints.SetSize(0);
loclines.SetSize(0);
pindex.SetSize(0);
lindex.SetSize(0);
delpoints.SetSize(0);
dellines.SetSize(0);
locelements.SetSize(0);
locpoints.SetSize0();
loclines.SetSize0();
pindex.SetSize0();
lindex.SetSize0();
delpoints.SetSize0();
dellines.SetSize0();
locelements.SetSize0();
@ -408,8 +404,8 @@ namespace netgen
// unique-pgi, multi-pgi
upgeominfo.SetSize(0);
mpgeominfo.SetSize(0);
upgeominfo.SetSize0();
mpgeominfo.SetSize0();
nfaces = adfront.GetNFL();
@ -428,27 +424,27 @@ namespace netgen
(*testout) << "\n";
}
Point<3> p1, p2;
int baselineindex = adfront.SelectBaseLine (p1, p2, blgeominfo1, blgeominfo2, qualclass);
found = 1;
his = Dist (p1, p2);
double his = Dist (p1, p2);
Point3d pmid = Center (p1, p2);
hshould = CalcLocalH (pmid, mesh.GetH (pmid));
Point<3> pmid = Center (p1, p2);
double hshould = CalcLocalH (pmid, mesh.GetH (pmid));
if (gh < hshould) hshould = gh;
mesh.RestrictLocalH (pmid, hshould);
h = hshould;
double h = hshould;
double hinner = (3 + qualclass) * max2 (his, hshould);
tgetlocals.Start();
adfront.GetLocals (baselineindex, locpoints, mpgeominfo, loclines,
pindex, lindex, 2*hinner);
tgetlocals.Stop();
NgProfiler::RegionTimer reg2 (timer2);
@ -535,6 +531,12 @@ namespace netgen
*testout << "3d points: " << endl << locpoints << endl;
}
for (size_t i = 0; i < locpoints.Size(); i++)
TransformToPlain (locpoints[i], mpgeominfo[i],
plainpoints[i], h, plainzones[i]);
/*
for (int i = 1; i <= locpoints.Size(); i++)
{
// (*testout) << "pindex(i) = " << pindex[i-1] << endl;
@ -545,6 +547,7 @@ namespace netgen
// (*testout) << plainpoints.Get(i).X() << " " << plainpoints.Get(i).Y() << endl;
//(*testout) << "transform " << locpoints.Get(i) << " to " << plainpoints.Get(i).X() << " " << plainpoints.Get(i).Y() << endl;
}
*/
// (*testout) << endl << endl << endl;
@ -671,31 +674,34 @@ namespace netgen
legalpoints.SetSize(plainpoints.Size());
legalpoints = 1;
/*
for (int i = 1; i <= legalpoints.Size(); i++)
legalpoints.Elem(i) = 1;
*/
double avy = 0;
for (int i = 1; i <= plainpoints.Size(); i++)
avy += plainpoints.Elem(i).Y();
for (size_t i = 0; i < plainpoints.Size(); i++)
avy += plainpoints[i].Y();
avy *= 1./plainpoints.Size();
for (int i = 1; i <= plainpoints.Size(); i++)
for (auto i : Range(plainpoints))
{
if (plainzones.Elem(i) < 0)
if (plainzones[i] < 0)
{
plainpoints.Elem(i) = Point2d (1e4, 1e4);
legalpoints.Elem(i) = 0;
plainpoints[i] = Point2d (1e4, 1e4);
legalpoints[i] = 0;
}
if (pindex.Elem(i) == -1)
if (pindex[i] == -1)
{
legalpoints.Elem(i) = 0;
legalpoints[i] = 0;
}
if (plainpoints.Elem(i).Y() < -1e-10*avy) // changed
if (plainpoints[i].Y() < -1e-10*avy) // changed
{
legalpoints.Elem(i) = 0;
legalpoints[i] = 0;
}
}
/*
@ -784,6 +790,8 @@ namespace netgen
if (found)
{
static Timer t("ApplyRules");
RegionTimer r(t);
rulenr = ApplyRules (plainpoints, legalpoints, maxlegalpoint,
loclines, maxlegalline, locelements,
dellines, qualclass, mp);
@ -1538,7 +1546,7 @@ namespace netgen
}
}
}
PrintMessage (3, "Surface meshing done");

View File

@ -668,11 +668,14 @@ namespace netgen
Meshing2OCCSurfaces meshing(TopoDS::Face(geom.fmap(k)), bb, projecttype, mparam);
tinit.Stop();
static Timer tprint("print");
tprint.Start();
if (meshing.GetProjectionType() == PLANESPACE)
PrintMessage (2, "Face ", k, " / ", mesh.GetNFD(), " (plane space projection)");
else
PrintMessage (2, "Face ", k, " / ", mesh.GetNFD(), " (parameter space projection)");
tprint.Stop();
if (surfmesherror)
cout << "Surface meshing error occurred before (in " << surfmesherror << " faces)" << endl;
@ -795,8 +798,11 @@ namespace netgen
// int noldpoints = mesh->GetNP();
int noldsurfel = mesh.GetNSE();
static Timer tsurfprop("surfprop");
tsurfprop.Start();
GProp_GProps sprops;
BRepGProp::SurfaceProperties(TopoDS::Face(geom.fmap(k)),sprops);
tsurfprop.Stop();
meshing.SetMaxArea(2.*sprops.Mass());
MESHING2_RESULT res;