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 (var i = 0; i < _pts.Length; i++) { for (var j = 0; j < _pts.Length; j++) { if (i == j) continue; var segResult = false; if (useSegInt) segResult = rectSegIntersector.Intersects(_pts[i], _pts[j]); var 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(); }
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; var segResult = false; if (useSegInt) segResult = rectSegIntersector.Intersects(_pts[i], _pts[j]); var sideResult = false; if (useSideInt) sideResult = rectSideIntersector.Intersects(_pts[i], _pts[j]); if (useSegInt && useSideInt) { if (segResult != sideResult) _isValid = false; } } } }
/// <summary> /// Creates a visitor for checking rectangle intersection with segments /// </summary> /// <param name="rectangle">the query rectangle </param> public RectangleIntersectsSegmentVisitor(IPolygon rectangle) { _rectEnv = rectangle.EnvelopeInternal; _rectIntersector = new RectangleLineIntersector(_rectEnv); }