Use BoxTree::GetFirstIntersecting in STLChart::ProjectNormal

This commit is contained in:
Matthias Hochsteger 2019-10-02 11:51:04 +02:00
parent 90c6f0256d
commit 85d7f5e628

View File

@ -832,31 +832,37 @@ STLTrigId STLChart :: ProjectNormal (Point<3> & p3d) const
int starttrig = 1;
if (inner_searchtree)
{
NgArray<STLTrigId> trigs;
starttrig = GetNChartT()+1;
Point<2> p2d = Project2d (p3d);
inner_searchtree->GetIntersecting(p2d, p2d, trigs);
for (STLTrigId i : trigs)
bool inside = false;
STLTrigId trignum;
inner_searchtree->GetFirstIntersecting(p2d, p2d, [&](auto i)
{
auto & trig = geometry->GetTriangle(i);
const Point<3> & c = trig.center;
if (quadfun.Eval(c) > sqr (trig.rad))
continue;
return false;
Point<3> p = p3d;
Vec<3> lam;
int err = trig.ProjectInPlain(geometry->GetPoints(), GetNormal(), p, lam);
bool inside = (err == 0 && lam(0) > -lamtol &&
int err = trig.ProjectInPlain(geometry->GetPoints(), GetNormal(), p, lam);
inside = (err == 0 && lam(0) > -lamtol &&
lam(1) > -lamtol && (1-lam(0)-lam(1)) > -lamtol);
if (inside)
{
trignum=i;
p3d = p;
return i;
return true;
}
}
return false;
});
if(inside)
return trignum;
}