/// <summary> /// Decodes the PackingPattern i.e. constructs the resulting Packing. /// </summary> /// <param name="packing">The PackingPattern to be decoded</param> /// <param name="rects">Corresponding rects</param> /// <returns>Resulting Packing</returns> private static PackingResult Decode(ref PackingPattern packing, IEnumerable <PPRect> rects) { BLAlgorithmPacker blAlgorithm = new BLAlgorithmPacker(new PreserveOrderImageSorter()); var rectsPermuted = Permute(packing.permutation, rects); return(blAlgorithm.PlaceRects(packing.packingWidth, Int32.MaxValue, rectsPermuted)); }
public void BLAlgorithmTestNegativeParameters() { //Arrange var blAlgorithm = new BLAlgorithmPacker(); var rects = new List <PPRect>() { new PPRect(0, 0, 20, 20) }; //Act blAlgorithm.PlaceRects(-1, -10, rects); }
public void BLAlgorithmTestNoFit() { //Arrange var blAlgorithm = new BLAlgorithmPacker(); var rects = new List <PPRect>() { new PPRect(0, 0, 20, 20) }; //Act var result = blAlgorithm.PlaceRects(10, 10, rects); //Assert Assert.AreEqual(null, result); }
public void BLAlgorithmTestFullWidth() { //Arrange var blAlgorithm = new BLAlgorithmPacker(); var rects = new List <PPRect>() { new PPRect(0, 0, 100, 10), new PPRect(0, 0, 100, 10), new PPRect(0, 0, 100, 10), new PPRect(0, 0, 100, 10) }; //Act var result = blAlgorithm.PlaceRects(100, 100, rects); //Assert Assert.AreNotEqual(null, result); Assert.AreEqual(true, TestUtil.IsPackingResultValid(result)); var actualW = result.Rects.Max(x => x.Right); var actualH = result.Rects.Max(x => x.Bottom); Assert.AreEqual(100, actualW); Assert.AreEqual(40, actualH); }