예제 #1
0
 public void Detach(CMPoint point)
 {
     pointsDict.Remove(point.Id);
     pointsList.Remove(point);
     if (point.Contains(this))
     {
         point.Detach(this);
     }
 }
예제 #2
0
        private CMPoint CreatePoint(int id)
        {
            CMPoint point = new CMPoint(this, id);

            primitives.Add(point.Id, point);
            if (PointCreated != null)
            {
                PointCreated(this, point);
            }
            return(point);
        }
예제 #3
0
        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);
        }
예제 #4
0
 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);
     }
 }
예제 #5
0
 // возвращает общую прямую, если она есть и null, если ее нет
 public CMLine GetCommonLine(CMPoint point)
 {
     return(lines.Values.FirstOrDefault(line => line.Contains(point)));
 }
예제 #6
0
 public bool Contains(CMPoint point)
 {
     return(pointsDict.ContainsKey(point.Id));
 }
예제 #7
0
 public void Insert(int index, CMPoint point)
 {
     pointsDict.Add(point.Id, point);
     pointsList.Insert(index, point);
     point.Attach(this);
 }
예제 #8
0
 public void PushPointBack(CMPoint point)
 {
     PushPointBack(point.Id);
 }
예제 #9
0
 public void PushPointFront(CMPoint point)
 {
     PushPointFront(point.Id);
 }
예제 #10
0
 public bool Contains(CMPoint point)
 {
     return(lines.Values.Any(line => line.Contains(point)));
 }