From 7c8d42e18210132b1b98e96bae3179604892914e Mon Sep 17 00:00:00 2001 From: ChenX Date: Wed, 18 Apr 2018 11:08:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=81=8F=E7=A7=BB,=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E7=82=B9=E5=9C=A8=E6=9B=B2=E7=BA=BF=E5=86=85=E5=A4=96?= =?UTF-8?q?=E7=9A=84,=E9=81=BF=E5=85=8D=E5=9C=A8=E5=A4=9A=E6=AE=B5?= =?UTF-8?q?=E7=BA=BF=E6=97=B6=E5=81=8F=E7=A7=BB=E9=94=99=E8=AF=AF.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/Offset.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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));