private void TryToRemoveRemainderLines(_Room room, _Line l1, _Line l2) { bool isComplete; try { if (room.Lines.Contains(l1)) { room.Lines.Remove(l1); isComplete = room.CanGetBoundarySorted(); if (!isComplete) { room.Lines.Add(l1); } } } catch (Exception e) { } try { if (room.Lines.Contains(l2)) { room.Lines.Remove(l2); isComplete = room.CanGetBoundarySorted(); if (!isComplete) { room.Lines.Add(l2); } } } catch (Exception e) { } try { if (room.Lines.Contains(l1) && room.Lines.Contains(l2)) { room.Lines.Remove(l1); room.Lines.Remove(l2); isComplete = room.CanGetBoundarySorted(); if (!isComplete) { room.Lines.Add(l1); } if (!isComplete) { room.Lines.Add(l2); } } } catch (Exception e) { } }
private void TryToDivideRoomLinesWithL1L2(_Room room, _Line l1, _Line l2) { bool isComplete = room.CanGetBoundarySorted(); //this might be bad if (!isComplete) { for (int i = 0; i < room.Lines.Count; i++) { _Line chosenLine = room.Lines.ElementAt(i); if (chosenLine.Equals(l1) || chosenLine.Equals(l2)) { continue; } var connectsPoint = chosenLine.ConnectsPoint(l1); if (connectsPoint != null) { _Point otherPoint = l1.EndPoint.Equals(connectsPoint) ? l1.StartPoint : l1.EndPoint; if (IsOnLine(otherPoint, chosenLine)) { if (chosenLine.EndPoint.Equals(connectsPoint)) { chosenLine.EndPoint = otherPoint; } else { chosenLine.StartPoint = otherPoint; } } } connectsPoint = chosenLine.ConnectsPoint(l2); if (connectsPoint != null) { _Point otherPoint = l2.EndPoint.Equals(connectsPoint) ? l2.StartPoint : l2.EndPoint; if (IsOnLine(otherPoint, chosenLine)) { if (chosenLine.EndPoint.Equals(connectsPoint)) { chosenLine.EndPoint = otherPoint; } else { chosenLine.StartPoint = otherPoint; } } } } } isComplete = room.CanGetBoundarySorted(); //we need to check it after the split }