예제 #1
0
        private static int IgnoreOverlappedBoxes(IList <MModRect> boxes, TestBoxOverlap overlaps)
        {
            var numIgnored = 0;

            for (var i = 0; i < boxes.Count; ++i)
            {
                if (boxes[i].Ignore)
                {
                    continue;
                }

                for (var j = i + 1; j < boxes.Count; ++j)
                {
                    if (boxes[j].Ignore)
                    {
                        continue;
                    }

                    if (overlaps.Operator(boxes[i], boxes[j]))
                    {
                        ++numIgnored;
                        if (boxes[i].Rect.Area < boxes[j].Rect.Area)
                        {
                            boxes[i].Ignore = true;
                        }
                        else
                        {
                            boxes[j].Ignore = true;
                        }
                    }
                }
            }

            return(numIgnored);
        }
예제 #2
0
        private static int IgnoreOverlappedBoxes(IReadOnlyList <TruthInstance> truthInstances, TestBoxOverlap overlaps)

        /*!
         * ensures
         *  - Whenever two rectangles in boxes overlap, according to overlaps(), we set the
         *    smallest box to ignore.
         *  - returns the number of newly ignored boxes.
         * !*/
        {
            var numIgnored = 0;

            for (int i = 0, end = truthInstances.Count; i < end; ++i)
            {
                var boxI = truthInstances[i].MmodRect;
                if (boxI.Ignore)
                {
                    continue;
                }

                for (var j = i + 1; j < end; ++j)
                {
                    var boxJ = truthInstances[j].MmodRect;
                    if (boxJ.Ignore)
                    {
                        continue;
                    }
                    if (overlaps.Operator(boxI, boxJ))
                    {
                        ++numIgnored;
                        if (boxI.Rect.Area < boxJ.Rect.Area)
                        {
                            boxI.Ignore = true;
                        }
                        else
                        {
                            boxJ.Ignore = true;
                        }
                    }
                }
            }

            return(numIgnored);
        }