Exemple #1
0
        public void ShamosHoey_HasIntersectionsTest()
        {
            int n        = 6000;
            var segments = new List <Segment>();

            for (int i = 0; i < n / 2; i++)
            {
                segments.Add(
                    new Segment(
                        new Coordinate {
                    x = i / (double)n, y = i
                },
                        new Coordinate {
                    x = i / (double)n + 100, y = 100 + i
                }));

                segments.Add(
                    new Segment(
                        new Coordinate {
                    x = i / (double)n, y = i + n
                },
                        new Coordinate {
                    x = i / (double)n + 100, y = 100 + i + n
                }));
            }
            var  shamosHoey = new ShamosHoey(segments);
            bool expected   = false;
            bool actual     = shamosHoey.HasIntersections();

            Assert.AreEqual(expected, actual);
        }
Exemple #2
0
        public bool IsSimple()
        {
            if (IsEmptyPath())
            {
                return(true);
            }
            var segments = Segments;

            if (segments.Count <= 1)
            {
                return(true);
            }
            var sh = new ShamosHoey(segments);

            if (sh.HasIntersections())
            {
                return(false);
            }
            return(true);
        }
Exemple #3
0
        public void ShamosHoey_SelfIntersectingPolygonTest()
        {
            var g = new Polygon
            {
                Rings = new List <Path>
                {
                    new Path
                    {
                        Coordinates = new List <Coordinate>
                        {
                            new Coordinate {
                                x = 1, y = 1
                            },
                            new Coordinate {
                                x = 2, y = 5
                            },
                            new Coordinate {
                                x = 4, y = 0
                            },
                            new Coordinate {
                                x = 4, y = 2
                            },
                            new Coordinate {
                                x = 1, y = 1
                            },
                        }
                    }
                }
            };

            var  shamosHoey = new ShamosHoey(g.Rings[0].Segments);
            bool expected   = true;
            bool actual     = shamosHoey.HasIntersections();

            Assert.AreEqual(expected, actual);
        }