Пример #1
0
        /// <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;
            }
        }
Пример #2
0
 /// <summary>
 /// Check if RSTAB edge in the list
 /// </summary>
 /// <param name="le">list of RSTAB edges</param>
 /// <param name="re">RSTAB edge to find in the list</param>
 /// <returns>True if the edge in the list, false if there is no such edges in the list</returns>
 private bool haveEdge(List <RREdge> a, RREdge b)
 {
     foreach (RREdge e in a)
     {
         if (e.Equals(b))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #3
0
 /// <summary>
 /// Sets member in RSTAB
 /// </summary>
 /// <param name="a">Edge to create in RSTAB</param>
 /// <param name="i">Edge ID</param>
 private void SetRSTABMember(RREdge a, ref int i)
 {
     try
     {
         IData.rsSetMember(a.GetRSMember(i++));
     }
     catch (Exception e)
     {
         ecd = ErrCode.RSTABMMBR;
         ems = e.Message;
         epl = this.GetType().Name + "->" + MethodBase.GetCurrentMethod().Name;
     }
 }
Пример #4
0
 /// <summary>
 /// Adds new edge into the list
 /// </summary>
 /// <param name="a">Edge to add</param>
 public void AddEdge(RREdge a, bool b)
 {
     if (!b)
     {
         this.edg.Add(a);
     }
     else
     {
         if (!haveEdge(this.edg, a))
         {
             this.edg.Add(a);
         }
     }
 }
Пример #5
0
        /// <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);
            }
        }