Example #1
0
        public void ShouldNotGetMethodInfoWhenRouteAttributeNotSet()
        {
            MethodInfo result;

            result = RouteUtils.GetMethodInfo <BooksRouteHandler>("GetBook3");
            Assert.IsNull(result);
        }
Example #2
0
        private RouteData GetRouteData(string virtualUrl, ParameterList parameters)
        {
            var routeData = RouteUtils.GetRouteDataByUrl(_functionCollection.RouteCollection, virtualUrl);

            var routeDataToUpdate = new List <RouteData> {
                routeData
            };

            object directRouteMatches;

            if (routeData.Values.TryGetValue("MS_DirectRouteMatches", out directRouteMatches))
            {
                var directMatchRouteData = (directRouteMatches as ICollection <RouteData>)?.FirstOrDefault();
                if (directMatchRouteData != null)
                {
                    routeDataToUpdate.Add(directMatchRouteData);
                }
            }

            foreach (var parameterName in parameters.AllParameterNames)
            {
                object value;
                if (parameters.TryGetParameter(parameterName, out value))
                {
                    routeDataToUpdate.ForEach(r => r.Values[parameterName] = value);
                }
            }

            return(routeData);
        }
Example #3
0
        public void ShouldGetMethodInfo()
        {
            MethodInfo result;

            result = RouteUtils.GetMethodInfo <BooksRouteHandler>("GetBook");
            Assert.IsNotNull(result);
        }
Example #4
0
        public void ShouldNotGetMethodInfoWhenNameDoesntMatch()
        {
            MethodInfo result;

            result = RouteUtils.GetMethodInfo <BooksRouteHandler>("GetBook2");
            Assert.IsNull(result);
        }
 public static async Task GetHelloWorld(HttpContext httpContext)
 {
     await RouteUtils.ExecuteRoute <string>(httpContext, async() =>
     {
         return(await Task.FromResult("Hello World"));
     });
 }
Example #6
0
        /// <summary>
        /// This function is required for implementing the IPageExtender interface and will
        /// be called in order to verify that the requested Url is a part of the extended
        /// page or not.
        /// </summary>
        /// <param name="pageId">The id of the page being extended</param>
        /// <param name="remainingSegments">The remaining Url segments from the page and on</param>
        /// <returns></returns>
        public bool HandleRequest(Guid pageId, string[] remainingSegments)
        {
            // We only handle one level of additional paths in this extender
            if (remainingSegments.Length != 1)
            {
                return(false);
            }

            // Check if this was a called for a valid product in our product database
            if (FakeProductDatabase.IsValidProduct(remainingSegments[0]))
            {
                // It was, so lets execute the Product action in our page controller
                // (ProductListPageController). The product list page will be passed
                // to the action by default, but we also need to attach the product id.
                // This is done by adding it to a dictionary of route values.
                var page = PageFactory.GetPage(pageId);
                var additionalRouteData = new Dictionary <string, object> {
                    { "productId", remainingSegments[0] }
                };

                RouteUtils.RedirectToController(page, "product", additionalRouteData);

                return(true);
            }

            // Tell the request handler that the requested Url is unknown
            return(false);
        }
 public void OnProgressChange(Location location, RouteProgress routeProgress)
 {
     if (RouteUtils.IsArrivalEvent(routeProgress))
     {
         lastKnownLocation = location; // Accounts for driver moving after dialog was triggered
         if (!dropoffDialogShown && points.Any())
         {
             ShowDropoffDialog();
             dropoffDialogShown = true; // Accounts for multiple arrival events
         }
     }
 }
        private RouteData GetRouteData(string virtualUrl, ParameterList parameters)
        {
            var routeData = RouteUtils.GetRouteDataByUrl(_functionCollection.RouteCollection, virtualUrl);

            foreach (var parameterName in parameters.AllParameterNames)
            {
                object value;
                if (parameters.TryGetParameter(parameterName, out value))
                {
                    routeData.Values.Add(parameterName, value);
                }
            }

            return(routeData);
        }
Example #9
0
        private static StopByStop.Route GetRouteFromRoutePathId(string routePathId)
        {
            Location fromLocation, toLocation;

            if (RouteUtils.GetRouteLocationsFromRoutePathId(routePathId, out fromLocation, out toLocation))
            {
                var route = StopByStopService.RouteServiceInstance.GetRoute(
                    routePathId,
                    fromLocation,
                    toLocation,
                    new RouteOptions()
                {
                    ExcludeJunctionsWithoutExitInfo = false,
                });

                return(route);
            }

            return(null);
        }
        public static bool IsAssemblyCombineModules(string uniqureId)
        {
            RouteData routeDataByUrl = RouteUtils.GetRouteDataByUrl(uniqureId);

            if (routeDataByUrl == null)
            {
                return(false);
            }
            var areaName = (string)routeDataByUrl.DataTokens["area"];

            if (areaName == null)
            {
                return(false);
            }
            if (AssemblyResourceManager.GetResourceStoreForArea(areaName) == null)
            {
                return(false);
            }
            return(BundleTable.Bundles.GetBundleFor(uniqureId) is SeajsEmbedBundle);
        }
Example #11
0
        static MethodInfos()
        {
            GetBooks = RouteUtils.GetMethodInfo <BooksRouteHandler>("GetBooks");

            GetBook = RouteUtils.GetMethodInfo <BooksRouteHandler>("GetBook");
        }
Example #12
0
        private static int FindBestWireToRoute(Mnet MainNetwork, int BaseSize, List<RouteUtils.Cpoint> Cpoints, int CurrentWireLayer, int CurrentRealLayer, int WireNum, RouteUtils.Wire[] MCWires, char[,] wireMask)
        {
            for (int j = 0; j < Cpoints.Count; j++)
            {
                if (Cpoints[j].UsedLayer == 0)
                    DrawAtMask(wireMask, Cpoints[j].BaseX, Cpoints[j].BaseY + CurrentWireLayer, 1, 2);
            }

            Wire W = MainNetwork.wires[WireNum];

            RouteUtils.Wire MCW = new RouteUtils.Wire(W.SrcName + "-" + W.SrcPort, W.DistName + "-" + W.DistPort);
            //UnmaskStartEndPoint
            RouteUtils.Cpoint SP = FindCpoint(MCW.StartName, Cpoints);
            RouteUtils.Cpoint EP = FindCpoint(MCW.EndName, Cpoints);

            SP.BaseY += CurrentWireLayer;
            EP.BaseY += CurrentWireLayer;

            UnmaskCpoint(wireMask, SP);
            UnmaskCpoint(wireMask, EP);
            //CalcAstar
            int[,] AStarTable = CalcAstar(BaseSize, wireMask, SP, EP);
            SP.BaseY -= CurrentWireLayer;
            EP.BaseY -= CurrentWireLayer;

            return AStarTable[EP.BaseX, EP.BaseY + CurrentWireLayer];
        }
Example #13
0
        private static int[,] CalcAstar(int BaseSize, char[,] wireMask, RouteUtils.Cpoint SP, RouteUtils.Cpoint EP)
        {
            var AStarTable = new int[BaseSize, BaseSize];
            AStarTable[SP.BaseX, SP.BaseY] = 1;
            var lsx = new List<int>();
            var lsy = new List<int>();

            lsx.Add(SP.BaseX);
            lsy.Add(SP.BaseY);

            bool calcing = true;

            while (calcing)
            {
                int[] csx = lsx.ToArray();
                int[] csy = lsy.ToArray();

                lsx = new List<int>();
                lsy = new List<int>();

                int aded = 0;
                for (int i = 0; i < csx.Length; i++)
                {
                    int x = csx[i];
                    int y = csy[i];

                    if (x == EP.BaseX && y == EP.BaseY)
                        calcing = false;

                    if (x > 1 && x < BaseSize - 2 && y > 1 && y < BaseSize - 2)
                    {
                        if (AStarTable[x, y] != 0)
                        {
                            if (AStarTable[x + 1, y] == 0 && wireMask[x + 1, y] != 'X')
                            {
                                AStarTable[x + 1, y] = AStarTable[x, y] + 1;
                                aded++;
                                lsx.Add(x + 1);
                                lsy.Add(y);
                            }
                            if (AStarTable[x - 1, y] == 0 && wireMask[x - 1, y] != 'X')
                            {
                                AStarTable[x - 1, y] = AStarTable[x, y] + 1;
                                aded++;
                                lsx.Add(x - 1);
                                lsy.Add(y);
                            }
                            if (AStarTable[x, y - 1] == 0 && wireMask[x, y - 1] != 'X')
                            {
                                AStarTable[x, y - 1] = AStarTable[x, y] + 1;
                                aded++;
                                lsx.Add(x);
                                lsy.Add(y - 1);
                            }
                            if (AStarTable[x, y + 1] == 0 && wireMask[x, y + 1] != 'X')
                            {
                                AStarTable[x, y + 1] = AStarTable[x, y] + 1;
                                aded++;
                                lsx.Add(x);
                                lsy.Add(y + 1);
                            }
                        }
                    }
                }
                if (aded == 0) calcing = false;
            }
            return AStarTable;
        }
Example #14
0
        private static RouteUtils.Node CutOutputNode(int PlaceLayer, int BaseSize, RouteUtils.Node OutNode)
        {
            //find xs
            int xs = 0;
            int ys = 0;
            int zs = 0;
            for (int i = 1; i < BaseSize; i++)
            {
                int pn = 0;
                for (int y = 0; y < BaseSize; y++)
                {
                    for (int z = 0; z < (PlaceLayer + 10); z++)
                    {
                        if (OutNode.DataMatrix[i, y, z] != "0")
                        {
                            pn++;
                        }
                    }
                }
                if (pn != 0)
                {
                    xs = i - 1;
                    break;
                }
            }

            for (int i = 1; i < BaseSize; i++)
            {
                int pn = 0;
                for (int x = 0; x < BaseSize; x++)
                {
                    for (int z = 0; z < (PlaceLayer + 10); z++)
                    {
                        if (OutNode.DataMatrix[x, i, z] != "0")
                        {
                            pn++;
                        }
                    }
                }
                if (pn != 0)
                {
                    ys = i - 1;
                    break;
                }
            }

            for (int i = 1; i < (PlaceLayer + 10); i++)
            {
                int pn = 0;
                for (int x = 0; x < BaseSize; x++)
                {
                    for (int y = 0; y < BaseSize; y++)
                    {
                        if (OutNode.DataMatrix[x, y, i] != "0")
                        {
                            pn++;
                        }
                    }
                }
                if (pn != 0)
                {
                    zs = i - 1;
                    break;
                }
            }

            int xe = 0;
            int ye = 0;
            int ze = 0;
            for (int i = 1; i < BaseSize; i++)
            {
                int qi = BaseSize - 1 - i;
                int pn = 0;
                for (int y = 0; y < BaseSize; y++)
                {
                    for (int z = 0; z < (PlaceLayer + 10); z++)
                    {
                        if (OutNode.DataMatrix[qi, y, z] != "0")
                        {
                            pn++;
                        }
                    }
                }
                if (pn != 0)
                {
                    xe = qi + 2;
                    break;
                }
            }

            for (int i = 1; i < BaseSize; i++)
            {
                int qi = BaseSize - 1 - i;
                int pn = 0;
                for (int x = 0; x < BaseSize; x++)
                {
                    for (int z = 0; z < (PlaceLayer + 10); z++)
                    {
                        if (OutNode.DataMatrix[x, qi, z] != "0")
                        {
                            pn++;
                        }
                    }
                }
                if (pn != 0)
                {
                    ye = qi + 2;
                    break;
                }
            }

            for (int i = 1; i < (PlaceLayer + 10); i++)
            {
                int qi = (PlaceLayer + 10) - 1 - i;

                int pn = 0;
                for (int x = 0; x < BaseSize; x++)
                {
                    for (int y = 0; y < BaseSize; y++)
                    {
                        if (OutNode.DataMatrix[x, y, qi] != "0")
                        {
                            pn++;
                        }
                    }
                }
                if (pn != 0)
                {
                    ze = qi + 2;
                    break;
                }
            }

            RouteUtils.Node OutNodeO = new RouteUtils.Node("OUT", xe - xs, ye - ys, ze - zs);

            for (int x = xs; x < xe; x++)
            {
                for (int y = ys; y < ye; y++)
                {
                    for (int z = zs; z < ze; z++)
                    {
                        OutNodeO.DataMatrix[x - xs, y - ys, z - zs] = OutNode.DataMatrix[x, y, z];
                    }
                }
            }

            return OutNodeO;
        }
Example #15
0
        private static bool TryPlaceWire(RouteUtils.Cpoint SP, RouteUtils.Cpoint EP, int[,] AStarTable, out List<int> WPX, out List<int> WPY)
        {
            WPX = new List<int>();
            WPY = new List<int>();

            bool Wcalc = true;
            int tx = EP.BaseX;
            int ty = EP.BaseY;
            if (AStarTable[tx, ty] == 0)
                return false;
            while (Wcalc)
            {
                bool R = false;
                WPX.Add(tx);
                WPY.Add(ty);
                //Поиск минимальной точки
                var ways = new int[4];

                ways[0] = AStarTable[tx - 1, ty] - AStarTable[tx, ty];
                ways[1] = AStarTable[tx + 1, ty] - AStarTable[tx, ty];
                ways[2] = AStarTable[tx, ty + 1] - AStarTable[tx, ty];
                ways[3] = AStarTable[tx, ty - 1] - AStarTable[tx, ty];
                if (AStarTable[tx - 1, ty] == 0) ways[0] = -9000;
                if (AStarTable[tx + 1, ty] == 0) ways[1] = -9000;
                if (AStarTable[tx, ty + 1] == 0) ways[2] = -9000;
                if (AStarTable[tx, ty - 1] == 0) ways[3] = -9000;

                int bestWay = 0;
                int bestVal = 9000;
                for (int i = 0; i < ways.Length; i++)
                {
                    if (ways[i] <= bestVal)
                    {
                        if (ways[i] != -9000)
                        {
                            bestWay = i;
                            bestVal = ways[i];
                        }
                    }
                }

                if (bestWay == 0) tx = tx - 1;
                if (bestWay == 1) tx = tx + 1;
                if (bestWay == 2) ty = ty + 1;
                if (bestWay == 3) ty = ty - 1;
                /*
                if (AStarTable[tx - 1, ty] < AStarTable[tx, ty] && AStarTable[tx - 1, ty] != 0 & !R)
                {
                    R = true;
                    tx = tx - 1;
                }

                if (AStarTable[tx + 1, ty] < AStarTable[tx, ty] && AStarTable[tx + 1, ty] != 0 & !R)
                {
                    R = true;
                    tx = tx + 1;
                }

                if (AStarTable[tx, ty + 1] < AStarTable[tx, ty] && AStarTable[tx, ty + 1] != 0 & !R)
                {
                    R = true;
                    ty = ty + 1;
                }

                if (AStarTable[tx, ty - 1] < AStarTable[tx, ty] && AStarTable[tx, ty - 1] != 0 & !R)
                {
                    R = true;
                    ty = ty - 1;
                }
                */
                if (SP.BaseX == tx && SP.BaseY == ty)
                {
                    Wcalc = false;
                    WPX.Add(tx);
                    WPY.Add(ty);
                }
            }
            return true;
        }
Example #16
0
        private static bool TryPlace(Mnet MainNetwork, RouteUtils.Node[] mcNodes, int PlaceLayer, int BaseSize)
        {
            char[,] PlaceMask = new char[BaseSize, BaseSize];

            //PlacePorts
            int potrtx = 1;
            for (int i = 0; i < MainNetwork.nodes.Count; i++)
            {
                if (MainNetwork.nodes[i].NodeType.Contains("Port"))
                {
                    MainNetwork.nodes[i].X = potrtx;
                    MainNetwork.nodes[i].Y = 1;
                    MainNetwork.nodes[i].Z = PlaceLayer;
                    //DrawMask
                    int mx = MainNetwork.nodes[i].X;
                    int my = MainNetwork.nodes[i].Y;
                    int mw = mcNodes[i].SizeX;
                    int mh = mcNodes[i].SizeY;

                    DrawAtMask(PlaceMask, mx, my, mw, mh + 3);

                    potrtx += 4;
                }
            }

            int lastY = 1;
            int lastX = 1;
            for (int i = 0; i < MainNetwork.nodes.Count; i++)
            {
                bool placed = false;
                if (MainNetwork.nodes[i].NodeType.Contains("Port"))
                {
                    placed = true;
                }

                for (int x = lastX; x < BaseSize; x += Dolled)
                {
                    for (int y = 1; y < BaseSize; y += Dolled)
                    {
                        if (!placed)
                        {
                            MainNetwork.nodes[i].X = x;
                            MainNetwork.nodes[i].Y = y;
                            MainNetwork.nodes[i].Z = PlaceLayer;

                            int mx = MainNetwork.nodes[i].X;
                            int my = MainNetwork.nodes[i].Y;
                            int mw = mcNodes[i].SizeX;
                            int mh = mcNodes[i].SizeY;

                            if (CanPlace(PlaceMask, mx, my, mw, mh + 3))
                            {
                                DrawAtMask(PlaceMask, mx, my, mw, mh + 3);
                                placed = true;
                                lastX = x;
                                lastY = y;
                            }
                        }
                    }
                }

                if (!placed)
                    return false;
            }
            return true;
        }
Example #17
0
        private static void PlaceWire(Mnet MainNetwork, int BaseSize, List<RouteUtils.Cpoint> Cpoints, int CurrentWireLayer, int CurrentRealLayer, int WireNum, RouteUtils.Wire[] MCWires, char[,] wireMask, out List<int> WPX, out List<int> WPY)
        {
            //wireMask = new string[BaseSize, BaseSize];

            //PlaceMaskCpoint
            for (int j = 0; j < Cpoints.Count; j++)
            {
                if (Cpoints[j].UsedLayer == 0)
                    DrawAtMask(wireMask, Cpoints[j].BaseX, Cpoints[j].BaseY + CurrentWireLayer, 1, 2);
            }

            Wire W = MainNetwork.wires[WireNum];

            RouteUtils.Wire MCW = new RouteUtils.Wire(W.SrcName + "-" + W.SrcPort, W.DistName + "-" + W.DistPort);
            //UnmaskStartEndPoint
            RouteUtils.Cpoint SP = FindCpoint(MCW.StartName, Cpoints);
            RouteUtils.Cpoint EP = FindCpoint(MCW.EndName, Cpoints);

            SP.BaseY += CurrentWireLayer;
            EP.BaseY += CurrentWireLayer;

            UnmaskCpoint(wireMask, SP);
            UnmaskCpoint(wireMask, EP);
            //CalcAstar
            int[,] AStarTable = CalcAstar(BaseSize, wireMask, SP, EP);

            //DrawWire

            bool placed = TryPlaceWire(SP, EP, AStarTable, out WPX, out WPY);
            if (placed)
            {
                //WireRemask
                for (int i = 0; i < WPX.Count; i++)
                {
                    DrawAtMask(wireMask, WPX[i], WPY[i], 1, 1);
                }

                MCWires[WireNum] = new RouteUtils.Wire(MCW.StartName, MCW.EndName);

                MCWires[WireNum].WirePointX = new int[WPX.Count];
                MCWires[WireNum].WirePointY = new int[WPX.Count];
                MCWires[WireNum].WirePointZ = new int[WPX.Count];

                for (int i = 0; i < WPX.Count; i++)
                {
                    MCWires[WireNum].WirePointX[WPX.Count - i - 1] = WPX[i];
                    MCWires[WireNum].WirePointY[WPX.Count - i - 1] = WPY[i];
                    MCWires[WireNum].WirePointZ[WPX.Count - i - 1] = CurrentRealLayer;
                }
                MainNetwork.wires[WireNum].Placed = true;

                SP.UsedLayer = CurrentWireLayer;
                EP.UsedLayer = CurrentWireLayer;
            }
            SP.BaseY -= CurrentWireLayer;
            EP.BaseY -= CurrentWireLayer;
        }
Example #18
0
        private static void PlaceOptimal(Mnet mainNetwork, RouteUtils.Node[] mcNodes, out int PlaceLayer, out int BaseSize)
        {
            //Расчитать baseSize
            PlaceLayer = 60;
            int xStep = mcNodes.Select(t => t.SizeX).Max() + Dolled;
            int yStep = mcNodes.Select(t => t.SizeY).Max() + Dolled;

            BaseSize = (new int[] { Convert.ToInt32(Math.Sqrt(mcNodes.Length)) * xStep, Convert.ToInt32(Math.Sqrt(mcNodes.Length)) * yStep }).Max() + 60;

            //Разместить порты
            var ports = mainNetwork.nodes.Where(t => t.NodeType.Contains("Port"));
            if (BaseSize < ports.Count() * 5)
            {
                BaseSize = ports.Count()*5 + 60;
            }
            int lastxcoord = 1;
            foreach (var port in ports)
            {
                port.Placed = true;
                port.X = lastxcoord;
                port.Y = 1;
                port.Z = PlaceLayer;
                lastxcoord += mcNodes.FirstOrDefault(t => t.NodeName == port.NodeName).SizeX + Dolled;
            }
            //Расчитать матрицу связоности
            int[,] connectionMatrix = new int[mainNetwork.nodes.Count, mainNetwork.nodes.Count];
            for (int i = 0; i < mainNetwork.nodes.Count; i++)
            {
                for (int j = 0; j < mainNetwork.nodes.Count; j++)
                {
                    connectionMatrix[i, j] = mainNetwork.wires.Where(t => t.SrcName == mainNetwork.nodes[i].NodeName && t.DistName == mainNetwork.nodes[j].NodeName ||
                                                                          t.SrcName == mainNetwork.nodes[j].NodeName && t.DistName == mainNetwork.nodes[i].NodeName).Count();
                }
            }

            //Разместить ноды в ячейки
            var unPlaced = mainNetwork.nodes.Where(t => !t.Placed);
            while (unPlaced.Count() > 0)
            {
                //Поиск нода максимально связанного с установленными
                int[] localConnectionMatrix = new int[mainNetwork.nodes.Count];
                for (int i = 0; i < mainNetwork.nodes.Count; i++)
                {
                    localConnectionMatrix[i] += mainNetwork.wires.Where(t => !mainNetwork.nodes[i].Placed &&
                                                                             (t.SrcName == mainNetwork.nodes[i].NodeName && mainNetwork.nodes.FirstOrDefault(n => n.NodeName == t.DistName).Placed)).Count();
                    localConnectionMatrix[i] += mainNetwork.wires.Where(t => !mainNetwork.nodes[i].Placed &&
                                                                             (t.DistName == mainNetwork.nodes[i].NodeName && mainNetwork.nodes.FirstOrDefault(n => n.NodeName == t.SrcName).Placed)).Count();
                }
                int maxConections = localConnectionMatrix.Max();
                Node nodeToPlace = new Node();
                for (int i = 0; i < mainNetwork.nodes.Count; i++)
                {
                    if (localConnectionMatrix[i] == maxConections)
                    {
                        nodeToPlace = mainNetwork.nodes[i];
                    }
                }
                if (maxConections == 0)
                {
                    nodeToPlace = unPlaced.FirstOrDefault();
                }
                //Поиск места для установки
                int[,] placeMatrix = new int[BaseSize, BaseSize];
                var connectionsa = mainNetwork.wires.Where(k => k.SrcName == nodeToPlace.NodeName).Select(s => mainNetwork.nodes.FirstOrDefault(q => s.DistName == q.NodeName)).Where(l => l.Placed);
                var connectionsb = mainNetwork.wires.Where(k => k.DistName == nodeToPlace.NodeName).Select(s => mainNetwork.nodes.FirstOrDefault(q => s.SrcName == q.NodeName)).Where(l => l.Placed);
                var connections = connectionsa.Union(connectionsb);
                var mcNode = mcNodes.FirstOrDefault(k => k.NodeName == nodeToPlace.NodeName);
                int sizex = mcNode.SizeX + Dolled;
                int sizey = mcNode.SizeY + Dolled;
                var placedNodes = mainNetwork.nodes.Where(t => t.Placed);

                char[,] mask = new char[BaseSize, BaseSize];
                foreach (var node in placedNodes)
                {
                    DrawAtMask(mask, node.X, node.Y, node.McNode.SizeX + 3, node.McNode.SizeY);//При Более близко расположении бывают ошибки
                }

                for (int i = 0; i < BaseSize; i += Step)
                {
                    for (int j = 0; j < BaseSize; j += Step)
                    {
                        //bool collision = placedNodes.Where(t => CheckCollision(t, t.mcNode, i, j, mcNode)).Count() > 0;
                        if (BaseSize > i + sizex + 1 && BaseSize > j + sizey + 1)
                            if (!CheckMaskCollision(mask, nodeToPlace, i, j))
                            {
                                foreach (Node n in connections)
                                {
                                    placeMatrix[i, j] += (n.X - i) * (n.X - i) + (n.Y - j) * (n.Y - j);
                                }
                            }
                    }
                }
                //Установка
                int pcondMin = 90000000;
                int xplace = 0;
                int yplace = 0;
                for (int i = 1; i < BaseSize; i++)
                {
                    for (int j = 1; j < BaseSize; j++)
                    {
                        if (placeMatrix[i, j] < pcondMin && placeMatrix[i, j] > 0)
                        {
                            xplace = i;
                            yplace = j;
                            pcondMin = placeMatrix[i, j];
                        }
                    }
                }
                nodeToPlace.X = xplace;
                nodeToPlace.Y = yplace;
                nodeToPlace.Z = PlaceLayer;
                nodeToPlace.Placed = true;
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine("{0} - Осталось:{1}", nodeToPlace.NodeName, unPlaced.Count());
                Console.ForegroundColor = ConsoleColor.White;
            }
            //foreach(Node node in )

            BaseSize += PlaceLayer;
            //Debug Draw Image
            System.Drawing.Image im = new System.Drawing.Bitmap(BaseSize, BaseSize);
            System.Drawing.Graphics Gr = System.Drawing.Graphics.FromImage(im);
            Gr.Clear(System.Drawing.Color.Black);
            foreach (var node in mainNetwork.nodes)
            {
                Gr.DrawRectangle(System.Drawing.Pens.Green, node.X, node.Y, node.McNode.SizeX, node.McNode.SizeY);
            }
            im.Save("1.png");

            //Увеличить плотность
            //throw new NotImplementedException();
        }
Example #19
0
        private static void PlaceCompact(Mnet MainNetwork, RouteUtils.Node[] mcNodes, out int PlaceLayer, out int BaseSize)
        {
            PlaceLayer = 60;
            int PortNum = CalcPortNum(MainNetwork);

            BaseSize = 5 * PortNum;

            while (!TryPlace(MainNetwork, mcNodes, PlaceLayer, BaseSize))
            {
                BaseSize += 10;
                Console.WriteLine("Размер:" + BaseSize.ToString());
            }
            BaseSize += PlaceLayer;
        }
Example #20
0
        private static void UnmaskCpoint(char[,] WireMask, RouteUtils.Cpoint SP)
        {
            WireMask[SP.BaseX, SP.BaseY] = ' ';
            WireMask[SP.BaseX - 1, SP.BaseY] = ' ';
            WireMask[SP.BaseX + 1, SP.BaseY] = ' ';

            WireMask[SP.BaseX, SP.BaseY + 1] = ' ';
            WireMask[SP.BaseX - 1, SP.BaseY + 1] = ' ';
            WireMask[SP.BaseX + 1, SP.BaseY + 1] = ' ';
        }
Example #21
0
        private static bool CheckCollision(Node t, RouteUtils.Node node1, int i, int j, RouteUtils.Node node2)
        {
            bool result = false;
            result = result || CheckCollisionBoxAndPoint(t.X, t.Y, node1.SizeX + Dolled, node1.SizeY + Dolled, i, j);
            result = result || CheckCollisionBoxAndPoint(t.X, t.Y, node1.SizeX + Dolled, node1.SizeY + Dolled, i + node2.SizeX, j);
            result = result || CheckCollisionBoxAndPoint(t.X, t.Y, node1.SizeX + Dolled, node1.SizeY + Dolled, i, j + node2.SizeY);
            result = result || CheckCollisionBoxAndPoint(t.X, t.Y, node1.SizeX + Dolled, node1.SizeY + Dolled, i + node2.SizeX, j + node2.SizeY);

            result = result || CheckCollisionBoxAndPoint(i, j, node2.SizeX + Dolled, node2.SizeY + Dolled, t.X, t.Y);
            result = result || CheckCollisionBoxAndPoint(i, j, node2.SizeX + Dolled, node2.SizeY + Dolled, t.X + node1.SizeX, t.Y);
            result = result || CheckCollisionBoxAndPoint(i, j, node2.SizeX + Dolled, node2.SizeY + Dolled, t.X, t.Y + node1.SizeY);
            result = result || CheckCollisionBoxAndPoint(i, j, node2.SizeX + Dolled, node2.SizeY + Dolled, t.X + node1.SizeX, t.Y + node1.SizeY);

            return result;
        }
Example #22
0
 private static void PlaceFast(Mnet MainNetwork, RouteUtils.Node[] mcNodes, out int PlaceLayer, out int BaseSize)
 {
     throw new NotImplementedException();
 }
Example #23
0
        private static void UnmaskCpoint(char[,] wireMask, RouteUtils.Cpoint SP)
        {
            wireMask[SP.BaseX, SP.BaseY] = ' ';
            wireMask[SP.BaseX - 1, SP.BaseY] = ' ';
            wireMask[SP.BaseX + 1, SP.BaseY] = ' ';

            wireMask[SP.BaseX, SP.BaseY + 1] = ' ';
            wireMask[SP.BaseX - 1, SP.BaseY + 1] = ' ';
            wireMask[SP.BaseX + 1, SP.BaseY + 1] = ' ';
            //Пробный код

            wireMask[SP.BaseX, SP.BaseY + 2] = ' ';
            //wireMask[SP.BaseX - 1, SP.BaseY - 1] = ' ';
            //wireMask[SP.BaseX + 1, SP.BaseY - 1] = ' ';
        }
Example #24
0
        private static bool TryPlaceWire(RouteUtils.Cpoint SP, RouteUtils.Cpoint EP, int[,] AStarTable, out List<int> WPX, out List<int> WPY)
        {
            WPX = new List<int>();
            WPY = new List<int>();

            bool Wcalc = true;
            int tx = EP.BaseX;
            int ty = EP.BaseY;
            if (AStarTable[tx, ty] == 0)
                return false;
            while (Wcalc)
            {
                bool R = false;
                WPX.Add(tx);
                WPY.Add(ty);
                if (AStarTable[tx - 1, ty] < AStarTable[tx, ty] && AStarTable[tx - 1, ty] != 0 & !R)
                {
                    R = true;
                    tx = tx - 1;
                }

                if (AStarTable[tx + 1, ty] < AStarTable[tx, ty] && AStarTable[tx + 1, ty] != 0 & !R)
                {
                    R = true;
                    tx = tx + 1;
                }

                if (AStarTable[tx, ty + 1] < AStarTable[tx, ty] && AStarTable[tx, ty + 1] != 0 & !R)
                {
                    R = true;
                    ty = ty + 1;
                }

                if (AStarTable[tx, ty - 1] < AStarTable[tx, ty] && AStarTable[tx, ty - 1] != 0 & !R)
                {
                    R = true;
                    ty = ty - 1;
                }
                if (SP.BaseX == tx && SP.BaseY == ty)
                {
                    Wcalc = false;
                    WPX.Add(tx);
                    WPY.Add(ty);
                }
            }
            return true;
        }