pull/68/head
Zoe 6 years ago
parent 83030db3e4
commit fbc924d345

@ -11,7 +11,6 @@ import { Polyline } from '../DatabaseServices/Polyline';
import { equal, equaln } from "../Geometry/GeUtils"; import { equal, equaln } from "../Geometry/GeUtils";
import { IsPtsAllOutOrOnReg } from "./BoolOperateUtils"; import { IsPtsAllOutOrOnReg } from "./BoolOperateUtils";
import { IntersectOption } from "./IntersectWith"; import { IntersectOption } from "./IntersectWith";
import { testContours } from "../Add-on/testEntity/TestCurve";
interface offestRes interface offestRes
{ {
@ -92,10 +91,10 @@ export class PolyOffestUtil
} }
else if (pl1 || pl2) else if (pl1 || pl2)
{ {
let arc = pl1 ? pl1.Clone() as Arc : pl2.Clone() as Arc; let arc = pl1 ? pl1 as Arc : pl2 as Arc;
let l1 = new Line(arc.Center, arc.StartPoint); // let l1 = new Line(arc.Center, arc.StartPoint);
let l2 = new Line(arc.Center, arc.EndPoint); // let l2 = new Line(arc.Center, arc.EndPoint);
return Contour.CreateContour([arc, l1, l2]); return Contour.CreateContour([new Circle(arc.Center, Math.abs(this.m_OffestDist))]);
} }
else else
{ {
@ -158,8 +157,8 @@ export class PolyOffestUtil
frontLine.PtOnCurve(p) && laterLine.PtOnCurve(p) && !equal(p, laterLine.EndPoint)); frontLine.PtOnCurve(p) && laterLine.PtOnCurve(p) && !equal(p, laterLine.EndPoint));
} }
//有真交点,直接连接加入结果数组 //如果首尾相等或者 有真交点且不是最后一条和第一条运算,直接连接加入结果数组
if (tPts.length > 0) if (!interPts || (tPts.length > 0 && i !== offResList.length - 1))
{ {
let interPt = this.selectFitInterPt(tPts, frontLine.EndPoint); let interPt = this.selectFitInterPt(tPts, frontLine.EndPoint);
this.appendNewCuAndContour(frontLine, nextStartPt, interPt, rets, startIndex, cons); this.appendNewCuAndContour(frontLine, nextStartPt, interPt, rets, startIndex, cons);
@ -305,7 +304,6 @@ export class PolyOffestUtil
} }
let inPt = this.selectFitInterPt(pts, frontLine.EndPoint); let inPt = this.selectFitInterPt(pts, frontLine.EndPoint);
this.appendNewCuAndContour(frontLine, nextPt, inPt, retPlList, startIndex, cons); this.appendNewCuAndContour(frontLine, nextPt, inPt, retPlList, startIndex, cons);
//TODO:如果圆和laterline有交点了,可以跳过剩下的圆 //TODO:如果圆和laterline有交点了,可以跳过剩下的圆
@ -315,6 +313,7 @@ export class PolyOffestUtil
let cir2 = cirs[i + 1]; let cir2 = cirs[i + 1];
let pts = cir1.IntersectWith(cir2, IntersectOption.OnBothOperands); let pts = cir1.IntersectWith(cir2, IntersectOption.OnBothOperands);
let intPt = this.selectFitInterPt(pts, nextPt); let intPt = this.selectFitInterPt(pts, nextPt);
// testPts([inPt])
this.buildArcJoinList(cir1, nextPt, intPt, retPlList, cons); this.buildArcJoinList(cir1, nextPt, intPt, retPlList, cons);
} }
//最后一个圆连接laterline //最后一个圆连接laterline
@ -459,8 +458,8 @@ export class PolyOffestUtil
let toOriginCu = this.m_Polyline.GetClosestPointTo(pts[0], false).distanceToSquared(pts[0]); let toOriginCu = this.m_Polyline.GetClosestPointTo(pts[0], false).distanceToSquared(pts[0]);
let toOriginCu1 = this.m_Polyline.GetClosestPointTo(pts[1], false).distanceToSquared(pts[1]); let toOriginCu1 = this.m_Polyline.GetClosestPointTo(pts[1], false).distanceToSquared(pts[1]);
let rad2 = Math.pow(this.m_OffestDist, 2); let rad2 = Math.pow(this.m_OffestDist, 2);
let pt0Equl = (rad2 - 1e-3) >= toOriginCu; let pt0Equl = equaln(rad2, toOriginCu) || (rad2 + 1e-3) < toOriginCu;
let pt1Equl = (rad2 - 1e-3) >= toOriginCu1; let pt1Equl = equaln(rad2, toOriginCu1) || (rad2 + 1e-3) < toOriginCu1;
if ((pt0Equl && pt1Equl) || (!pt0Equl && !pt1Equl)) if ((pt0Equl && pt1Equl) || (!pt0Equl && !pt1Equl))
{ {

Loading…
Cancel
Save