示例#1
0
    //<Custom additional code>
    //Calculates the Depth for each curve on a list of Curves
    private int CalculateDepth(Curve x, List<Curve> y)
    {
        foreach (Curve crv in y)
        {
          crv.SetUserString("D", "nil");
        }

        int depth = 0;

        Queue<Curve> Q = new Queue<Curve>();
        int d = 0;
        x.SetUserString("D", d.ToString());
        Q.Enqueue(x);

        while (Q.Count > 0)
        {
          Curve c = Q.Dequeue();
          int val = Convert.ToInt32(c.GetUserString("D"));
          depth = depth + val;
          Print(depth.ToString());

          List<Curve> connected = FindIntersectingCurves(c, y);
          foreach (Curve crv in connected)
          {
        if (c.GetUserString("D") == "nil")
        {
          d = val + 1;
          crv.SetUserString("D", d.ToString());
          Q.Enqueue(crv);
        }
          }
        }

        return depth;
    }