Ejemplo n.º 1
0
        public void ResponseProcessor(SheetPlacement payload)
        {
            //console.log('ipc response', payload);
            if (ga == null)
            {
                // user might have quit while we're away
                return;
            }
            ga.population[payload.index].processing = null;
            ga.population[payload.index].fitness    = payload.fitness;

            // render placement
            if (this.nests.Count == 0 || this.nests[0].fitness > payload.fitness)
            {
                this.nests.Insert(0, payload);

                if (this.nests.Count > Config.populationSize)
                {
                    this.nests.RemoveAt(nests.Count - 1);
                }
                //if (displayCallback)
                {
                    // displayCallback();
                }
            }
        }
Ejemplo n.º 2
0
 public void StartNest()
 {
     current = null;
     Nest    = new SvgNest();
     Background.cacheProcess = new Dictionary <string, NFP[]>();
     Background.window       = new windowUnk();
     Background.callCounter  = 0;
     Iterations = 0;
 }
Ejemplo n.º 3
0
        public void AssignPlacement(SheetPlacement plcpr)
        {
            current = plcpr;
            double totalSheetsArea = 0;
            double totalPartsArea  = 0;

            PlacedPartsCount = 0;
            List <NFP> placed = new List <NFP>();

            foreach (var item in Polygons)
            {
                item.sheet = null;
            }
            List <int> sheetsIds = new List <int>();

            foreach (var item in plcpr.placements)
            {
                foreach (var zitem in item)
                {
                    var sheetid = zitem.sheetId;
                    if (!sheetsIds.Contains(sheetid))
                    {
                        sheetsIds.Add(sheetid);
                    }

                    var sheet = Sheets.First(z => z.id == sheetid);
                    totalSheetsArea += Math.Abs(GeometryUtil.polygonArea(sheet));

                    foreach (var ssitem in zitem.sheetplacements)
                    {
                        PlacedPartsCount++;
                        var poly = Polygons.First(z => z.id == ssitem.id);
                        totalPartsArea += Math.Abs(GeometryUtil.polygonArea(poly));
                        placed.Add(poly);
                        poly.sheet    = sheet;
                        poly.x        = ssitem.x + sheet.x;
                        poly.y        = ssitem.y + sheet.y;
                        poly.rotation = ssitem.rotation;
                    }
                }
            }

            var emptySheets = Sheets.Where(z => !sheetsIds.Contains(z.id)).ToArray();

            UsedSheetsCount     = Sheets.Count - emptySheets.Length;
            MaterialUtilization = Math.Abs(totalPartsArea / totalSheetsArea);

            var ppps = Polygons.Where(z => !placed.Contains(z));

            foreach (var item in ppps)
            {
                item.x = -1000;
                item.y = 0;
            }
        }