Exemple #1
0
        public static void RemoveDuplicate(Point2dCollection pts, Tolerance tol)
        {
            var ptlst = pts.Cast <Point2d>().ToList();

            //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++;
                    }
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Removes duplicated points in the collection according to the specified tolerance.
 /// </summary>
 /// <param name="source">The instance to which the method applies.</param>
 /// <param name="tolerance">The tolerance to be used in equality comparison.</param>
 /// <returns>A sequence of disitnct points.</returns>
 public static IEnumerable <Point2d> RemoveDuplicates(this Point2dCollection source, Tolerance tolerance)
 {
     return(source.Cast <Point2d>().Distinct(new Point2dComparer()));
 }
Exemple #3
0
 /// <summary>
 /// Removes duplicated points in the collection using Tolerance.Global.
 /// </summary>
 /// <param name="source">The instance to which the method applies.</param>
 /// <returns>A sequence of distinct points.</returns>
 public static IEnumerable <Point2d> RemoveDuplicates(this Point2dCollection source)
 {
     return(source.Cast <Point2d>().RemoveDuplicates(Tolerance.Global));
 }