pull/546/head
ChenX 5 years ago
parent 8039f48d79
commit e871892c77

@ -113,7 +113,7 @@ function createTestPolyline(): Polyline
test('切割点在尾部', () =>
{
let pl = new Polyline();
pl.Create2Pt(new Vector3(), new Vector3(100, 100));
pl.Rectangle(100, 100);
let cus = pl.GetSplitCurves([1, 4]);
expect(cus.length).toBe(2);

@ -35,7 +35,7 @@ export function Board2Regions(br: Board): Region[]
for (let l of lines)
{
let rectPl = new Polyline().Create2Pt(ZeroVec, new Vector3(l.Length, br.Thickness));
let rectPl = new Polyline().Rectangle(l.Length, br.Thickness);
let reg = Region.CreateFromCurves([rectPl]);
let p = l.StartPoint.applyMatrix4(ocs);

@ -12,7 +12,7 @@ export class DrawRect implements Command
if (rectRes.Status === PromptStatus.OK)
{
let rec = new Polyline();
rec.Create2Pt(rectRes.Point1UCS, rectRes.Point2UCS);
rec.RectangleFrom2Pt(rectRes.Point1UCS, rectRes.Point2UCS);
rec.ApplyMatrix(app.Editor.UCSMatrix);
app.Database.ModelSpace.Append(rec);

@ -73,7 +73,7 @@ export class DrawObliqueWineRackTool extends DrawWineRackTool
break;
}
let rectPl = new Polyline().Create2Pt(new Vector3(), new Vector3(spaceWidth, spaceHeight));
let rectPl = new Polyline().Rectangle(spaceWidth, spaceHeight);
let gripWidth = config.boardThick + config.gripWidth;
let retPls: Polyline[] = [];
@ -652,8 +652,7 @@ export class DrawObliqueWineRackTool extends DrawWineRackTool
{
const size = this.space.Size;
let pl = new Polyline();
pl.Create2Pt(new Vector3(), new Vector3(size.y, len));
pl.CloseMark = true;
pl.Rectangle(size.y, len);
const config = this.Config;
let addWidth = config.grooveWidthAdd;

@ -248,7 +248,7 @@ export class ExtrudeSolid extends Entity
if (!this.contourCurve || !(this.contourCurve instanceof Polyline))
this.contourCurve = new Polyline();
this.contourCurve.Create2Pt(new Vector3(), new Vector3(this.width, this.height));
this.contourCurve.Rectangle(this.width, this.height);
}
/**

@ -258,7 +258,17 @@ export class Polyline extends Curve
{
return this._LineData[index].bul;
}
Create2Pt(p1: Vector3, p2: Vector3)
Rectangle(length: number, height: number): this
{
this.LineData = [
{ pt: new Vector2(), bul: 0 },
{ pt: new Vector2(length), bul: 0 },
{ pt: new Vector2(length, height), bul: 0 },
{ pt: new Vector2(0, height), bul: 0 }];
this.CloseMark = true;
return this;
}
RectangleFrom2Pt(p1: Vector3, p2: Vector3): this
{
let box = new Box3();
box.setFromPoints([p2, p1].map((p: Vector3) => p.clone().applyMatrix4(this.OCSInv)));
@ -1436,3 +1446,5 @@ export class Polyline extends Curve
file.Write(this._ClosedMark);
}
}
export const TempPolyline = new Polyline();

@ -5,7 +5,7 @@ import { Board } from "../DatabaseServices/Entity/Board";
import { Circle } from "../DatabaseServices/Entity/Circle";
import { Curve } from "../DatabaseServices/Entity/Curve";
import { Line } from "../DatabaseServices/Entity/Line";
import { Polyline } from "../DatabaseServices/Entity/Polyline";
import { Polyline, TempPolyline } from "../DatabaseServices/Entity/Polyline";
import { angle, equaln, equalv3, isParallelTo, SelectNearP } from "../Geometry/GeUtils";
import { IntersectOption } from "./IntersectWith";
@ -187,8 +187,7 @@ export function GetBoardSealingCurves(br: Board)
}
else
{
let cu = new Polyline().Create2Pt(new Vector3(), new Vector3(br.Width, br.Height))
cus = cu.Explode();
cus = TempPolyline.Rectangle(br.Width, br.Height).Explode();
}
return cus;
}

@ -235,7 +235,7 @@ export class FeedingToolPath extends Singleton
box.max.add(new Vector3(0, addLen / 2));
box.min.add(new Vector3(0, -addLen / 2));
}
let pl = new Polyline().Create2Pt(box.min, box.max).ApplyMatrix(curveData.OCS);
let pl = new Polyline().RectangleFrom2Pt(box.min, box.max).ApplyMatrix(curveData.OCS);
pl.ColorIndex = shape.Outline.Curve.ColorIndex;
shape.Outline = Contour.CreateContour(pl);
}

@ -1,5 +1,4 @@
import { Matrix4, Vector2, Vector3 } from "three";
import { arrayLast } from "../Common/ArrayExt";
import { EBoardKeyList } from "../Common/BoardKeyList";
import { Vector2ApplyMatrix4 } from "../Common/Matrix4Utils";
import { GangDrill, GangDrillType } from "../DatabaseServices/3DSolid/GangDrill";

Loading…
Cancel
Save