Domain shift for SubSurfaces(Panels) C# -A logic Problem


#1

Hi all,

I am trying to build a panel component that shifts the panel rows.
My desired result would be this:

What I get so far:

My code:

 private void RunScript(Surface srf, List<double> u, List<double> v, int shift, ref object A, ref object B)
  {

    double vShift = v[1] / shift;
    var domains = new List<Interval>();
    List<Surface> srfs = new List<Surface>();
    for (int i = 0; i < u.Count - 1; i++)
    {
      for (int j = 0; j < v.Count - 1; j++)
      {

        Interval uVal = new Interval(u[i], u[i + 1]);
        Interval vVal = new Interval(v[j] + (vShift * i), v[j + 1] + (vShift * i));
        Surface srfT = srf.Trim(uVal, vVal);
        srfs.Add(srfT);
        domains.Add(vVal);


      }
    }
    A = srfs;
    B = domains;
  }
 

My file:20181206_ShiftDomain.gh (6.4 KB)
I hope it is not that far away.
Thanks everybody!


#2

I just got it.
If anybody needs the same at some point here is the code:


  private void RunScript(Surface srf, List<double> u, List<double> v, int shift, ref object A, ref object B)
  {

    double vShift = v[1] / shift;
    var domains = new List<Interval>();
    List<Surface> srfs = new List<Surface>();

    for (int i = 0; i < u.Count - 1; i++)
    {
      for (int j = 0; j < v.Count - 1; j++)
      {
        double v1 = v[j] + (vShift * i);
        double v2 = v[j + 1] + (vShift * i);

        if (v1 >= 0 && v1 < 1)
        {
          if (v2 > 0 || v2 < 1)
          {
            Interval uVal = new Interval(u[i], u[i + 1]);
            Interval vVal = new Interval(v1, v2);
            Surface srfT = srf.Trim(uVal, vVal);
            srfs.Add(srfT);
            domains.Add(vVal);
          }
        }
      }
    }



    for (int i = 0; i < u.Count - 1; i++)
    {
      for (int j = 0; j < v.Count - 1; j++)
      {
        double v1 = v[j] + (vShift * i) - 1;
        double v2 = v[j + 1] + (vShift * i) - 1;
        
        if (v1 > 0 || v1 < 1)
        {
          if (v2 > 0 && v2 < 1)
          {
            Interval uVal = new Interval(u[i], u[i + 1]);
            Interval vVal = new Interval(v1, v2);
            Surface srfT = srf.Trim(uVal, vVal);
            srfs.Add(srfT);
            domains.Add(vVal);
          }
        }
      }
    }

    A = srfs;
    B = domains;
  }