/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Mesh mesh1, mesh2; mesh1 = mesh2 = null; double max_distance = Rhino.RhinoMath.UnsetValue; if (!DA.GetData <Mesh>(0, ref mesh1)) { return; } if (!DA.GetData <Mesh>(1, ref mesh2)) { return; } if (!DA.GetData <double>(2, ref max_distance)) { return; } var molecular = mesh1.ToMolecular(); // create molecular structure for second mesh and add into first molecular.Append(mesh2.ToMolecular()); var points = molecular.ToPoint3dArray(); var node3List = new Node3List(points); Node3Tree node3Tree = node3List.CreateTree(0.0, false, 10); if (node3Tree == null) { return; } int max_results = molecular.Nodes.Count - 1; double min_distance = 0; int n = mesh1.Vertices.Count; for (int i = 0; i < n; i++) { Node3Proximity node3Proximity = new Node3Proximity(node3List[i], i, max_results, min_distance, max_distance); node3Tree.SolveProximity(node3Proximity); foreach (var j in node3Proximity.IndexList) { if (j >= n) { molecular.Add(i, j); } } } DA.SetData(0, molecular); DA.SetDataList(1, points); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Mesh mesh = null; double max_distance = Rhino.RhinoMath.UnsetValue; if (!DA.GetData <Mesh>(0, ref mesh)) { return; } if (!DA.GetData <double>(1, ref max_distance)) { return; } int n = mesh.Vertices.Count; var molecular = new Molecular(n); var points = mesh.Vertices.Select(v => (Point3d)v.Position); foreach (var pt in points) { molecular.Add(pt.X, pt.Y, pt.Z); } var node3List = new Node3List(points); Node3Tree node3Tree = node3List.CreateTree(0.0, false, 10); if (node3Tree == null) { return; } int max_results = n - 1; double min_distance = 0; for (int i = 0; i < n; i++) { Node3Proximity node3Proximity = new Node3Proximity(node3List[i], i, max_results, min_distance, max_distance); node3Tree.SolveProximity(node3Proximity); foreach (var j in node3Proximity.IndexList) { molecular.Add(i, j); } } DA.SetData(0, molecular); DA.SetDataList(1, points); }