开发:重构变量名

pull/1929/head
ChenX 2 years ago
parent a373749050
commit 3e02a957ab

@ -13,7 +13,7 @@ test('直线相交,共线', () =>
let pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendThis); let pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendThis);
expect(pts.length).toBe(0); expect(pts.length).toBe(0);
pts = IntersectLineAndLine(l1, l2, IntersectOption.OnBothOperands); pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendNone);
expect(pts.length).toBe(0); expect(pts.length).toBe(0);
pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendArg); pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendArg);
@ -33,7 +33,7 @@ test('直线相交', () =>
let pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendThis); let pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendThis);
expect(pts.length).toBe(1); expect(pts.length).toBe(1);
pts = IntersectLineAndLine(l1, l2, IntersectOption.OnBothOperands); pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendNone);
expect(pts.length).toBe(1); expect(pts.length).toBe(1);
pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendArg); pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendArg);

@ -1,5 +1,5 @@
import { Polyline } from "../../src/DatabaseServices/Entity/Polyline";
import { Vector2 } from "three"; import { Vector2 } from "three";
import { Polyline } from "../../src/DatabaseServices/Entity/Polyline";
import { IntersectOption } from "../../src/GraphicsSystem/IntersectWith"; import { IntersectOption } from "../../src/GraphicsSystem/IntersectWith";
describe("相交", () => describe("相交", () =>
{ {
@ -25,7 +25,7 @@ describe("相交", () =>
bul: 2.01 bul: 2.01
}, },
]); ]);
let pts = pl.IntersectWith(p2, IntersectOption.OnBothOperands); let pts = pl.IntersectWith(p2, IntersectOption.ExtendNone);
expect(pts.length).toBe(0); expect(pts.length).toBe(0);
let pts1 = pl.IntersectWith(p2, IntersectOption.ExtendBoth); let pts1 = pl.IntersectWith(p2, IntersectOption.ExtendBoth);
expect(pts1.length).toBe(2); expect(pts1.length).toBe(2);
@ -96,7 +96,7 @@ describe("相交", () =>
bul: 0 bul: 0
}, },
]); ]);
let pts = pl.IntersectWith(p2, IntersectOption.OnBothOperands); let pts = pl.IntersectWith(p2, IntersectOption.ExtendNone);
expect(pts.length).toBe(1); expect(pts.length).toBe(1);
let pts1 = pl.IntersectWith(p2, IntersectOption.ExtendBoth); let pts1 = pl.IntersectWith(p2, IntersectOption.ExtendBoth);
expect(pts1.length).toBe(2); expect(pts1.length).toBe(2);
@ -104,10 +104,10 @@ describe("相交", () =>
expect(pts2.length).toBe(2); expect(pts2.length).toBe(2);
let pts3 = pl.IntersectWith(p2, IntersectOption.ExtendArg); let pts3 = pl.IntersectWith(p2, IntersectOption.ExtendArg);
expect(pts3.length).toBe(1); expect(pts3.length).toBe(1);
let pts4 = pl.IntersectWith(p3, IntersectOption.OnBothOperands); let pts4 = pl.IntersectWith(p3, IntersectOption.ExtendNone);
expect(pts).toMatchSnapshot(); expect(pts).toMatchSnapshot();
expect(pts4.length).toBe(2); expect(pts4.length).toBe(2);
let pts5 = pl.IntersectWith(p4, IntersectOption.OnBothOperands); let pts5 = pl.IntersectWith(p4, IntersectOption.ExtendNone);
expect(pts5.length).toBe(1); expect(pts5.length).toBe(1);
let pts6 = pl.IntersectWith(p4, IntersectOption.ExtendArg); let pts6 = pl.IntersectWith(p4, IntersectOption.ExtendArg);
expect(pts6.length).toBe(2); expect(pts6.length).toBe(2);

@ -313,7 +313,7 @@ class FixBoard2dPath
let new_m2d: I2DModeling[] = []; let new_m2d: I2DModeling[] = [];
for (let m of m2d) for (let m of m2d)
{ {
let ints = br.ContourCurve.IntersectWith(m.path, IntersectOption.OnBothOperands); let ints = br.ContourCurve.IntersectWith(m.path, IntersectOption.ExtendNone);
if (ints.length) if (ints.length)
{ {
let cus = m.path.GetSplitCurvesByPts(ints); let cus = m.path.GetSplitCurvesByPts(ints);

@ -131,7 +131,7 @@ async function BreakAll()
return; return;
let curves = cuRes.SelectSet.SelectEntityList as Curve[]; let curves = cuRes.SelectSet.SelectEntityList as Curve[];
let ins = new CurveIntersection(curves, true, IntersectOption.OnBothOperands); let ins = new CurveIntersection(curves, true, IntersectOption.ExtendNone);
//延伸+打断 //延伸+打断
for (let [cu, pmap] of ins.intersect2) for (let [cu, pmap] of ins.intersect2)

@ -178,7 +178,7 @@ export class DrawCircle implements Command
let center: Vector3; let center: Vector3;
let ipts = c1.IntersectWith(c2, IntersectOption.OnBothOperands); let ipts = c1.IntersectWith(c2, IntersectOption.ExtendNone);
if (ipts.length === 2) if (ipts.length === 2)
{ {
let p = midPoint(ptRes1.Point, ptRes2.Point); let p = midPoint(ptRes1.Point, ptRes2.Point);

@ -673,7 +673,7 @@ export class DrawObliqueWineRackTool extends DrawWineRackTool
let dists: number[] = []; let dists: number[] = [];
for (let d2 of rData) for (let d2 of rData)
{ {
let intPts = d.pl.IntersectWith(d2.pl, IntersectOption.OnBothOperands); let intPts = d.pl.IntersectWith(d2.pl, IntersectOption.ExtendNone);
if (intPts.length === 4) if (intPts.length === 4)
{ {
dists.push(...intPts.map(p => dists.push(...intPts.map(p =>

@ -167,7 +167,7 @@ export class FilletUtils
// JigUtils.Draw(offCu1.Clone()); // JigUtils.Draw(offCu1.Clone());
// JigUtils.Draw(offCu2.Clone()); // JigUtils.Draw(offCu2.Clone());
let center = offCu1.IntersectWith(offCu2, IntersectOption.OnBothOperands) let center = offCu1.IntersectWith(offCu2, IntersectOption.ExtendNone)
.sort((p1, p2) => .sort((p1, p2) =>
{ {
return p1.distanceToSquared(iPt) - p2.distanceToSquared(iPt); return p1.distanceToSquared(iPt) - p2.distanceToSquared(iPt);

@ -157,7 +157,7 @@ export class Command_Trim implements Command
//TODO: 缓存相交结果,避免反复求值,仅当图纸实体更新时才更新,避免反复求值 //TODO: 缓存相交结果,避免反复求值,仅当图纸实体更新时才更新,避免反复求值
for (let icu of kniefCus) for (let icu of kniefCus)
if (icu !== thisCurve && selectBox.CheckSelectTraverse(icu.GetDrawObjectFromRenderType())) if (icu !== thisCurve && selectBox.CheckSelectTraverse(icu.GetDrawObjectFromRenderType()))
arrayPushArray(inPts, cu.IntersectWith(icu, IntersectOption.OnBothOperands)); arrayPushArray(inPts, cu.IntersectWith(icu, IntersectOption.ExtendNone));
return inPts; return inPts;
} }
@ -228,7 +228,7 @@ export class Command_Trim implements Command
let insPts: Vector3[] = []; let insPts: Vector3[] = [];
for (let cuT of subCus) for (let cuT of subCus)
if (cuT !== cu) if (cuT !== cu)
insPts.push(...cu.IntersectWith(cuT, IntersectOption.OnBothOperands)); insPts.push(...cu.IntersectWith(cuT, IntersectOption.ExtendNone));
let cus = this.TrimCurve(cu, kniefCus, selBox, curve, insPts); let cus = this.TrimCurve(cu, kniefCus, selBox, curve, insPts);
notSelCus.push(...cus); notSelCus.push(...cus);

@ -24,7 +24,7 @@ export class Command_INsTest implements Command
{ {
let cu2 = cus[j]; let cu2 = cus[j];
let ins = cu.IntersectWith(cu2, IntersectOption.OnBothOperands); let ins = cu.IntersectWith(cu2, IntersectOption.ExtendNone);
for (let p of ins) for (let p of ins)
{ {

@ -800,7 +800,7 @@ export class Polyline2Board implements Command
let box = box1.clone().intersect(box2); let box = box1.clone().intersect(box2);
let s = box.getSize(new Vector3); let s = box.getSize(new Vector3);
if (s.x < 1 || s.y < 1) return false; if (s.x < 1 || s.y < 1) return false;
let int = pl1.IntersectWith(pl2, IntersectOption.OnBothOperands); let int = pl1.IntersectWith(pl2, IntersectOption.ExtendNone);
return int.length > 0 || pl1.PtInCurve(pl2.StartPoint); return int.length > 0 || pl1.PtInCurve(pl2.StartPoint);
} }

@ -234,7 +234,7 @@ export class Contour
// if (!sourceOutline.BoundingBox.intersectsBox(targetOutline.BoundingBox, 1e-3)) // if (!sourceOutline.BoundingBox.intersectsBox(targetOutline.BoundingBox, 1e-3))
// return { intersectionList, unionList }; // return { intersectionList, unionList };
let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.OnBothOperands, COMBINE_FUZZ); let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.ExtendNone, COMBINE_FUZZ);
let sourceContainerTarget: boolean; let sourceContainerTarget: boolean;
let targetContainerSource: boolean; let targetContainerSource: boolean;
@ -327,7 +327,7 @@ export class Contour
let isEqualNormal = equalv3(sourceOutline.Normal, targetOutline.Normal, 1e-3); let isEqualNormal = equalv3(sourceOutline.Normal, targetOutline.Normal, 1e-3);
let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.OnBothOperands, COMBINE_FUZZ); let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.ExtendNone, COMBINE_FUZZ);
if (interPts.length <= 1) if (interPts.length <= 1)
{ {
@ -435,7 +435,7 @@ export class Contour
if (!IntersectBox2(outBox, targetOutline.BoundingBox)) if (!IntersectBox2(outBox, targetOutline.BoundingBox))
continue; continue;
let pts = sourceOutline.IntersectWith2(con.Curve, IntersectOption.OnBothOperands, COMBINE_FUZZ); let pts = sourceOutline.IntersectWith2(con.Curve, IntersectOption.ExtendNone, COMBINE_FUZZ);
if (pts.length <= 1) if (pts.length <= 1)
{ {
//反包含 //反包含

@ -1261,7 +1261,7 @@ export class Polyline extends Curve
for (let j = i + 2; j < cus.length; j++) for (let j = i + 2; j < cus.length; j++)
{ {
let c2 = cus[j]; let c2 = cus[j];
let pts = c.IntersectWith(c2, IntersectOption.OnBothOperands); let pts = c.IntersectWith(c2, IntersectOption.ExtendNone);
for (let p of pts) for (let p of pts)
{ {

@ -26,14 +26,14 @@ export class CurveTrim
if (this._IsErase) return; if (this._IsErase) return;
//交点参数列表 //交点参数列表
let iParams = this._curve.IntersectWith2(contour.Curve, IntersectOption.OnBothOperands).map(p => p.thisParam).filter(p => p > 1e-4 && p < 0.9999); let iParams = this._curve.IntersectWith2(contour.Curve, IntersectOption.ExtendNone).map(p => p.thisParam).filter(p => p > 1e-4 && p < 0.9999);
iParams.push(0, 1); iParams.push(0, 1);
iParams.sort((a, b) => a - b); iParams.sort((a, b) => a - b);
arrayRemoveDuplicateBySort(iParams, (a1, a2) => equaln(a1, a2, 1e-4)); arrayRemoveDuplicateBySort(iParams, (a1, a2) => equaln(a1, a2, 1e-4));
if (iParams.length === 2)//[0,1]全包含 或者在外部 if (iParams.length === 2)//[0,1]全包含 或者在外部
{ {
let p = this._curve.GetPointAtParam(0.5); let p = this.GetPointAtParam(0.5);
if (this.PointInContour(p, contour, box, saveSyntropy)) if (this.PointInContour(p, contour, box, saveSyntropy))
this._IsErase = true; this._IsErase = true;
return; return;

@ -334,7 +334,7 @@ export class RoomWallParse
else tempC.StartPoint = p; else tempC.StartPoint = p;
line = new Line(v.position.clone(), p); line = new Line(v.position.clone(), p);
let ipts = line.IntersectWith(tempC, IntersectOption.OnBothOperands); let ipts = line.IntersectWith(tempC, IntersectOption.ExtendNone);
if (ipts.length === 2) if (ipts.length === 2)
p = undefined; p = undefined;
} }
@ -346,7 +346,7 @@ export class RoomWallParse
else tempC.StartPoint = p; else tempC.StartPoint = p;
if (!line) line = new Line(v.position.clone(), p); if (!line) line = new Line(v.position.clone(), p);
let ipts = line.IntersectWith(tempC, IntersectOption.OnBothOperands); let ipts = line.IntersectWith(tempC, IntersectOption.ExtendNone);
if (ipts.length === 2) if (ipts.length === 2)
p = undefined; p = undefined;
} }

@ -24,7 +24,7 @@ export class CurveIntersection
* @param {Curve[]} cus ,, * @param {Curve[]} cus ,,
* @memberof CurveIntersection * @memberof CurveIntersection
*/ */
constructor(cus: Curve[], parseIntersectionParam = false, intType = IntersectOption.OnBothOperands, protected fuzz = 1e-6, parseRecord = false) constructor(cus: Curve[], parseIntersectionParam = false, intType = IntersectOption.ExtendNone, protected fuzz = 1e-6, parseRecord = false)
{ {
this.GenBox(cus); this.GenBox(cus);
//按x排序 //按x排序

@ -1346,7 +1346,7 @@ function GetIntersection(cu1: Curve, cu2: Curve): IntersectResult[]
m = new Map(); m = new Map();
intCache.set(cu1, m); intCache.set(cu1, m);
let r = cu1.IntersectWith2(cu2, IntersectOption.OnBothOperands); let r = cu1.IntersectWith2(cu2, IntersectOption.ExtendNone);
let cu1EndParam = cu1.EndParam; let cu1EndParam = cu1.EndParam;
let cu2EndParam = cu2.EndParam; let cu2EndParam = cu2.EndParam;

@ -39,7 +39,7 @@ export function isTargetCurInOrOnSourceCur(sourceCur: Polyline | Circle | Ellips
//获取交点处上下距0.01par的点 //获取交点处上下距0.01par的点
function getIntPtContextPts(sourceCur: Curve, cu: Curve, pts: Vector3[] = []) function getIntPtContextPts(sourceCur: Curve, cu: Curve, pts: Vector3[] = [])
{ {
let interPts = cu.IntersectWith(sourceCur, IntersectOption.OnBothOperands); let interPts = cu.IntersectWith(sourceCur, IntersectOption.ExtendNone);
if (interPts.length > 0) if (interPts.length > 0)
{ {
let pars = interPts.map(pt => cu.GetParamAtPoint(pt)); let pars = interPts.map(pt => cu.GetParamAtPoint(pt));

@ -19,7 +19,7 @@ export enum IntersectOption
/** /**
* *
*/ */
OnBothOperands = 0, ExtendNone = 0,
/** /**
* *
*/ */
@ -599,7 +599,7 @@ export function IntersectEllipseAndCircleOrArc(el: Ellipse, cir: Circle | Arc, t
if (type === IntersectOption.ExtendBoth) if (type === IntersectOption.ExtendBoth)
type = IntersectOption.ExtendArg; type = IntersectOption.ExtendArg;
else if (type !== IntersectOption.ExtendArg) else if (type !== IntersectOption.ExtendArg)
type = IntersectOption.OnBothOperands; type = IntersectOption.ExtendNone;
let intPts = IntersectPolylineAndCurve(pl, cirClone, type); let intPts = IntersectPolylineAndCurve(pl, cirClone, type);
intPts.forEach(r => r.pt.applyMatrix4(el.OCS)); intPts.forEach(r => r.pt.applyMatrix4(el.OCS));

@ -61,7 +61,7 @@ export class CurveTreeNode
} }
//交点参数列表 //交点参数列表
let iParams = this.curve.IntersectWith(contour.Curve, IntersectOption.OnBothOperands) let iParams = this.curve.IntersectWith(contour.Curve, IntersectOption.ExtendNone)
.map(p => this.curve.GetParamAtPoint2(p)); .map(p => this.curve.GetParamAtPoint2(p));
let cus = this.curve.GetSplitCurves(iParams); let cus = this.curve.GetSplitCurves(iParams);
@ -414,7 +414,7 @@ export class OffsetPolyline
let l1 = new Line(p1, p2); let l1 = new Line(p1, p2);
let l2 = new Line(p3, p4); let l2 = new Line(p3, p4);
let ipts = l1.IntersectWith(l2, IntersectOption.OnBothOperands, 1e-8); let ipts = l1.IntersectWith(l2, IntersectOption.ExtendNone, 1e-8);
if (ipts.length > 0) if (ipts.length > 0)
{ {
let p = ipts[0]; let p = ipts[0];
@ -440,8 +440,8 @@ export class OffsetPolyline
{ {
if (Math.sign(cu2.Bul) !== this._OffsetDistSign) if (Math.sign(cu2.Bul) !== this._OffsetDistSign)
{ {
let ipts1 = cu2.IntersectWith(l1, IntersectOption.OnBothOperands); let ipts1 = cu2.IntersectWith(l1, IntersectOption.ExtendNone);
let ipts2 = cu2.IntersectWith(l2, IntersectOption.OnBothOperands); let ipts2 = cu2.IntersectWith(l2, IntersectOption.ExtendNone);
let sp: Vector3; let sp: Vector3;
let ep: Vector3; let ep: Vector3;
@ -474,7 +474,7 @@ export class OffsetPolyline
let a = d.preCurve; let a = d.preCurve;
if (Math.sign(a.Bul) !== this._OffsetDistSign && a.AllAngle > 1e-6) if (Math.sign(a.Bul) !== this._OffsetDistSign && a.AllAngle > 1e-6)
{ {
let ipts = a.IntersectWith(l1, IntersectOption.OnBothOperands); let ipts = a.IntersectWith(l1, IntersectOption.ExtendNone);
if (ipts.length === 2) if (ipts.length === 2)
{ {
let sp = SelectNearP(ipts, p1); let sp = SelectNearP(ipts, p1);
@ -489,7 +489,7 @@ export class OffsetPolyline
let a = d.nextCurve; let a = d.nextCurve;
if (Math.sign(a.Bul) !== this._OffsetDistSign && a.AllAngle > 1e-6) if (Math.sign(a.Bul) !== this._OffsetDistSign && a.AllAngle > 1e-6)
{ {
let ipts = a.IntersectWith(l2, IntersectOption.OnBothOperands); let ipts = a.IntersectWith(l2, IntersectOption.ExtendNone);
if (ipts.length === 2) if (ipts.length === 2)
{ {
let ep = SelectNearP(ipts, p3); let ep = SelectNearP(ipts, p3);

Loading…
Cancel
Save