Example #1
0
        // ************************************************************************
        /// <summary>
        /// Test for online convex hull
        /// </summary>
        /// <param name="testSet"></param>
        private void ExecuteOneSetOfTest(TestSetOfPoint testSet)
        {
            ConvexHull ch;

            Permutations.ForAllPermutation(testSet.Points, points =>
            {
                bool isIntergrityExceptionHappen;
                do
                {
                    isIntergrityExceptionHappen = false;

                    ch = new ConvexHull();

                    try
                    {
                        foreach (Point pt in points)
                        {
                            ch.TryAddOnePoint(pt);

                            this.Dispatcher.BeginInvoke(new Action(() => DrawPoints(
                                                                       new DrawInfo(testSet.Points, DrawStyle.Point, OxyColors.Aqua),
                                                                       new DrawInfo(ch, DrawStyle.Line, OxyColors.Blue))), DispatcherPriority.Background);

                            Thread.Sleep(10);
                        }
                    }
                    catch (ConvexHullResultIntegrityException)
                    {
                        isIntergrityExceptionHappen = true;
                    }
                } while (isIntergrityExceptionHappen);


                var result = ch.GetResultsAsArrayOfPoint(true);

                DifferencesInPath diffs = ConvexHullUtil.GetPathDifferences("Online", points, testSet.ExpectedResult, result);
                if (diffs.HasErrors)
                {
                    Debugger.Break();
                }

                return(ExecutionState.Continue);
            });
        }