pointsearch in 2D

This commit is contained in:
Joachim Schoeberl 2011-08-11 16:13:35 +00:00
parent 5733e491fe
commit 1312e1d1da

View File

@ -4079,40 +4079,62 @@ namespace netgen
PrintMessage (4, "Rebuild element searchtree"); PrintMessage (4, "Rebuild element searchtree");
if (elementsearchtree) delete elementsearchtree;
delete elementsearchtree;
elementsearchtree = NULL; elementsearchtree = NULL;
Box3d box; Box3d box;
int i, j; int ne = (dimension == 2) ? GetNSE() : GetNE();
int ne = GetNE();
if (!ne) if (!ne)
{ {
lock.UnLock(); lock.UnLock();
return; return;
} }
box.SetPoint (Point (VolumeElement(1).PNum(1))); if (dimension == 2)
for (i = 1; i <= ne; i++)
{ {
const Element & el = VolumeElement(i); box.SetPoint (Point (SurfaceElement(1).PNum(1)));
for (j = 1; j <= el.GetNP(); j++) for (int i = 1; i <= ne; i++)
box.AddPoint (Point (el.PNum(j))); {
const Element2d & el = SurfaceElement(i);
for (int j = 1; j <= el.GetNP(); j++)
box.AddPoint (Point (el.PNum(j)));
}
box.Increase (1.01 * box.CalcDiam());
elementsearchtree = new Box3dTree (box.PMin(), box.PMax());
for (int i = 1; i <= ne; i++)
{
const Element2d & el = SurfaceElement(i);
box.SetPoint (Point (el.PNum(1)));
for (int j = 1; j <= el.GetNP(); j++)
box.AddPoint (Point (el.PNum(j)));
elementsearchtree -> Insert (box.PMin(), box.PMax(), i);
}
} }
else
box.Increase (1.01 * box.CalcDiam());
elementsearchtree = new Box3dTree (box.PMin(), box.PMax());
for (i = 1; i <= ne; i++)
{ {
const Element & el = VolumeElement(i); box.SetPoint (Point (VolumeElement(1).PNum(1)));
box.SetPoint (Point (el.PNum(1))); for (int i = 1; i <= ne; i++)
for (j = 1; j <= el.GetNP(); j++) {
box.AddPoint (Point (el.PNum(j))); const Element & el = VolumeElement(i);
for (int j = 1; j <= el.GetNP(); j++)
box.AddPoint (Point (el.PNum(j)));
}
box.Increase (1.01 * box.CalcDiam());
elementsearchtree = new Box3dTree (box.PMin(), box.PMax());
for (int i = 1; i <= ne; i++)
{
const Element & el = VolumeElement(i);
box.SetPoint (Point (el.PNum(1)));
for (int j = 1; j <= el.GetNP(); j++)
box.AddPoint (Point (el.PNum(j)));
elementsearchtree -> Insert (box.PMin(), box.PMax(), i); elementsearchtree -> Insert (box.PMin(), box.PMax(), i);
}
} }
elementsearchtreets = GetTimeStamp(); elementsearchtreets = GetTimeStamp();
@ -4501,8 +4523,10 @@ namespace netgen
return ps_startelement; return ps_startelement;
Array<int> locels; Array<int> locels;
if (0) if (elementsearchtree || build_searchtree)
{ {
// update if necessary:
const_cast<Mesh&>(*this).BuildElementSearchTree ();
elementsearchtree->GetIntersecting (p, p, locels); elementsearchtree->GetIntersecting (p, p, locels);
ne = locels.Size(); ne = locels.Size();
} }
@ -4513,7 +4537,7 @@ namespace netgen
{ {
int ii; int ii;
if (0) if (elementsearchtree)
ii = locels.Get(i); ii = locels.Get(i);
else else
ii = i; ii = i;