Пример #1
0
        public void process()
        {
            IList <BoardInfo> usedBoardList    = new List <BoardInfo>();
            BoardInfo         currentBoardInfo = null;

            for (int i = 0; i < this.panels.Count; i++)
            {
                if (outLineInfo == null)
                {
                    outLineInfo = new OutLineInfo();
                }
                if (i == 0)
                {
                    currentBoardInfo = new BoardInfo(this.boardInfo);
                    usedBoardList.Add(currentBoardInfo);

                    Panel panel = Panel.copy(this.panels[i]);

                    panel.setLeftBottomPoint(new Point(0, 0));
                    currentBoardInfo.addPanel(panel);

                    OutLine outLine  = new OutLine(0, panel.Length, panel.Width);
                    OutLine outLine2 = new OutLine(panel.Length, boardInfo.Length, 0);

                    outLineInfo.update(outLine);
                    outLineInfo.update(outLine2);

                    continue;
                }

                IList <OutLine> lowestLines = outLineInfo.getLowestOutline();

                //只有一条最低水平轮廓线
                if (lowestLines.Count == 1)
                {
                    float lineY   = lowestLines[0].Y;
                    float lineLen = lowestLines[0].Length;

                    int matchIndex = -1;
                    searchMatchPanel(ref matchIndex, lineY, lineLen, panels, i);

                    if (matchIndex == -1) //不存在找到合适的零件在当前板材上排放,即需要换新板
                    {
                        currentBoardInfo = new BoardInfo(this.boardInfo);
                        usedBoardList.Add(currentBoardInfo);
                    }
                    else
                    {
                        SwapPanel(i, matchIndex, panels);

                        Panel panel = Panel.copy(this.panels[i]);
                        addPanelAndUpdateOutLine(currentBoardInfo, panel, lowestLines[0]);
                    }
                }
                else
                {
                    OutLine line = null;
                    SearchGoodLine(lowestLines, panels[i].Length, panels[i].Width, out line);

                    //长度能放下
                    if (line != null)
                    {
                        //最低水平线+当前零件高度没有超出边界
                        if ((lowestLines[0].Y + panels[i].Width) <= boardInfo.Width)
                        {
                            addPanelAndUpdateOutLine(currentBoardInfo, Panel.copy(this.panels[i]), line);
                        }
                        else //搜索当前零件后的零件,看高度是否合适
                        {
                            float lineY   = line.Y;
                            float lineLen = line.Length;

                            int matchIndex = -1;
                            searchMatchPanel(ref matchIndex, lineY, lineLen, panels, i);

                            if (matchIndex == -1) //不存在找到合适的零件的高度在当前板材上排放,即需要换新板
                            {
                                currentBoardInfo = new BoardInfo(this.boardInfo);
                                usedBoardList.Add(currentBoardInfo);
                            }
                            else
                            {
                                SwapPanel(i, matchIndex, panels);

                                Panel panel = Panel.copy(this.panels[i]);
                                addPanelAndUpdateOutLine(currentBoardInfo, panel, line);
                            }
                        }
                    }
                    else //长度不合适,查找后面的零件
                    {
                        float minLengh = this.panels.Skip(i + 1).Min(m => m.Length);
                        //TODO:  ////
                    }
                }
            }
        }
Пример #2
0
        /**
         *
         * @param boardInfo 板材描述
         * @param panels 待排板件信息
         */
        public void process(BoardInfo boardInfo, IList <Panel> panels)
        {
            Box2dAlgorithm algorithm = new Box2dAlgorithm(boardInfo, panels);

            algorithm.process();
        }
Пример #3
0
 public Box2dAlgorithm(BoardInfo boardInfo, IList <Panel> panels)
 {
     this.boardInfo = boardInfo;
     this.panels    = panels;
 }
Пример #4
0
 public BoardInfo(BoardInfo info)
 {
     this.width  = info.width;
     this.length = info.length;
 }