/// <summary> /// Divides the contours in this reigon and creates a front. /// </summary> public Front DivideContours(out double idealDistance) { Front front = new Front(this.Contours[0].Divide(out idealDistance)); for (int i = 1; i < this.Contours.Count; i++) { double d; Front f = new Front(Contours[i].Divide(out d)); if (d < idealDistance) idealDistance = d; front.Join(f); } // Mark edge points. foreach (Point point in front.InitialPoints) { point.IsEdgePoint = true; } return front; }
public HashSet<Segment> GetNearbySegments(Front front, int cellDistance) { HashSet<Segment> segments = new HashSet<Segment>(); foreach (Point p in front.NeighbourAreaPoints(this.Start, cellDistance)) { foreach (Segment segment in p.Segments) { segments.Add(segment); } } foreach (Point p in front.NeighbourAreaPoints(this.End, cellDistance)) { foreach (Segment segment in p.Segments) { segments.Add(segment); } } return segments; }
/// <summary> /// Determines whether the front has at least one commmon /// point with another front. /// </summary> //public bool HasCommonPointWith(Front other) //{ // foreach (Point point in this.Points) // { // foreach (Point otherPoint in other.Points) // { // if (point.Equals(otherPoint)) // return true; // } // } // return false; //} public void Join(Front front) { foreach (Point p in front.GetInitialPoints()) { this.InitialPoints.Add(p); } List<Segment> segments = front.GetSegmentsUnordered(); foreach (Segment segment in segments) { this.AddSegment(segment); } }