System.Collections.Generic.List.Add(xy)

Here are the examples of the csharp api System.Collections.Generic.List.Add(xy) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

19 Source : tri.cs
with Apache License 2.0
from ericsink

internal static void Triangulate2d(List<Triangle2d> tris, List<xy> pts)
        {
            if (pts.Count == 3)
            {
                if (!ut.PointsAreCollinear2d(pts[0], pts[1], pts[2]))
                {
                    tris.Add(new Triangle2d(pts[0], pts[1], pts[2]));
                }
                return;
            }

            // TODO we could optimize the 4 pt case here

            for (int i0 = 0, i1 = 1, i2 = 2; i0 < pts.Count; i0++, i1 = (i1 + 1) % pts.Count, i2 = (i2 + 1) % pts.Count)
            {
                if (
                    (!ut.PointsAreCollinear2d(pts[i0], pts[i1], pts[i2]))
                    && (ut.IsDiagonal(pts, i0, i2))
                    )
                {
                    tris.Add(new Triangle2d(pts[i0], pts[i1], pts[i2]));
                    List<xy> sublist = new List<xy>();
                    for (int j = 0; j < pts.Count; j++)
                    {
                        if (j != i1)
                        {
                            sublist.Add(pts[j]);
                        }
                    }
                    Triangulate2d(tris, sublist);
                    return;
                }
            }
        }

19 Source : triangleint2d.cs
with Apache License 2.0
from ericsink

public void Add(xy p)
        {
            if (pts == null)
            {
                pts = new List<xy>();
            }

            foreach (xy q in pts)
            {
                if (fp.eq_inches(p, q))
                {
                    return;
                }
            }

            pts.Add(p);
        }

19 Source : ppi2d.cs
with Apache License 2.0
from ericsink

public static void FindTheLoops(List<List<xy>> loops, List<seg2d> segs)
        {
#if not
            bool bTricky = need_to_find_loop_starting_point(segs);
#endif
            while (segs.Count > 0)
            {
                List<xy> pts = new List<xy>();
                seg2d cur;
#if not
                if (bTricky)
                {
                    cur = find_loop_starting_point(segs);
                }
                else
#endif
                {
                    cur = segs[0];
                }
                pts.Add(cur.a);
                pts.Add(cur.b);
                segs.Remove(cur);
                xy p0 = cur.a;
                xy plast = cur.b;
                while (true)
                {
                    xy next;
                    cur = seg2d.find_seg_a(segs, plast, out next);
                    Debug.replacedert(cur != null);
                    segs.Remove(cur);
                    if (fp.eq_inches(next, p0))
                    {
                        // loop closed
                        break;
                    }
                    pts.Add(next);
                    plast = next;
                }
                loops.Add(pts);
            }
        }

19 Source : ppi2d.cs
with Apache License 2.0
from ericsink

public static void FindTheLoops(List<List<xy>> loops, List<seg2d> segs)
        {
#if not
            bool bTricky = need_to_find_loop_starting_point(segs);
#endif
            while (segs.Count > 0)
            {
                List<xy> pts = new List<xy>();
                seg2d cur;
#if not
                if (bTricky)
                {
                    cur = find_loop_starting_point(segs);
                }
                else
#endif
                {
                    cur = segs[0];
                }
                pts.Add(cur.a);
                pts.Add(cur.b);
                segs.Remove(cur);
                xy p0 = cur.a;
                xy plast = cur.b;
                while (true)
                {
                    xy next;
                    cur = seg2d.find_seg_a(segs, plast, out next);
                    Debug.replacedert(cur != null);
                    segs.Remove(cur);
                    if (fp.eq_inches(next, p0))
                    {
                        // loop closed
                        break;
                    }
                    pts.Add(next);
                    plast = next;
                }
                loops.Add(pts);
            }
        }