|
|
|
@ -51,11 +51,26 @@ export class Container
|
|
|
|
|
constructor(public BinPath?: Path, private _PlaceType = PlaceType.Box, public ComparePosFnKey = "xy")
|
|
|
|
|
{
|
|
|
|
|
if (BinPath)
|
|
|
|
|
{
|
|
|
|
|
this.StatusKey = this.BinPath.Id.toString() + "," + this._PlaceType + "," + ComparePosFnKey;
|
|
|
|
|
|
|
|
|
|
this.UpdateCurNotPuts();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.CompartePoint = ComparePoint(ComparePosFnKey);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private UpdateCurNotPuts()
|
|
|
|
|
{
|
|
|
|
|
this._CurNotPuts = NestCache.GetNoPut(this.StatusKey);
|
|
|
|
|
if (!this._CurNotPuts)
|
|
|
|
|
{
|
|
|
|
|
this._CurNotPuts = new Set;
|
|
|
|
|
NestCache.SetNoPut(this.StatusKey, this._CurNotPuts);
|
|
|
|
|
this._NotPuts.push(this._CurNotPuts);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get UseRatio(): number
|
|
|
|
|
{
|
|
|
|
|
return this.PlacedBox.area / this.BinPath.Area;
|
|
|
|
@ -72,6 +87,7 @@ export class Container
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private _NotPuts: Set<number>[] = [];//已经无法放置的pathId
|
|
|
|
|
private _CurNotPuts: Set<number>;
|
|
|
|
|
|
|
|
|
|
private PrePut(part: Part): PartPlacedContainerState
|
|
|
|
|
{
|
|
|
|
@ -100,8 +116,6 @@ export class Container
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//快速退出
|
|
|
|
|
let noSet = NestCache.GetNoPut(this.StatusKey);
|
|
|
|
|
if (noSet) this._NotPuts.push(noSet);
|
|
|
|
|
for (let set of this._NotPuts)
|
|
|
|
|
{
|
|
|
|
|
if (set.has(part.State.Contour.Id))
|
|
|
|
@ -114,12 +128,7 @@ export class Container
|
|
|
|
|
let finalNfp = this.GetNFPs(part, binNfp);
|
|
|
|
|
if (!finalNfp || finalNfp.length === 0)
|
|
|
|
|
{
|
|
|
|
|
if (noSet) noSet.add(part.State.Contour.Id);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
noSet = new Set([part.State.Contour.Id]);
|
|
|
|
|
NestCache.SetNoPut(this.StatusKey, noSet);
|
|
|
|
|
}
|
|
|
|
|
this._CurNotPuts.add(part.State.Contour.Id);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -324,6 +333,7 @@ export class Container
|
|
|
|
|
private AppendPart(part: Part, calc = true): void
|
|
|
|
|
{
|
|
|
|
|
this.StatusKey += "," + part.State.Contour.Id;
|
|
|
|
|
this.UpdateCurNotPuts();
|
|
|
|
|
this.PlacedParts.push(part);
|
|
|
|
|
this.PlacedArea += part.State.Contour.Area;
|
|
|
|
|
let m = { x: part.PlacePosition.x * 1e-4, y: part.PlacePosition.y * 1e-4 };
|
|
|
|
|