/// <summary> /// this is extremely inefficient, avoid this if possible /// supposedly complete, should time it /// </summary> /// <param name="m"></param> private void RemoveRedundancy(_Model m) { ObservableCollection <_Room> rooms = m.rooms; //List<List<_Line>> lines = m.AllLines(); //List<List<List<_Point>>> points = m.AllPoints(); List <_Point> uniquePoints = new List <_Point>(); List <_Line> uniqueLines = new List <_Line>(); //clean points first //TODO: might need to override equals for the contains filter foreach (_Room room in rooms) { foreach (_Line line in room.Lines) { if (uniquePoints.Contains(line.StartPoint)) { line.StartPoint = uniquePoints.Find(i => i.XY == line.StartPoint.XY); } else { uniquePoints.Add(line.StartPoint); } if (uniquePoints.Contains(line.EndPoint)) { line.EndPoint = uniquePoints.Find(i => i.XY == line.EndPoint.XY); } else { uniquePoints.Add(line.EndPoint); } } } //TODO: might need to override equals for the contains filter //clean lines foreach (_Room room in rooms) { foreach (_Line line in room.Lines) { if (uniqueLines.Contains(line)) { //if (oldNewLines.ContainsKey(line)) //{ //} //else { room.Lines.Remove(line); _Line @where = uniqueLines.FirstOrDefault(i => i.IsTheSame(line)) as _Line; if (@where == null || @where.Number == -1) { room.Lines.Add(line); } else { room.Lines.Add(@where); } } } else { uniqueLines.Add(line); } } } }