更新偏移,校验点在曲线内外的,避免在多段线时偏移错误.

pull/59/head
ChenX 7 years ago
parent 9a857b29ff
commit 7c8d42e182

@ -33,6 +33,10 @@ export class Command_Offset implements Command
let d = cu.GetFistDeriv(cu.GetParamAtPoint(ptClose));//切线。
let c = toPtVec.cross(d);
if (cu instanceof Polyline && cu.EndParam > 1 && cu.Area > 0)
{
c.z = (IsPointInPolyLine(cu, p) ? -1 : 1) * Math.sign(cu.Area2);
}
let offCurs = cu.GetOffsetCurves(dis.Value * Math.sign(c.z));
offCurs.forEach((offCur) =>
@ -74,9 +78,9 @@ export class Command_TestOffset implements Command
let d = cu.GetFistDeriv(cu.GetParamAtPoint(ptClose));//切线。
let c = toPtVec.cross(d);
if (cu instanceof Polyline)
if (cu instanceof Polyline && cu.EndParam > 1 && cu.Area > 0)
{
c.z = (IsPointInPolyLine(cu, p)) ? 1 : -1;
c.z = (IsPointInPolyLine(cu, p) ? -1 : 1) * Math.sign(cu.Area2);
}
lastpls = cu.GetOffsetCurves(p.distanceTo(cu.GetClosestPointTo(p, !cu.IsClose)) * Math.sign(c.z));

Loading…
Cancel
Save