Esempio n. 1
0
 public TekAreaDef(TekAreaDef value)
 {
     initLists();
     foreach (Point point in value.Points)
     {
         Points.Add(new Point(point.X, point.Y));
     }
     Update();
 }
Esempio n. 2
0
 private void AddAlternatives(TekAreaDef value)
 {
     foreach (TekAreaDef val in value.GetAlternatives())
     {
         if (!val.IsInList(values))
         {
             values.Add(val);
         }
     }
 }
Esempio n. 3
0
        public TekAreaDef Rotate90()
        {
            TekAreaDef result = new TekAreaDef(this.Points[0]);

            foreach (Point value in this.Deltas)
            {
                result.Deltas.Add(new Point(-value.Y, value.X));
                Point p = result.Deltas.ElementAt(result.Deltas.Count - 1);
                result.AddPoint(new Point(this.Points[0].X + p.X, this.Points[0].Y + p.Y));
            }
            return(result);
        }
Esempio n. 4
0
        public TekAreaDef FlipHorizontal()
        {
            TekAreaDef result = new TekAreaDef();
            int        xMax   = xMaximum();

            for (int i = 0; i < Points.Count; i++)
            {
                Point P = Points[i];
                result.AddPoint(new Point(xMax - P.X, P.Y));
            }
            return(result);
        }
Esempio n. 5
0
        public TekAreaDef FlipVertical()
        {
            TekAreaDef result = new TekAreaDef();

            int yMax = yMaximum();

            for (int i = 0; i < Points.Count; i++)
            {
                Point P = Points[i];
                result.AddPoint(new Point(P.X, yMax - P.Y));
            }
            return(result);
        }
Esempio n. 6
0
        private void AddAlternative(TekAreaDef area, List <TekAreaDef> list)
        {
            if (!area.IsInList(list))
            {
                list.Add(area);
            }
            TekAreaDef area2 = area.FlipHorizontal();

            if (!area2.IsInList(list))
            {
                list.Add(area2);
            }
            area2 = area.FlipVertical();
            if (!area2.IsInList(list))
            {
                list.Add(area2);
            }
        }
Esempio n. 7
0
        public bool Equals(TekAreaDef other)
        {
            TekAreaDef N1 = this.Normalized();
            TekAreaDef N2 = other.Normalized();

            if (N1.Points.Count != N2.Points.Count)
            {
                return(false);
            }
            for (int i = 0; i < N1.Points.Count; i++)
            {
                if (N1.Points[i].X != N2.Points[i].X || N1.Points[i].Y != N2.Points[i].Y)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 8
0
        public TekAreaDef GetValue(int i, int nFields)
        {
            int        j      = i;
            TekAreaDef result = null;

            foreach (TekAreaDef value in values)
            {
                if (value.PointCount != nFields)
                {
                    continue;
                }
                if (j == 0)
                {
                    result = value;
                    break;
                }
                j--;
            }
            return(result);
        }
Esempio n. 9
0
        public TekAreaDef Normalized()
        {
            TekAreaDef result = new TekAreaDef(this);

            for (int i = 0; i < Points.Count; i++) // simple bubblesort
            {
                for (int j = i + 1; j < Points.Count; j++)
                {
                    switch (Compare(result.Points[i], result.Points[j]))
                    {
                    case 1:
                        Swap(result.Points, i, j);
                        break;

                    case 0:
                    case -1: break;
                    }
                }
            }
            result.ComputeDeltas();
            result.Shift(-result.xMinimum(), -result.yMinimum());
            return(result);
        }