fix stlchartboundary

This commit is contained in:
Christopher Lackner 2019-09-22 00:16:44 +02:00
parent 6ad36f73cb
commit 4de79f4ce6

View File

@ -1280,8 +1280,6 @@ bool STLBoundary :: TestSegChartNV(const Point3d & p1, const Point3d& p2,
// static int timerquick = NgProfiler::CreateTimer ("TestSegChartNV-searchtree");
// static int timer = NgProfiler::CreateTimer ("TestSegChartNV");
int nseg = NOSegments();
Point<2> p2d1 = chart->Project2d (p1);
Point<2> p2d2 = chart->Project2d (p2);
@ -1291,7 +1289,7 @@ bool STLBoundary :: TestSegChartNV(const Point3d & p1, const Point3d& p2,
Line2d l1 (p2d1, p2d2);
double eps = 1e-3;
double eps = 1e-6;
bool ok = true;
/*
@ -1303,7 +1301,8 @@ bool STLBoundary :: TestSegChartNV(const Point3d & p1, const Point3d& p2,
cout << "avg nseg = " << double(totnseg)/cnt << endl;
*/
if (searchtree)
// TODO: fix searchtree update
if (false)
{
// NgProfiler::RegionTimer reg(timerquick);
@ -1325,10 +1324,14 @@ bool STLBoundary :: TestSegChartNV(const Point3d & p1, const Point3d& p2,
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 && lam1 > eps && lam1 < 1-eps &&
lam2 > eps && lam2 < 1-eps)
if(!err && ((on1 && in2) || (on2 && in1)))
{
ok = false;
break;
}
@ -1338,10 +1341,8 @@ bool STLBoundary :: TestSegChartNV(const Point3d & p1, const Point3d& p2,
else
{
// NgProfiler::RegionTimer reg(timer);
for (int j = 1; j <= nseg; j++)
for(auto [i2, seg] : boundary_ht)
{
const STLBoundarySeg & seg = GetSegment(j);
if (seg.IsSmoothEdge()) continue;
if (!box2d.Intersect (seg.BoundingBox())) continue;
@ -1353,8 +1354,11 @@ bool STLBoundary :: TestSegChartNV(const Point3d & p1, const Point3d& p2,
int err = CrossPointBarycentric (l1, l2, lam1, lam2);
if (!err && lam1 > eps && lam1 < 1-eps &&
lam2 > eps && lam2 < 1-eps)
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;