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 class EnhancedEdge : IEquatable<EnhancedEdge>
00015 {
00016 private List<ControlMeshVertex> controlPoints = new List<ControlMeshVertex>();
00017
00018
00019
00020
00021 public List<ControlMeshVertex> ControlPoints
00022 {
00023 get { return controlPoints; }
00024 }
00025
00026 private SimpleEdge edge;
00027
00028 public Point A
00029 {
00030 get { return edge.A; }
00031 }
00032
00033 public Point B
00034 {
00035 get { return edge.B; }
00036 }
00037
00038
00039
00040
00041
00042 public EnhancedEdge(SimpleEdge edge)
00043 {
00044 this.edge = edge;
00045 }
00046
00047
00048
00049
00050
00051 public void SortControlPoints(Point startPoint)
00052 {
00053 List<ControlMeshVertex> sortedPoints = new List<ControlMeshVertex>();
00054
00055 double dist = 1000;
00056 int size = controlPoints.Count;
00057 int deleteIndex = 0;
00058 for (int i = 0; i < size; i++)
00059 {
00060 int count = controlPoints.Count;
00061 for (int d = 0; d < count; d++)
00062 {
00063 double length = (controlPoints[d].Point - startPoint).Length;
00064 if(length < dist){
00065 dist = length;
00066 deleteIndex = d;
00067 }
00068 }
00069
00070 sortedPoints.Add(controlPoints[deleteIndex]);
00071 controlPoints.RemoveAt(deleteIndex);
00072 dist = 1000;
00073 }
00074
00075 controlPoints = sortedPoints;
00076 }
00077
00078
00079
00080
00081 public void AddControlPoint(Point p)
00082 {
00083 if (p != null)
00084 {
00085 ControlMeshVertex v = new ControlMeshVertex(p);
00086 if(!controlPoints.Contains(v))
00087 controlPoints.Add(v);
00088 }
00089 }
00090
00091 public bool Equals(EnhancedEdge other)
00092 {
00093 return this.edge.Equals(other.edge);
00094 }
00095 }
00096 }