示例#1
0
        public void CloseContour(ILIneFactory factory)
        {
            RemoveLines();

            if (curContour.myPoints.Count < 2)
            {
                curContour.lines.Clear();
            }
            if (curContour.myPoints.Count == 2)
            {
                if (curContour.lines.Count > 1)
                {
                    RemoveLastLine();
                }
                curContour.lines.Add(factory.Create(lastPoint, firstPoint));
            }
            if (curContour.myPoints.Count > 2)
            {
                /*if (factory.Create(lastPoint, firstPoint).TypeEqualTo(curContour.lines.Last()))
                 * return;*/
                RemoveLastLine();
                curContour.lines.Add(factory.Create(lastPoint, firstPoint));
            }
            RemoveLines();
        }
示例#2
0
        private void DeletePoint(ILIneFactory factory, int n)
        {
            /*for (int i = 0; i < curContour.lines.Count; i++)
             * {
             *  foreach(MyPoint p in curContour.lines[i].GetPoints())
             *  {
             *      if (p.EqualTo(curContour.myPoints[n]))
             *      {
             *          curContour.lines[i] = factory.Create(curContour.myPoints[n - 1 >= 0 ? n - 1: curContour.myPoints.Count - n - 1],
             *              curContour.myPoints[curContour.myPoints.Count > n + 1 ? n + 1 : n + 1 - curContour.myPoints.Count]);
             *          break;
             *      }
             *  }
             * }*/
            //int i = n / 2;

            if (curContour.lines.Count > n)
            {
                curContour.lines.RemoveAt(n);
            }
            if (curContour.lines.Count == 1)
            {
                curContour.myPoints.RemoveAt(n);
                return;
            }
            int i = n - 1 >= 0 ? n - 1 : curContour.lines.Count - 1;

            // curContour.lines.RemoveAt(i);
            curContour.lines[i] = factory.Create(curContour.myPoints[n - 1 >= 0 ? n - 1 : curContour.myPoints.Count - n - 1],
                                                 curContour.myPoints[curContour.myPoints.Count > n + 1 ? n + 1 : n + 1 - curContour.myPoints.Count]);
            curContour.myPoints.RemoveAt(n);
            //lastPoint = curContour.myPoints.Last();*/
        }
示例#3
0
 public void PointIn(PointF p, ILIneFactory factory, ILIneFactory fact, ScreenConverter sc)
 {
     if (curContour != null)
     {
         int n = SearchMyPoint(p, sc);
         if (n != -1)
         {
             curPoint = curContour.myPoints[n];
             if (curContour.myPoints[n].Current)
             {
                 curContour.myPoints[n].Current = false;
             }
             else
             {
                 curContour.myPoints[n].Current = true;
             }
             return;
         }
         if (SearchPoint(p, sc) != null)
         {
             curPoint = SearchPoint(p, sc);
             return;
         }
         else
         {
             if (lastPoint == null)
             {
                 curContour.myPoints.Add(new MyPoint(sc.XX((int)p.X), sc.YY((int)p.Y)));
                 if (curContour.myPoints.Count == 1)
                 {
                     curContour.myPoints[0].First = true;
                     firstPoint = curContour.myPoints[0];
                 }
                 lastPoint = curContour.myPoints.Last();
             }
             else
             {
                 if (curContour.myPoints.Count >= 2)
                 {
                     RemoveLastLine();
                 }
                 MyPoint curP = new MyPoint(sc.XX((int)p.X), sc.YY((int)p.Y));
                 curContour.lines.Add(factory.Create(lastPoint, curP));
                 curContour.myPoints.Add(curP);
                 lastPoint = curContour.myPoints.Last();
             }
             if (curContour.myPoints.Count >= 2)
             {
                 CloseContour(fact);
             }
         }
     }
 }