// Attributed to Gilles. But I made some very minor modifications.
// WARNING: Implement the EqualityComparer<T> abstract class, rather than the
// IEqualityComparer<T> interface. This is because the MS documentation recommends
// that you do so.
private class Point3dComparer : IEqualityComparer<Point3d>
{
private Tolerance tolerance;
public Point3dComparer()
: this(Tolerance.Global)
{
}
public Point3dComparer(Tolerance tolerance)
{
this.tolerance = tolerance;
}
public bool Equals(Point3d pt1, Point3d pt2)
{
return pt1.IsEqualTo(pt2, tolerance);
}
public int GetHashCode(Point3d pt)
{
var d = tolerance.EqualPoint * 2.0;
return new Point3d(
Math.Round(pt.X / d),
Math.Round(pt.Y / d),
Math.Round(pt.Z / d)).GetHashCode();
}
}
// get polyline points:
List<Point3d> layoutPoints = layoutPolyline.GetPolylinePoints().ToList();
List<Point3d> shopdrawingPoints = shopDrawingPolyline.GetPolylinePoints().ToList();
PointsUtility.Point3dComparer pointComparer = new PointsUtility.Point3dComparer(t);
// Now if the two lists have the same elements but in a different order, then
// SequenceEqual will return false.
bool pointsEqual = layoutPoints.SequenceEqual(shopdrawingPoints, pointComparer);