private void RunCompare(bool useSegInt, bool useSideInt)
        {
            var rectSegIntersector  = new RectangleLineIntersector(_rectEnv);
            var rectSideIntersector = new SimpleRectangleIntersector(_rectEnv);

            for (int i = 0; i < _pts.Length; i++)
            {
                for (int j = 0; j < _pts.Length; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    bool segResult = false;
                    if (useSegInt)
                    {
                        segResult = rectSegIntersector.Intersects(_pts[i], _pts[j]);
                    }
                    bool sideResult = false;
                    if (useSideInt)
                    {
                        sideResult = rectSideIntersector.Intersects(_pts[i], _pts[j]);
                    }

                    if (useSegInt && useSideInt)
                    {
                        if (segResult != sideResult)
                        {
                            _isValid = false;
                        }
                    }
                }
            }
        }
        public void Run(bool useSegInt, bool useSideInt)
        {
            if (useSegInt)
            {
                Console.WriteLine("Using Segment Intersector");
            }
            if (useSideInt)
            {
                Console.WriteLine("Using Side Intersector");
            }

            Console.WriteLine("# pts: " + _pts.Length);

            var rectSegIntersector  = new RectangleLineIntersector(_rectEnv);
            var rectSideIntersector = new SimpleRectangleIntersector(_rectEnv);

            var sw = new Stopwatch();

            sw.Start();

            for (int i = 0; i < _pts.Length; i++)
            {
                for (int j = 0; j < _pts.Length; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    bool segResult = false;
                    if (useSegInt)
                    {
                        segResult = rectSegIntersector.Intersects(_pts[i], _pts[j]);
                    }
                    bool sideResult = false;
                    if (useSideInt)
                    {
                        sideResult = rectSideIntersector.Intersects(_pts[i], _pts[j]);
                    }

                    if (useSegInt && useSideInt)
                    {
                        if (segResult != sideResult)
                        {
                            throw new ApplicationException("Seg and Side values do not match");
                        }
                    }
                }
            }
            sw.Stop();
            Console.WriteLine("Finished in " + sw.Elapsed);
            Console.WriteLine();
        }
예제 #3
0
        private void CheckIntersectionWithSegments(ICurve testLine)
        {
            var seq1 = testLine.CoordinateSequence;

            for (var j = 1; j < seq1.Count; j++)
            {
                seq1.GetCoordinate(j - 1, _p0);
                seq1.GetCoordinate(j, _p1);

                if (!_rectIntersector.Intersects(_p0, _p1))
                {
                    continue;
                }
                Intersects = true;
                return;
            }
        }
예제 #4
0
        private void CheckIntersectionWithSegments(LineString testLine)
        {
            var seq1 = testLine.CoordinateSequence;

            for (int j = 1; j < seq1.Count; j++)
            {
                _p0.X = seq1.GetX(j - 1);
                _p0.Y = seq1.GetY(j - 1);

                _p1.X = seq1.GetX(j);
                _p1.Y = seq1.GetY(j);

                if (!_rectIntersector.Intersects(_p0, _p1))
                {
                    continue;
                }
                Intersects = true;
                return;
            }
        }