Пример #1
0
        internal void VerifyVisibilityGraph(RectilinearEdgeRouterWrapper router)
        {
            Validate.AreEqual(this.fileVertexCount, router.VisibilityGraph.VertexCount, "Graph vertex count difference");
            Validate.AreEqual(this.fileEdgeCount, router.VisibilityGraph.EdgeCount, "Graph edge count difference");

            // If the vertices and edges were stored to the file, verify them.
            if (0 != this.VisibilityGraph.VertexCount)
            {
                foreach (var fileVertex in this.VisibilityGraph.Vertices())
                {
                    Validate.IsNotNull(router.VisibilityGraph.FindVertex(fileVertex.Point), "Cannot find file vertex in router graph");
                }
                foreach (var routerVertex in router.VisibilityGraph.Vertices())
                {
                    Validate.IsNotNull(this.VisibilityGraph.FindVertex(routerVertex.Point), "Cannot find router vertex in file graph");
                }
                foreach (var fileEdge in this.VisibilityGraph.Edges)
                {
                    Validate.IsNotNull(VisibilityGraph.FindEdge(fileEdge), "Cannot find file edge in router graph");
                }
                foreach (var routerEdge in router.VisibilityGraph.Edges)
                {
                    Validate.IsNotNull(VisibilityGraph.FindEdge(routerEdge), "Cannot find router edge in file graph");
                }
            }
        }
Пример #2
0
        private void VerifyThatAllRouterHullsAreInFile(RectilinearEdgeRouterWrapper router)
        {
            foreach (var routerHull in router.ObstacleTree.GetAllPrimaryObstacles().Where(obs => obs.ConvexHull != null).Select(obs => obs.ConvexHull))
            {
                var routerSiblings = routerHull.Obstacles.Select(obs => this.shapeToIdMap[obs.InputShape]).OrderBy(id => id).ToArray();
                var fileHull       = this.shapeIdToConvexHullMap[routerSiblings.First()];
                fileHull.RouterAccretion = routerHull;
                VerifyOrderedSiblingLists(fileHull.SiblingIds, routerSiblings);     // SiblingIds are already ordered

                // This may be null if -nowriteConvexHulls
                if (fileHull.Polyline != null)
                {
                    this.VerifyPolylinesAreSame(fileHull.Polyline, routerHull.Polyline);
                }

                // Convex Hulls can exist for both groups and non-groups.  For groups, there should only be one obstacle,
                // the group, in the hull.
                var firstSibling = this.idToShapeMap[routerSiblings.First()];
                if (firstSibling.IsGroup)
                {
                    Validate.AreEqual(1, routerSiblings.Count(), "only one item should be in a convex hull for a group");
                }
                else
                {
                    Validate.IsFalse(routerSiblings.Any(sib => this.idToShapeMap[sib].IsGroup), "group found with non-groups in a convex hull");
                }
            }
        }
        internal RectFileWriter(RectilinearEdgeRouterWrapper router,
                RectilinearVerifier verifier,
                Dictionary<Port, Shape> freeRelativePortToShapeMap = null,
                bool writeGraph = true,
                bool writePaths = true,
                bool writeScanSegments = true,
                bool writePaddedObstacles = true,
                bool writeConvexHulls = true,
                bool useFreePortsForObstaclePorts = false
            ) 
        {
            this.router = router;
            this.verifier = verifier;
            this.freeRelativePortToShapeMap = freeRelativePortToShapeMap;

            this.writeGraph = writeGraph;
            this.writePaths = writePaths;
            this.writeScanSegments = writeScanSegments;
            this.writePaddedObstacles = writePaddedObstacles;
            this.writeConvexHulls = writeConvexHulls;

            this.useFreePortsForObstaclesPorts = useFreePortsForObstaclePorts;
            this.useSparseVisibilityGraph = router.UseSparseVisibilityGraph;
            this.useObstacleRectangles = router.UseObstacleRectangles;
            this.bendPenalty = router.BendPenaltyAsAPercentageOfDistance;
            this.limitPortVisibilitySpliceToEndpointBoundingBox = router.LimitPortVisibilitySpliceToEndpointBoundingBox;

            // Don't leave these null - they'll be overwritten by caller in most cases.
            this.RandomObstacleArg = RectFileStrings.NullStr;
            this.RandomObstacleDensity = RectFileStrings.NullStr;
        }
        internal RectFileWriter(RectilinearEdgeRouterWrapper router,
                RectilinearVerifier verifier,
                Dictionary<Port, Shape> freeRelativePortToShapeMap = null,
                bool writeGraph = true,
                bool writePaths = true,
                bool writeScanSegments = true,
                bool writePaddedObstacles = true,
                bool writeConvexHulls = true,
                bool useFreePortsForObstaclePorts = false
            ) 
        {
            this.router = router;
            this.verifier = verifier;
            this.freeRelativePortToShapeMap = freeRelativePortToShapeMap;

            this.writeGraph = writeGraph;
            this.writePaths = writePaths;
            this.writeScanSegments = writeScanSegments;
            this.writePaddedObstacles = writePaddedObstacles;
            this.writeConvexHulls = writeConvexHulls;

            this.useFreePortsForObstaclesPorts = useFreePortsForObstaclePorts;
            this.useSparseVisibilityGraph = router.UseSparseVisibilityGraph;
            this.useObstacleRectangles = router.UseObstacleRectangles;
            this.bendPenalty = router.BendPenaltyAsAPercentageOfDistance;
            this.limitPortVisibilitySpliceToEndpointBoundingBox = router.LimitPortVisibilitySpliceToEndpointBoundingBox;

            // Don't leave these null - they'll be overwritten by caller in most cases.
            this.RandomObstacleArg = RectFileStrings.NullStr;
            this.RandomObstacleDensity = RectFileStrings.NullStr;
        }
Пример #5
0
 public void VerifyRouter(RectilinearEdgeRouterWrapper router)
 {
     if (router.WantVerify)
     {
         VerifyVisibilityGraph(router);
         VerifyPaths(router);
     }
 }
Пример #6
0
        private IEnumerable <EdgeGeometry> CreateSourceToFreePortRoutings(RectilinearEdgeRouterWrapper router,
                                                                          List <Shape> obstacles, IEnumerable <FloatingPort> freePorts)
        {
            var routings = CreateSourceToFreePortRoutings(obstacles, this.DefaultSourceOrdinal, freePorts);

            this.UpdateObstaclesForSourceOrdinal(obstacles, this.DefaultSourceOrdinal, router);
            return(routings);
        }
 internal override void LoadAndProcessFile(string fileName)
 {
     // BasicFileProcessor provides exception management.
     using (var reader = new RectFileReader(fileName, fileRoundingDigits))
     {
         Router = routingFunc(reader);
         Verify(Router, reader);
     }
 }
 internal override void LoadAndProcessFile(string fileName)
 {
     // BasicFileProcessor provides exception management.
     using (var reader = new RectFileReader(fileName, fileRoundingDigits))
     {
         Router = routingFunc(reader);
         Verify(Router, reader);
     }
 }
Пример #9
0
 internal void VerifyConvexHulls(RectilinearEdgeRouterWrapper router)
 {
     if (this.convexHullIdToAccretionMap.Count == 0)
     {
         return;
     }
     VerifyThatAllRouterHullsAreInFile(router);
     VerifyThatAllFileHullsAreInRouter(router);
 }
Пример #10
0
 internal void VerifyClumps(RectilinearEdgeRouterWrapper router)
 {
     if (this.clumpIdToAccretionMap.Count == 0)
     {
         return;
     }
     VerifyThatAllRouterClumpsAreInFile(router);
     VerifyThatAllFileClumpsAreInRouter(router);
 }
Пример #11
0
 private void VerifyThatAllRouterClumpsAreInFile(RectilinearEdgeRouterWrapper router)
 {
     foreach (var routerClump in router.ObstacleTree.GetAllPrimaryObstacles().Where(obs => obs.IsOverlapped).Select(obs => obs.Clump).Distinct())
     {
         var routerSiblings = routerClump.Select(obs => this.shapeToIdMap[obs.InputShape]).OrderBy(id => id).ToArray();
         var fileClump      = this.shapeIdToClumpMap[routerSiblings.First()];
         fileClump.RouterAccretion = routerClump;
         VerifyOrderedSiblingLists(fileClump.SiblingIds, routerSiblings);    // SiblingIds are already ordered
     }
 }
 private static void Verify(RectilinearEdgeRouterWrapper router, RectFileReader reader)
 {
     if (router.WantVerify) {
         reader.VerifyObstaclePaddedPolylines(router.ObstacleTree.GetAllObstacles());
         reader.VerifyClumps(router);
         reader.VerifyConvexHulls(router);
         reader.VerifyVisibilityGraph(router);
         reader.VerifyScanSegments(router);
     }
 }
 private static void Verify(RectilinearEdgeRouterWrapper router, RectFileReader reader)
 {
     if (router.WantVerify)
     {
         reader.VerifyObstaclePaddedPolylines(router.ObstacleTree.GetAllObstacles());
         reader.VerifyClumps(router);
         reader.VerifyConvexHulls(router);
         reader.VerifyVisibilityGraph(router);
         reader.VerifyScanSegments(router);
     }
 }
Пример #14
0
        private void VerifyThatAllFileHullsAreInRouter(RectilinearEdgeRouterWrapper router)
        {
            foreach (var fileHull in this.convexHullIdToAccretionMap.Values)
            {
                var firstSibling  = this.idToShapeMap[fileHull.SiblingIds.First()];
                var firstObstacle = router.ShapeToObstacleMap[firstSibling];

                // We've already verified all the router hulls, so we now just need to know that we do have a router hull.
                Validate.AreSame(fileHull.RouterAccretion, firstObstacle.ConvexHull, "Convex hull from file was not found in router");
            }
        }
Пример #15
0
        private void VerifyPaths(RectilinearEdgeRouterWrapper router)
        {
            IEnumerable <EdgeGeometry> routerEdgeGeometries = router.EdgeGeometriesToRoute;

            foreach (EdgeGeometry routerEdgeGeom in routerEdgeGeometries.Where(edgeGeom => null != edgeGeom.Curve))
            {
                Curve fileCurve;
                if (this.portsToPathMap.TryGetValue(new Tuple <Port, Port>(routerEdgeGeom.SourcePort, routerEdgeGeom.TargetPort), out fileCurve))
                {
                    var routerCurve = (Curve)routerEdgeGeom.Curve;      // This is currently always a Curve
                    this.VerifyCurvesAreSame(fileCurve, routerCurve);
                }
            }
        }
 internal virtual void ShowGraph(RectilinearEdgeRouterWrapper router) { }
 internal virtual void ShowIncrementalGraph(RectilinearEdgeRouterWrapper router) { }
        private void VerifyThatAllRouterHullsAreInFile(RectilinearEdgeRouterWrapper router) {
            foreach (var routerHull in router.ObstacleTree.GetAllPrimaryObstacles().Where(obs => obs.ConvexHull != null).Select(obs => obs.ConvexHull))
            {
                var routerSiblings = routerHull.Obstacles.Select(obs => this.shapeToIdMap[obs.InputShape]).OrderBy(id => id).ToArray();
                var fileHull = this.shapeIdToConvexHullMap[routerSiblings.First()];
                fileHull.RouterAccretion = routerHull;
                VerifyOrderedSiblingLists(fileHull.SiblingIds, routerSiblings);     // SiblingIds are already ordered

                // This may be null if -nowriteConvexHulls
                if (fileHull.Polyline != null)
                {
                    this.VerifyPolylinesAreSame(fileHull.Polyline, routerHull.Polyline);
                }

                // Convex Hulls can exist for both groups and non-groups.  For groups, there should only be one obstacle,
                // the group, in the hull.
                var firstSibling = this.idToShapeMap[routerSiblings.First()];
                if (firstSibling.IsGroup) 
                {
                    Validate.AreEqual(1, routerSiblings.Count(), "only one item should be in a convex hull for a group");
                }
                else
                {
                    Validate.IsFalse(routerSiblings.Any(sib => this.idToShapeMap[sib].IsGroup), "group found with non-groups in a convex hull");
                }
            }
        }
Пример #19
0
 internal virtual void ShowGraph(RectilinearEdgeRouterWrapper router)
 {
 }
 private IEnumerable<EdgeGeometry> CreateSourceToFreePortRoutings(RectilinearEdgeRouterWrapper router,
         List<Shape> obstacles, IEnumerable<FloatingPort> freePorts)
 {
     var routings = CreateSourceToFreePortRoutings(obstacles, this.DefaultSourceOrdinal, freePorts);
     this.UpdateObstaclesForSourceOrdinal(obstacles, this.DefaultSourceOrdinal, router);
     return routings;
 }
Пример #21
0
 internal void VerifyScanSegments(RectilinearEdgeRouterWrapper router)
 {
     this.VerifyAxisScanSegments(this.HorizontalScanLineSegments, router.HorizontalScanLineSegments, "Horizontal ScanSegment");
     this.VerifyAxisScanSegments(this.VerticalScanLineSegments, router.VerticalScanLineSegments, "Vertical ScanSegment");
 }
Пример #22
0
 internal virtual void ShowInitialObstacles(RectilinearEdgeRouterWrapper router)
 {
 }
 public void VerifyRouter(RectilinearEdgeRouterWrapper router)
 {
     if (router.WantVerify)
     {
         VerifyVisibilityGraph(router);
         VerifyPaths(router);
     }
 }
 private void WriteRectFile(RectilinearEdgeRouterWrapper router, string fileName)
 {
     // For these small tests we write everything and have no freeOports.
     using (var writer = new RectFileWriter(router, this))
     {
         writer.WriteFile(fileName);
     }
 }
 private void VerifyThatAllRouterClumpsAreInFile(RectilinearEdgeRouterWrapper router) {
     foreach (var routerClump in router.ObstacleTree.GetAllPrimaryObstacles().Where(obs => obs.IsOverlapped).Select(obs => obs.Clump).Distinct())
     {
         var routerSiblings = routerClump.Select(obs => this.shapeToIdMap[obs.InputShape]).OrderBy(id => id).ToArray();
         var fileClump = this.shapeIdToClumpMap[routerSiblings.First()];
         fileClump.RouterAccretion = routerClump;
         VerifyOrderedSiblingLists(fileClump.SiblingIds, routerSiblings);    // SiblingIds are already ordered
     }
 }
 internal void VerifyVisibilityGraph(RectilinearEdgeRouterWrapper router)
 {
     Validate.AreEqual(this.fileVertexCount, router.VisibilityGraph.VertexCount, "Graph vertex count difference");
     
     // If the vertices and edges were stored to the file, verify them.
     if (0 != this.VisibilityGraph.VertexCount)
     {
         foreach (var fileVertex in this.VisibilityGraph.Vertices())
         {
             Validate.IsNotNull(router.VisibilityGraph.FindVertex(fileVertex.Point), "Cannot find file vertex in router graph");
         }
         foreach (var routerVertex in router.VisibilityGraph.Vertices())
         {
             Validate.IsNotNull(this.VisibilityGraph.FindVertex(routerVertex.Point), "Cannot find router vertex in file graph");
         }
         foreach (var fileEdge in this.VisibilityGraph.Edges)
         {
             Validate.IsNotNull(VisibilityGraph.FindEdge(fileEdge), "Cannot find file edge in router graph");
         }
         foreach (var routerEdge in router.VisibilityGraph.Edges)
         {
             Validate.IsNotNull(VisibilityGraph.FindEdge(routerEdge), "Cannot find router edge in file graph");
         }
     }
 }
        private void VerifyThatAllFileHullsAreInRouter(RectilinearEdgeRouterWrapper router)
        {
            foreach (var fileHull in this.convexHullIdToAccretionMap.Values)
            {
                var firstSibling = this.idToShapeMap[fileHull.SiblingIds.First()];
                var firstObstacle = router.ShapeToObstacleMap[firstSibling];

                // We've already verified all the router hulls, so we now just need to know that we do have a router hull.
                Validate.AreSame(fileHull.RouterAccretion, firstObstacle.ConvexHull, "Convex hull from file was not found in router");
            }
        }
 private void UpdateObstaclesForSourceOrdinal(List<Shape> obstacles, int sourceOrdinal, RectilinearEdgeRouterWrapper router) {
     for (var idxScan = 0; idxScan < obstacles.Count; ++idxScan)
     {
         if ((idxScan != this.DefaultSourceOrdinal) && (sourceOrdinal >= 0))
         {
             continue;
         }
         router.UpdateObstacle(obstacles[idxScan]);
         if (idxScan == this.DefaultSourceOrdinal)
         {
             break;
         }
     }
 }
 internal void VerifyClumps(RectilinearEdgeRouterWrapper router) {
     if (this.clumpIdToAccretionMap.Count == 0)
     {
         return;
     }
     VerifyThatAllRouterClumpsAreInFile(router);
     VerifyThatAllFileClumpsAreInRouter(router);
 }
Пример #30
0
 private void UpdateObstaclesForSourceOrdinal(List <Shape> obstacles, int sourceOrdinal, RectilinearEdgeRouterWrapper router)
 {
     for (var idxScan = 0; idxScan < obstacles.Count; ++idxScan)
     {
         if ((idxScan != this.DefaultSourceOrdinal) && (sourceOrdinal >= 0))
         {
             continue;
         }
         router.UpdateObstacle(obstacles[idxScan]);
         if (idxScan == this.DefaultSourceOrdinal)
         {
             break;
         }
     }
 }
 internal void VerifyScanSegments(RectilinearEdgeRouterWrapper router)
 {
     this.VerifyAxisScanSegments(this.HorizontalScanLineSegments, router.HorizontalScanLineSegments, "Horizontal ScanSegment");
     this.VerifyAxisScanSegments(this.VerticalScanLineSegments, router.VerticalScanLineSegments, "Vertical ScanSegment");
 }
Пример #32
0
 internal virtual void ShowIncrementalGraph(RectilinearEdgeRouterWrapper router)
 {
 }
 internal virtual void ShowInitialObstacles(RectilinearEdgeRouterWrapper router) { }
 private void VerifyPaths(RectilinearEdgeRouterWrapper router)
 {
     IEnumerable<EdgeGeometry> routerEdgeGeometries = router.EdgeGeometriesToRoute;
     foreach (EdgeGeometry routerEdgeGeom in routerEdgeGeometries.Where(edgeGeom => null != edgeGeom.Curve))
     {
         Curve fileCurve;
         if (this.portsToPathMap.TryGetValue(new Tuple<Port, Port>(routerEdgeGeom.SourcePort, routerEdgeGeom.TargetPort), out fileCurve))
         {
             var routerCurve = (Curve)routerEdgeGeom.Curve;      // This is currently always a Curve
             this.VerifyCurvesAreSame(fileCurve, routerCurve);
         }
     }
 }
 internal void VerifyConvexHulls(RectilinearEdgeRouterWrapper router)
 {
     if (this.convexHullIdToAccretionMap.Count == 0) 
     {
         return;
     }
     VerifyThatAllRouterHullsAreInFile(router);
     VerifyThatAllFileHullsAreInRouter(router);
 }