diff --git a/src/Add-on/Offset.ts b/src/Add-on/Offset.ts index b627a77a2..a5d562f31 100644 --- a/src/Add-on/Offset.ts +++ b/src/Add-on/Offset.ts @@ -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));