Advertisement
Guest User

GH/C# Group Curves

a guest
Jun 30th, 2014
589
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. private void RunScript(List<Curve> C, ref object G)
  2. {
  3.     DataTree<Curve> CurveGroups = new DataTree<Curve>();
  4.     bool[] Assigned = new bool[C.Count];
  5.     int PathCounter = 0;
  6.  
  7.     for (int i = 0; i < C.Count; i++)
  8.     {
  9.         if (!Assigned[i])
  10.         {
  11.  
  12.             List<int> GroupIndices = new List<int>();
  13.             GroupIndices.Add(i);
  14.             CurveGroups.Add(C[i], new GH_Path(PathCounter));
  15.             Assigned[i] = true;
  16.  
  17.             do
  18.             {
  19.                 for (int j = 0; j < C.Count; j++)
  20.                 {
  21.  
  22.                     if (j != GroupIndices[0] && !Assigned[j])
  23.                     {
  24.  
  25.                         Rhino.Geometry.Intersect.CurveIntersections CI =       
  26.                         Rhino.Geometry.Intersect.Intersection.CurveCurve(C[GroupIndices[0]], C[j], RhinoDoc.ActiveDoc.ModelAbsoluteTolerance, 0);
  27.  
  28.                         if (CI.Count > 0)
  29.                         {
  30.                             GroupIndices.Add(j);
  31.                             CurveGroups.Add(C[j], new GH_Path(PathCounter));
  32.                             Assigned[j] = true;
  33.                         }
  34.                     }
  35.                 }
  36.  
  37.                 GroupIndices.RemoveAt(0);
  38.             } while (GroupIndices.Count > 0);
  39.             PathCounter += 1;
  40.         }
  41.     }
  42.     G = CurveGroups;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement