mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-27 06:10:34 +05:00
Use BoxTree::GetFirstIntersecting
This commit is contained in:
parent
7ced41e56f
commit
8bfccdf1df
@ -1349,18 +1349,13 @@ bool STLBoundary :: TestSegChartNV(const Point3d & p1, const Point3d& p2,
|
|||||||
Line2d l1 (p2d1, p2d2);
|
Line2d l1 (p2d1, p2d2);
|
||||||
|
|
||||||
double eps = 1e-6;
|
double eps = 1e-6;
|
||||||
bool ok = true;
|
|
||||||
|
|
||||||
if (searchtree)
|
auto hasIntersection = [&] (auto i2) NETGEN_LAMBDA_INLINE
|
||||||
{
|
|
||||||
NgArrayMem<INDEX_2,100> pis;
|
|
||||||
searchtree -> GetIntersecting (box2d.PMin(), box2d.PMax(), pis);
|
|
||||||
for (auto i2 : pis)
|
|
||||||
{
|
{
|
||||||
const STLBoundarySeg & seg = boundary_ht[i2];
|
const STLBoundarySeg & seg = boundary_ht[i2];
|
||||||
|
|
||||||
if (seg.IsSmoothEdge()) continue;
|
if (seg.IsSmoothEdge()) return false;
|
||||||
if (!box2d.Intersect (seg.BoundingBox())) continue;
|
if (!box2d.Intersect (seg.BoundingBox())) return false;
|
||||||
|
|
||||||
const Point<2> & sp1 = seg.P2D1();
|
const Point<2> & sp1 = seg.P2D1();
|
||||||
const Point<2> & sp2 = seg.P2D2();
|
const Point<2> & sp2 = seg.P2D2();
|
||||||
@ -1375,42 +1370,28 @@ bool STLBoundary :: TestSegChartNV(const Point3d & p1, const Point3d& p2,
|
|||||||
bool on2 = (lam2 > -eps) && (lam2 < 1 + eps);
|
bool on2 = (lam2 > -eps) && (lam2 < 1 + eps);
|
||||||
|
|
||||||
if(!err && ((on1 && in2) || (on2 && in1)))
|
if(!err && ((on1 && in2) || (on2 && in1)))
|
||||||
{
|
return true;
|
||||||
ok = false;
|
return false;
|
||||||
break;
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (searchtree)
|
||||||
|
{
|
||||||
|
bool has_intersection = false;
|
||||||
|
searchtree -> GetFirstIntersecting (box2d.PMin(), box2d.PMax(),
|
||||||
|
[&] (auto i2) NETGEN_LAMBDA_INLINE
|
||||||
|
{
|
||||||
|
has_intersection = hasIntersection(i2);
|
||||||
|
return has_intersection;
|
||||||
|
});
|
||||||
|
return !has_intersection;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(auto [i2, seg] : boundary_ht)
|
for(auto [i2, seg] : boundary_ht)
|
||||||
{
|
if(hasIntersection(i2))
|
||||||
if (seg.IsSmoothEdge()) continue;
|
return false;
|
||||||
if (!box2d.Intersect (seg.BoundingBox())) continue;
|
return true;
|
||||||
|
|
||||||
const Point<2> & sp1 = seg.P2D1();
|
|
||||||
const Point<2> & sp2 = seg.P2D2();
|
|
||||||
|
|
||||||
Line2d l2 (sp1, sp2);
|
|
||||||
double lam1, lam2;
|
|
||||||
|
|
||||||
int err = CrossPointBarycentric (l1, l2, lam1, lam2);
|
|
||||||
|
|
||||||
bool in1 = (lam1 > eps) && (lam1 < 1-eps);
|
|
||||||
bool on1 = (lam1 > -eps) && (lam1 < 1 + eps);
|
|
||||||
bool in2 = (lam2 > eps) && (lam2 < 1-eps);
|
|
||||||
bool on2 = (lam2 > -eps) && (lam2 < 1 + eps);
|
|
||||||
if(!err && ((on1 && in2) || (on2 && in1)))
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user