public TekAreaDef(TekAreaDef value) { initLists(); foreach (Point point in value.Points) { Points.Add(new Point(point.X, point.Y)); } Update(); }
private void AddAlternatives(TekAreaDef value) { foreach (TekAreaDef val in value.GetAlternatives()) { if (!val.IsInList(values)) { values.Add(val); } } }
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); }
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); }
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); }
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); } }
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); }
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); }
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); }