public void Detach(CMPoint point) { pointsDict.Remove(point.Id); pointsList.Remove(point); if (point.Contains(this)) { point.Detach(this); } }
private CMPoint CreatePoint(int id) { CMPoint point = new CMPoint(this, id); primitives.Add(point.Id, point); if (PointCreated != null) { PointCreated(this, point); } return(point); }
public int DetectDir(CMPoint start, CMPoint end) { if (!Contains(start) || !Contains(end)) { throw new ArgumentException("Both points must be attached to the line (line id: " + Id + ")"); } if (start == end) { return(0); } var result = pointsList.Find(point => point == start || point == end); return(result == start ? 1 : -1); }
public CMAngle(int id, CMPoint start, CMPoint end1, CMPoint end2, int?angle = null) : base(start.Owner, id) { Point = start; Line1 = start.GetCommonLine(end1); Line2 = start.GetCommonLine(end2); this.angle = angle; if (Line1.DetectDir(start, end1) > 1) { Dir = (Line2.DetectDir(start, end2) > 1 ? AngleDir.FrontFront : AngleDir.FrontBack); } else { Dir = (Line2.DetectDir(start, end2) > 1 ? AngleDir.BackFront : AngleDir.BackBack); } }
// возвращает общую прямую, если она есть и null, если ее нет public CMLine GetCommonLine(CMPoint point) { return(lines.Values.FirstOrDefault(line => line.Contains(point))); }
public bool Contains(CMPoint point) { return(pointsDict.ContainsKey(point.Id)); }
public void Insert(int index, CMPoint point) { pointsDict.Add(point.Id, point); pointsList.Insert(index, point); point.Attach(this); }
public void PushPointBack(CMPoint point) { PushPointBack(point.Id); }
public void PushPointFront(CMPoint point) { PushPointFront(point.Id); }
public bool Contains(CMPoint point) { return(lines.Values.Any(line => line.Contains(point))); }