|
|
@ -273,6 +273,8 @@ export function GetPointAtCurveDir(cu: Curve, pt: Vector3): boolean
|
|
|
|
if (cu instanceof Circle)
|
|
|
|
if (cu instanceof Circle)
|
|
|
|
return !cu.PtInCurve(pt);
|
|
|
|
return !cu.PtInCurve(pt);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: 当T字形多段线时,最近点将重叠,导致方向结果出错
|
|
|
|
|
|
|
|
|
|
|
|
//最近点
|
|
|
|
//最近点
|
|
|
|
let cp = cu.GetClosestPointTo(pt, false);
|
|
|
|
let cp = cu.GetClosestPointTo(pt, false);
|
|
|
|
//最近点参数
|
|
|
|
//最近点参数
|
|
|
@ -285,13 +287,7 @@ export function GetPointAtCurveDir(cu: Curve, pt: Vector3): boolean
|
|
|
|
cu instanceof Polyline
|
|
|
|
cu instanceof Polyline
|
|
|
|
&& equaln(floorParam, cparam, 1e-2)
|
|
|
|
&& equaln(floorParam, cparam, 1e-2)
|
|
|
|
&&
|
|
|
|
&&
|
|
|
|
(
|
|
|
|
(cu.IsClose || (floorParam !== 0 && floorParam !== cu.EndParam))
|
|
|
|
cu.IsClose ||
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
floorParam !== 0
|
|
|
|
|
|
|
|
&& floorParam !== cu.EndParam
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let plVerCount = cu.NumberOfVertices;
|
|
|
|
let plVerCount = cu.NumberOfVertices;
|
|
|
@ -302,22 +298,72 @@ export function GetPointAtCurveDir(cu: Curve, pt: Vector3): boolean
|
|
|
|
if (floorParam === cu.EndParam) floorParam = 0;
|
|
|
|
if (floorParam === cu.EndParam) floorParam = 0;
|
|
|
|
let fIndex = FixIndex(floorParam - 1, plVerCount);
|
|
|
|
let fIndex = FixIndex(floorParam - 1, plVerCount);
|
|
|
|
|
|
|
|
|
|
|
|
let fpInCir = PointInPolylineArc(cu, fIndex, pt);
|
|
|
|
|
|
|
|
if (fpInCir !== 0) return fpInCir < 0;
|
|
|
|
|
|
|
|
let npInCir = PointInPolylineArc(cu, floorParam, pt);
|
|
|
|
|
|
|
|
if (npInCir !== 0) return npInCir < 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let p = cu.GetPointAtParam(floorParam);
|
|
|
|
let p = cu.GetPointAtParam(floorParam);
|
|
|
|
let fDer = cu.GetFistDeriv(fIndex + 0.99).normalize();
|
|
|
|
let cu1 = cu.GetCurveAtIndex(fIndex);
|
|
|
|
let nDer = cu.GetFistDeriv(floorParam + 0.01).normalize();
|
|
|
|
let cu2 = cu.GetCurveAtIndex(floorParam);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let cu1Length = cu1.Length;
|
|
|
|
|
|
|
|
let cu2Length = cu2.Length;
|
|
|
|
|
|
|
|
let minLength = Math.min(cu1Length, cu2Length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let fDer: Vector3;
|
|
|
|
|
|
|
|
let nDer: Vector3;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (equaln(cu.GetBuilgeAt(fIndex), 0))
|
|
|
|
|
|
|
|
fDer = cu.GetFistDeriv(fIndex).normalize();
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let tp = cu1.GetPointAtDistance(cu1Length - minLength * 0.25);
|
|
|
|
|
|
|
|
fDer = tp.negate().add(p).normalize();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (equaln(cu.GetBuilgeAt(floorParam), 0))
|
|
|
|
|
|
|
|
nDer = cu.GetFistDeriv(floorParam).normalize();
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let tp = cu2.GetPointAtDistance(minLength * 0.25);
|
|
|
|
|
|
|
|
nDer = tp.sub(p).normalize();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let l1 = new Line(p.clone().sub(fDer), p);
|
|
|
|
let l1 = new Line(p.clone().sub(fDer.clone().multiplyScalar(300)), p);
|
|
|
|
let l2 = new Line(p, p.clone().add(nDer));
|
|
|
|
l1.ColorIndex = 1;
|
|
|
|
|
|
|
|
let l2 = new Line(p, p.clone().add(nDer.clone().multiplyScalar(200)));
|
|
|
|
|
|
|
|
l2.ColorIndex = 2;
|
|
|
|
let cp1 = l1.GetClosestPointTo(pt, true);
|
|
|
|
let cp1 = l1.GetClosestPointTo(pt, true);
|
|
|
|
let cp2 = l2.GetClosestPointTo(pt, true);
|
|
|
|
let cp2 = l2.GetClosestPointTo(pt, true);
|
|
|
|
|
|
|
|
|
|
|
|
if (equalv3(fDer, nDer.clone().negate()))
|
|
|
|
// T 型曲线
|
|
|
|
return true;
|
|
|
|
let nDerN = nDer.clone().negate();
|
|
|
|
|
|
|
|
if (equalv3(fDer, nDerN))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let frontParam = floorParam;
|
|
|
|
|
|
|
|
while (frontParam > 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let fp = cu.GetPointAtParam(frontParam - 1.2);
|
|
|
|
|
|
|
|
fDer.copy(p).sub(fp).normalize();
|
|
|
|
|
|
|
|
if (!equalv3(fDer, nDerN))
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
frontParam--;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (frontParam <= 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let nextParam = floorParam;
|
|
|
|
|
|
|
|
let endParam = cu.EndParam - 1;
|
|
|
|
|
|
|
|
while (nextParam < endParam)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let np = cu.GetPointAtParam(nextParam + 1.2);
|
|
|
|
|
|
|
|
nDer = np.sub(p).normalize();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!equalv3(fDer, nDerN))
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nextParam++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if (equalv3(fDer, nDer))
|
|
|
|
if (equalv3(fDer, nDer))
|
|
|
|
return fDer.cross(pt.clone().sub(cp1)).applyMatrix4(cu.OCSInv).z < 0;
|
|
|
|
return fDer.cross(pt.clone().sub(cp1)).applyMatrix4(cu.OCSInv).z < 0;
|
|
|
|
|
|
|
|
|
|
|
|