예제 #1
0
        /// <summary>
        ///     Removes duplicated points in the collection.
        /// </summary>
        /// <param name="pts">The instance to which the method applies.</param>
        /// <param name="tol">The tolerance to use in comparisons.</param>
        public static void RemoveDuplicate(this Point2dCollection pts, Tolerance tol)
        {
            var ptlst = new List <Point2d>();

            for (var i = 0; i < pts.Count; i++)
            {
                ptlst.Add(pts[i]);
            }
            ptlst.Sort((p1, p2) => p1.X.CompareTo(p2.X));
            for (var i = 0; i < ptlst.Count - 1; i++)
            {
                for (var j = i + 1; j < ptlst.Count;)
                {
                    if (ptlst[j].X - ptlst[i].X > tol.EqualPoint)
                    {
                        break;
                    }
                    if (ptlst[i].IsEqualTo(ptlst[j], tol))
                    {
                        pts.Remove(ptlst[j]);
                        ptlst.RemoveAt(j);
                    }
                    else
                    {
                        j++;
                    }
                }
            }
        }