/// <summary> /// Constructor from two nodes /// </summary> /// <param name="a">First node</param> /// <param name="b">Second node</param> public RREdge(RRNode a, RRNode b) { this.or = false; this.sn = a; this.en = b; this.cs = null; }
/// <summary> /// Constructor from a Grasshopper curve /// </summary> /// <param name="a">Grasshopper curve</param> public RREdge(GH_Curve a) { this.or = false; this.sn = new RRNode(0, a.Value.PointAtStart); this.en = new RRNode(0, a.Value.PointAtEnd); this.cs = null; }
/// <summary> /// Gets members from RSTAB /// </summary> /// <param name="a">If true the read dummy members</param> private void GetRSTABMember(bool a) { int mc = 0; try { mc = IData.rsGetMemberCount(); } catch (Exception e) { ecd = ErrCode.RSTABMBCN; ems = e.Message; epl = this.GetType().Name + "->" + MethodBase.GetCurrentMethod().Name; return; } try { RS_MEMBER[] ms = new RS_MEMBER[mc]; IData.rsGetMemberArr(mc, ms); foreach (RS_MEMBER m in ms) { RRNode sn, en; sn = new RRNode(IData.rsGetNode(m.iStartNodeNo, ITEM_AT.AT_NO).rsGetData()); en = new RRNode(IData.rsGetNode(m.iEndNodeNo, ITEM_AT.AT_NO).rsGetData()); RREdge ed = new RREdge { ID = m.iNo, StartNode = sn, EndNode = en, CrossSection = this.obj.GetCrCsByNo(m.iStartCrossSectionNo) }; //zero node if (a) { if (m.type.GetHashCode() != 7) { this.obj.AddEdge(ed, false); } } else { this.obj.AddEdge(ed, false); } } } catch (Exception e) { ecd = ErrCode.RSTABMMBR; ems = e.Message; epl = this.GetType().Name + "->" + MethodBase.GetCurrentMethod().Name; } }
/// <summary> /// Sets node in RSTAB /// </summary> /// <param name="a">Node to create in RSTAB</param> private void SetRSTABNode(RRNode a) { try { IData.rsSetNode(a.GetRSNode()); } catch (Exception e) { ecd = ErrCode.RSTABNODE; ems = e.Message; epl = this.GetType().Name + "->" + MethodBase.GetCurrentMethod().Name; } }
/// <summary> /// Sets supports in RSTAB /// </summary> /// <param name="a">Node for supporting</param> /// <param name="i">Support ID</param> /// <param name="b">Anchor points list</param> /// <param name="c">Tolerance</param> private void SetRSTABSupport(RRNode a, ref int i, List <Point3d> b, double c) { Point3d k = a.GetPoint3d(); foreach (Point3d p in b) { try { if (p.DistanceTo(k) <= c) { IData.rsSetNodeSupport(new RS_NODE_SUPPORT { ID = (i).ToString(), iNo = i++, rotationSequence = 0, f*X = -1, fuY = -1, fuZ = -1, fPhiX = 0, fPhiY = 0, fPhiZ = -1, strNodeList = (a.ID).ToString() }); break; } } catch (Exception e) { ecd = ErrCode.RSTABSUPP; ems = e.Message; epl = this.GetType().Name + "->" + MethodBase.GetCurrentMethod().Name; } if (ecd != ErrCode.NONE) { return; } } }
/// <summary> /// Adds new node into the list /// </summary> /// <param name="a">Node to add</param> public void AddNode(RRNode a) { this.nds.Add(a); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { GH_Structure <GH_Curve> cr = new GH_Structure <GH_Curve>(); // curves tree List <Point3d> ap = new List <Point3d>(); // anchor points List <string> cl = new List <string>(); // cross section list double tl = new Double(); // tolerance bool xm = false; // export model into RSTAB bool rm = true; // remove structural data #region checking input params if (!DA.GetDataTree(0, out cr)) { return; } if (!DA.GetData(1, ref tl)) { tl = -1; } ; if (tl <= 0) { tl = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance; } DA.GetDataList(2, ap); DA.GetDataList(3, cl); if (!DA.GetData(4, ref xm)) { return; } if (xm == false) { return; } if (!DA.GetData(5, ref rm)) { return; } #endregion var w = Stopwatch.StartNew(); #region graph creation int pid = 1, bid = 1; RRObject ro = new RRObject(); RRMtrl mt = new RRMtrl(); ro.AddMtrl(mt); foreach (List <GH_Curve> lc in cr.Branches) { string dsc = "IPE 100"; if (cl.Count >= bid) { dsc = cl[bid - 1]; } ro.AddCrCs(new RRCrSc { ID = bid, Material = mt, Description = dsc }); // check any curve and build the graph from the points foreach (GH_Curve curve in lc) { RRNode p1, p2; bool b1, b2; p1 = p2 = null; b1 = b2 = true; foreach (RRNode rn in ro.Nodes) { Point3d p = rn.GetPoint3d(); if (b1) { if (curve.Value.PointAtStart.DistanceTo(p) <= tl) { b1 = false; p1 = rn; } } if (b2) { if (curve.Value.PointAtEnd.DistanceTo(p) <= tl) { b2 = false; p2 = rn; } } if (!b1 && !b2) { break; } } if (b1) { p1 = new RRNode(pid++, curve.Value.PointAtStart); ro.AddNode(p1); } if (b2) { p2 = new RRNode(pid++, curve.Value.PointAtEnd); ro.AddNode(p2); } RREdge re = new RREdge { StartNode = p1, EndNode = p2, CrossSection = ro.CrCss[bid - 1] }; ro.AddEdge(re, true); } bid++; } #endregion RRConverter rrc = new RRConverter(ro); rrc.Rhino2RSTAB(ap, tl, rm); w.Stop(); if (rrc.ErrorCode == 0) { DA.SetData(1, "No Errors occured\nExport time " + (w.Elapsed.TotalMilliseconds / 1000).ToString("~0.00 sec")); } else { DA.SetData(1, rrc.ErrorCode + " " + rrc.ErrorMessage); } }