/// <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) { // 1. Declare placeholder variables var struts = new List <Curve>(); double tol = 0.0; // 2. Attempt to retrieve input if (!DA.GetDataList(0, struts)) { return; } if (!DA.GetData(1, ref tol)) { return; } // 3. Validate input if (struts == null || struts.Count == 1) { return; } if (tol < 0) { return; } // 4. Call cleaning method var nodes = new Point3dList(); var nodePairs = new List <IndexPair>(); struts = FrameTools.CleanNetwork(struts, tol, out nodes, out nodePairs); // 5. Organize index lists var strutStart = new List <int>(); var strutEnd = new List <int>(); foreach (IndexPair nodePair in nodePairs) { strutStart.Add(nodePair.I); strutEnd.Add(nodePair.J); } // 6. Set output DA.SetDataList(0, struts); DA.SetDataList(1, nodes); DA.SetDataList(2, strutStart); DA.SetDataList(3, strutEnd); }
/// <summary> /// Instace constructor based on a list of curves (i.e. a lattice). /// </summary> public ExoMesh(List <Curve> struts) { m_hulls = new List <ExoHull>(); m_sleeves = new List <ExoSleeve>(); m_plates = new List <ExoPlate>(); m_mesh = new Mesh(); double tol = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance; // First, we convert the struts to a list of unique nodes and node pairs // We use the following lists to extract valid data from the input list var nodeList = new Point3dList(); // List of unique nodes var nodePairList = new List <IndexPair>(); // List of struts, as node index pairs struts = FrameTools.CleanNetwork(struts, tol, out nodeList, out nodePairList); // Set hull locations foreach (Point3d node in nodeList) { m_hulls.Add(new ExoHull(node)); } // Create sleeves, plates and relational indices for (int i = 0; i < struts.Count; i++) { m_sleeves.Add(new ExoSleeve(struts[i], nodePairList[i])); // Construct plates m_plates.Add(new ExoPlate(nodePairList[i].I, struts[i].TangentAtStart)); m_plates.Add(new ExoPlate(nodePairList[i].J, -struts[i].TangentAtEnd)); // Set sleeve relational parameters IndexPair platePair = new IndexPair(m_plates.Count - 2, m_plates.Count - 1); m_sleeves[i].PlatePair = platePair; // Set hull relational parameters m_hulls[nodePairList[i].I].SleeveIndices.Add(i); m_hulls[nodePairList[i].J].SleeveIndices.Add(i); m_hulls[nodePairList[i].I].PlateIndices.Add(platePair.I); m_hulls[nodePairList[i].J].PlateIndices.Add(platePair.J); } }