コード例 #1
0
ファイル: Grid.cs プロジェクト: leolzc7/CloudMapSystem
 public void getGlobalInfo(ModuleOne[] modules, List <RelationOperator.relation> relation, int[] rows, int[] columns)
 {
     foreach (RelationOperator.relation relationOne in relation)
     {
         ModuleOne moduleSource = modules[ModuleOne.GetIndex(modules, relationOne.sourceName)];
         ModuleOne moduleTarget = modules[ModuleOne.GetIndex(modules, relationOne.targetName)];
         int       com          = moduleSource.compareModuleAdd(moduleTarget);
         computeRowColumn(moduleSource, moduleTarget, com, rows, columns);
     }
 }
コード例 #2
0
ファイル: Grid.cs プロジェクト: leolzc7/CloudMapSystem
        public void setRouteForModules(ModuleOne[] modules, List <RelationOperator.relation> relation, int[] rows, int[] columns, List <ModuleOne.LineInfo> allLine)
        {
            ModuleOne.gapy = ModuleOne.mody - ModuleOne.getHeight();
            ModuleOne.gapx = ModuleOne.modx - ModuleOne.getWidth();

            int[] step_column = new int[columns.Length]; //记录每个区域的划分间隔
            int[] step_row    = new int[rows.Length];
            int[] r           = new int[rows.Length];    //记录每个区域已被划分的线的数量
            int[] c           = new int[columns.Length];
            for (int m = 0; m < rows.Length; m++)
            {
                step_column[m] = ModuleOne.gapy / (rows[m] + 1);
                step_row[m]    = ModuleOne.gapx / (columns[m] + 1);
            }
            step_column[0] = ModuleOne.gapy / (2 * rows[0] + 1);                                   //最上面区域的划分间隔适当减小
            step_row[columns.Length - 1] = ModuleOne.gapx / (2 * columns[columns.Length - 1] + 1); //最右边区域的划分间隔减小
            GridPoint start  = null;
            GridPoint target = null;

            foreach (RelationOperator.relation relationOne in relation)
            {
                ModuleOne moduleSource = modules[ModuleOne.GetIndex(modules, relationOne.sourceName)];
                ModuleOne moduleTarget = modules[ModuleOne.GetIndex(modules, relationOne.targetName)];
                string    bidirection  = relationOne.bidirection;
                string    relationName = relationOne.relationName;
                string    comment      = relationOne.comment;
                int       show         = relationOne.show;
                int       com          = moduleSource.compareModuleAdd(moduleTarget);
                int       numMax       = 0; //记录上下或左右有直连关系时,模块的引脚数量的最大值
                //根据模块的位置关系分配引脚
                switch (com)
                {
                case 1:
                    numMax = Math.Max(moduleSource.getNumNorth(), moduleTarget.getNumSouth());
                    start  = moduleSource.northPin(GridPoint.myGrid, com, numMax);
                    target = moduleTarget.southPin(GridPoint.myGrid, com, numMax);
                    break;

                case 2:
                case 8:
                    start  = moduleSource.northPin(GridPoint.myGrid, com, numMax);
                    target = moduleTarget.southPin(GridPoint.myGrid, com, numMax);
                    break;

                case 3:
                    numMax = Math.Max(moduleSource.getNumEast(), moduleTarget.getNumWest());
                    start  = moduleSource.eastPin(GridPoint.myGrid, com, numMax);
                    target = moduleTarget.westPin(GridPoint.myGrid, com, numMax);
                    break;

                case 11:
                case 13:
                    start  = moduleSource.eastPin(GridPoint.myGrid, com, numMax);
                    target = moduleTarget.westPin(GridPoint.myGrid, com, numMax);
                    break;

                case 5:
                    numMax = Math.Max(moduleSource.getNumSouth(), moduleTarget.getNumNorth());
                    start  = moduleSource.southPin(GridPoint.myGrid, com, numMax);
                    target = moduleTarget.northPin(GridPoint.myGrid, com, numMax);
                    break;

                case 6:
                case 4:
                    start  = moduleSource.southPin(GridPoint.myGrid, com, numMax);
                    target = moduleTarget.northPin(GridPoint.myGrid, com, numMax);
                    break;

                case 7:
                    numMax = Math.Max(moduleSource.getNumWest(), moduleTarget.getNumEast());
                    start  = moduleSource.westPin(GridPoint.myGrid, com, numMax);
                    target = moduleTarget.eastPin(GridPoint.myGrid, com, numMax);
                    break;

                case 9:
                case 15:
                    start  = moduleSource.westPin(GridPoint.myGrid, com, numMax);
                    target = moduleTarget.eastPin(GridPoint.myGrid, com, numMax);
                    break;

                case 10:
                case 14:
                    start  = moduleSource.eastPin(GridPoint.myGrid, com, numMax);
                    target = moduleTarget.eastPin(GridPoint.myGrid, com, numMax);
                    break;

                case 12:
                case 16:
                    start  = moduleSource.northPin(GridPoint.myGrid, com, numMax);
                    target = moduleTarget.northPin(GridPoint.myGrid, com, numMax);
                    break;

                case 17:
                    start  = moduleSource.northPin(GridPoint.myGrid, com, numMax);
                    target = moduleTarget.eastPin(GridPoint.myGrid, com, numMax);
                    break;

                case 18:
                    start  = moduleSource.northPin(GridPoint.myGrid, com, numMax);
                    target = moduleTarget.westPin(GridPoint.myGrid, com, numMax);
                    break;

                case 19:
                    start  = moduleSource.southPin(GridPoint.myGrid, com, numMax);
                    target = moduleTarget.westPin(GridPoint.myGrid, com, numMax);
                    break;

                case 20:
                    start  = moduleSource.southPin(GridPoint.myGrid, com, numMax);
                    target = moduleTarget.eastPin(GridPoint.myGrid, com, numMax);
                    break;

                default:
                    Console.WriteLine("no left pin");
                    break;
                }
                List <int[]> lineOnePath = Route(start, target, com, rows, columns, r, c, step_row, step_column, moduleSource, moduleTarget, bidirection);
                saveLine(lineOnePath, allLine, relationName, comment, show);
            }
        }