public int Fits(RectClass bigger, bool allowflip) { if (RectPackHelper.EqE(Width, bigger.Width, 0.00001) && RectPackHelper.EqE(Height, bigger.Height, 0.00001)) { return(3); } if (allowflip && RectPackHelper.EqE(Width, bigger.Height, 0.00001) && RectPackHelper.EqE(Height, bigger.Width, 0.00001)) { return(4); } if (Width <= bigger.Width && Height <= bigger.Height) { return(1); } if (allowflip && Width <= bigger.Height && Height <= bigger.Width) { return(2); } return(0); }
public int Fits(RectClass bigger) { if (RectPackHelper.EqE(Width(), bigger.Width(), 0.00001) && RectPackHelper.EqE(Height(), bigger.Height(), 0.00001)) { return(3); } if (RectPackHelper.EqE(Width(), bigger.Height(), 0.00001) && RectPackHelper.EqE(Height(), bigger.Width(), 0.00001)) { return(4); } if (Width() <= bigger.Width() && Height() <= bigger.Height()) { return(1); } if (Width() <= bigger.Height() && Height() <= bigger.Width()) { return(2); } return(0); }
public void Evaluate(int SpreadMax) { if (FRectangle.IsChanged || FMaxBins.IsChanged || FDiscardBelow.IsChanged || FBox.IsChanged) { var binlist = new List <RectBin>(); var rectlistin = new RectXywhFlipped[FRectangle.SliceCount]; for (int i = 0; i < FRectangle.SliceCount; i++) { rectlistin[i] = new RectXywhFlipped { FWidth = FRectangle[i].x, FHeight = FRectangle[i].y, ID = i, Left = 0, Top = 0, Flipped = false }; } FSuccess[0] = RectPackHelper.Pack(rectlistin, FBox[0], FDiscardBelow[0], binlist, FMaxBins[0]); FPacked.SliceCount = binlist.Count; FID.SliceCount = binlist.Count; FDim.SliceCount = binlist.Count; FFlipped.SliceCount = binlist.Count; for (int i = 0; i < binlist.Count; i++) { FPacked[i].SliceCount = binlist[i].Rects.Count; FID[i].SliceCount = binlist[i].Rects.Count; FFlipped[i].SliceCount = binlist[i].Rects.Count; FDim[i] = binlist[i].Size; for (int j = 0; j < FPacked[i].SliceCount; j++) { var rect = binlist[i].Rects[j]; FPacked[i][j] = new Vector4D(rect.Left, rect.Top, rect.Width(), rect.Height()); FFlipped[i][j] = rect.Flipped; FID[i][j] = rect.ID; } } } }
public void Evaluate(int SpreadMax) { FOut.Stream.IsChanged = false; if ( SpreadUtils.AnyChanged(FRectangle, FMaxBins, FDiscardBelow, FBox, FAllowRot) || _pgready && _typeChanged ) { FOut.Stream.IsChanged = true; int sprmax = Math.Max(FRectangle.SliceCount, FBox.SliceCount); if (FRectangle.SliceCount == 0 || FBox.SliceCount == 0) { sprmax = 0; } FOut.SliceCount = FDim.SliceCount = FSuccess.SliceCount = sprmax; if (sprmax == 0) { return; } for (int bi = 0; bi < sprmax; bi++) { var binlist = new List <RectBin>(); var rectlistin = new RectXywhFlipped[FRectangle[bi].SliceCount]; for (int i = 0; i < FRectangle[bi].SliceCount; i++) { object attachment = null; if (_pgready) { attachment = _attachment.GetSlice <ISpread>(bi, null)?[i]; } rectlistin[i] = new RectXywhFlipped { Attachment = attachment, FWidth = FRectangle[bi][i].x, FHeight = FRectangle[bi][i].y, ID = i, Left = 0, Top = 0, Flipped = false }; } FSuccess[bi] = RectPackHelper.Pack(rectlistin, FBox[bi].x, FBox[bi].y, FDiscardBelow[0], binlist, FMaxBins[0], FAllowRot[0]); FOut[bi].SliceCount = FDim[bi].SliceCount = binlist.Count; for (int i = 0; i < binlist.Count; i++) { FOut[bi][i] = binlist[i]; FDim[bi][i] = binlist[i].Size; } } } if (_typeChanged) { _typeChanged = false; } }