00001 using System;
00002 using System.Collections.Generic;
00003 using System.Linq;
00004 using System.Text;
00005 using System.Windows;
00006
00007 namespace EdgeClustering
00008 {
00009
00010
00011
00012
00013
00014 public class ControlMeshVertex : IEquatable<ControlMeshVertex>, IComparable<ControlMeshVertex>
00015 {
00016 private double x;
00017
00018 public double X
00019 {
00020 get { return x; }
00021 set { x = value; }
00022 }
00023
00024 private double y;
00025
00026 public double Y
00027 {
00028 get { return y; }
00029 set { y = value; }
00030 }
00031
00032 public Point Point { get { return new Point(x, y); } }
00033
00034
00035
00036
00037
00038
00039 public ControlMeshVertex(double x, double y)
00040 {
00041 this.x = x;
00042 this.y = y;
00043 }
00044
00045
00046
00047
00048
00049 public ControlMeshVertex(Point p)
00050 {
00051 this.x = p.X;
00052 this.y = p.Y;
00053 }
00054
00055
00056 public bool Equals(ControlMeshVertex other)
00057 {
00058 return Math.Abs(this.x - other.x) < 0.0001 && Math.Abs(other.y -this.y) < 0.0001;
00059 }
00060
00061 public override bool Equals(Object obj)
00062 {
00063 if (obj == null) return base.Equals(obj);
00064
00065 if (!(obj is ControlMeshVertex))
00066 throw new InvalidCastException("The 'obj' argument is not a ControlMeshVertex object.");
00067 else
00068 return Equals(obj as ControlMeshVertex);
00069 }
00070
00071
00072 public int CompareTo(ControlMeshVertex other)
00073 {
00074 if (this.y < other.y)
00075 return -1;
00076 if (this.y > other.y)
00077 return 1;
00078
00079 if (this.y == other.y)
00080 {
00081 if (this.x < other.x)
00082 return -1;
00083 if (this.x > other.x)
00084 return 1;
00085 }
00086
00087 return 0;
00088 }
00089 }
00090 }