Exemplo n.º 1
0
    static void Main()
    {
        var a = (int)default;

        void C(CS a) => System.Console.Write(a.Exec());

S:
        CS b = new H();

        if (a == default)
        {
            goto W;
        }
        b = new e();
        if (a == 1)
        {
            goto W;
        }
        b = new l();
        if ((a > 1 && a < 4) || a == 9)
        {
            goto W;
        }
        b = new o();
        if (a == 4 || a == 7)
        {
            goto W;
        }
        b = new sp();
        if (a == 5)
        {
            goto W;
        }
        b = new W();
        if (a == 6)
        {
            goto W;
        }
        b = new r();
        if (a == 8)
        {
            goto W;
        }
        b = new d();
        if (a == 10)
        {
            goto W;
        }
        b = new ex();

        W : C(b);
        a++;
        if (a == 12)
        {
            goto E;
        }
        goto S;

        E : return;
    }
Exemplo n.º 2
0
 private static int sp_comp(sp x, sp y)
 {
     if (x.val > y.val)
     {
         return(1);
     }
     if (y.val > x.val)
     {
         return(-1);
     }
     else
     {
         return(0);
     }
 }
Exemplo n.º 3
0
 private static int sp_comp(sp x, sp y)
 {
     if (x.val > y.val)
         return 1;
     if (y.val > x.val)
         return -1;
     else
         return 0;
 }
Exemplo n.º 4
0
        static public kd_node build_kdtree(List <Tri> tris)
        {
            // given a list of triangles, build a kd-tree

            // this should never happen...
            if (tris.Count == 0)
            {
                System.Console.WriteLine("kdtree build ERROR (tris.Count==0)");
                return(new kd_node(0, 0, null, null, tris));
            }

            // if the triangles in this node are contained within
            // a rectangle smaller than XX,
            // OR if only one triangle remains,
            // return a bucket node
            if (tris.Count == 1)
            {
                kd_node bucket_node = new kd_node(0, 0, null, null, tris);
                //System.Console.WriteLine("(tris.Count<=1)returning bucket node with {0} triangles", tris.Count);
                return(bucket_node);
            }

            sp spr = kdtree.spread(tris);

            //System.Console.WriteLine("cuttting along dim={0} spread={1}", spr.d, spr.val);
            //Console.ReadKey();

            // if the max spread is 0, return a bucket node (?when does this happen?)
            if (spr.val == 0.0)
            {
                kd_node bucket_node = new kd_node(0, 0, null, null, tris);
                // System.Console.WriteLine("(spr.val==0) returning bucket node with {0} triangles", tris.Count);
                //foreach (Tri tr in tris)
                //    Console.WriteLine(tr);
                return(bucket_node);
            }

            //return null;

            // otherwise, select at which triangle to cut
            double cv = spr.start + spr.val / 2;
            //System.Console.WriteLine("cutvalue={0}",cv);


            // build lists of triangles lower and higher than cutval
            List <Tri> tris_hi = new List <Tri>();
            List <Tri> tris_lo = new List <Tri>();

            foreach (Tri t in tris)
            {
                // choose which triangles go into which list here.
                t.calc_bbox(); // this is probably not needed.
                if (spr.d == 0)
                {
                    if (t.bb.maxx > cv)
                    {
                        tris_hi.Add(t);
                    }
                    else
                    {
                        tris_lo.Add(t);
                    }
                }
                else if (spr.d == 1)
                {
                    if (t.bb.minx > cv)
                    {
                        tris_hi.Add(t);
                    }
                    else
                    {
                        tris_lo.Add(t);
                    }
                }
                else if (spr.d == 2)
                {
                    if (t.bb.maxy > cv)
                    {
                        tris_hi.Add(t);
                    }
                    else
                    {
                        tris_lo.Add(t);
                    }
                }
                else if (spr.d == 3)
                {
                    if (t.bb.miny > cv)
                    {
                        tris_hi.Add(t);
                    }
                    else
                    {
                        tris_lo.Add(t);
                    }
                }
            }

            if (tris_hi.Count == 0)
            {
                Console.WriteLine("hi-list=0!");
            }

            if (tris_lo.Count == 0)
            {
                Console.WriteLine("lo-list=0!");
            }

            kd_node node = new kd_node();

            node.dim    = spr.d;
            node.cutval = cv;
            //System.Console.WriteLine("hi_count={0}  lo_count={1}", tris_hi.Count, tris_lo.Count);
            // System.Console.ReadKey();

            node.hi = build_kdtree(tris_hi);
            node.lo = build_kdtree(tris_lo);

            return(node);
        }
Exemplo n.º 5
0
 public ActionItem(sp.VoiceAction o)
 {
     ObjRef = o;
 }