|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import { ClipType, PolyFillType } from "js-angusj-clipper/web";
|
|
|
|
|
import { Vector2 } from "three";
|
|
|
|
|
import { Matrix4, Vector2, Vector3 } from "three";
|
|
|
|
|
import { app } from "../../ApplicationServices/Application";
|
|
|
|
|
import { Polyline } from "../../DatabaseServices/Entity/Polyline";
|
|
|
|
|
import { Command } from "../../Editor/CommandMachine";
|
|
|
|
@ -15,31 +15,18 @@ export class Test implements Command
|
|
|
|
|
{
|
|
|
|
|
async exec()
|
|
|
|
|
{
|
|
|
|
|
let promise = InitClipperCpp();
|
|
|
|
|
|
|
|
|
|
let plss = await app.Editor.GetSelection({ Filter: { filterTypes: [Polyline] } });
|
|
|
|
|
if (plss.Status !== PromptStatus.OK) return;
|
|
|
|
|
|
|
|
|
|
let pls = plss.SelectSet.SelectEntityList as Polyline[];
|
|
|
|
|
|
|
|
|
|
let bin = pls.shift();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await promise;
|
|
|
|
|
|
|
|
|
|
let finalNfp = clipperCpp.lib.clipToPaths({
|
|
|
|
|
subjectInputs: [{ data: PathScale(bin.GetStretchPoints(), 1e4), closed: true }],
|
|
|
|
|
clipInputs: pls.map(pl => { return { data: PathScale(pl.GetStretchPoints(), 1e4) }; }),
|
|
|
|
|
clipType: ClipType.Difference,
|
|
|
|
|
subjectFillType: PolyFillType.NonZero
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
finalNfp = clipperCpp.lib.simplifyPolygons(finalNfp);
|
|
|
|
|
|
|
|
|
|
for (let nfp of finalNfp)
|
|
|
|
|
for (let e of app.Database.ModelSpace.Entitys)
|
|
|
|
|
{
|
|
|
|
|
let pl = Path2Polyline(nfp.map(p => new Vector2(p.x * 1e-4, p.y * 1e-4)));
|
|
|
|
|
TestDraw(pl);
|
|
|
|
|
let box = e.BoundingBox;
|
|
|
|
|
|
|
|
|
|
if (isNaN(box.min.x))
|
|
|
|
|
{
|
|
|
|
|
e.OCS = new Matrix4;
|
|
|
|
|
e.Update();
|
|
|
|
|
app.Editor.SetSelection([e]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|