Exemplo n.º 1
0
 /// <summary>
 /// Constructor from RSTAB Cross section
 /// </summary>
 /// <param name="cs">RSTAB Cross section to convert</param>
 public RRCrSc(RS_CROSS_SECTION cs)
 {
     this.id = cs.iNo;
     this.mt = null;
     this.ds = cs.strDescription;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor from int, material and cross section description
 /// </summary>
 /// <param name="id">Cross section ID</param>
 /// <param name="mi">Material</param>
 /// <param name="ds">Cross section description</param>
 public RRCrSc(int id, RRMtrl mi, string ds)
 {
     this.id = id;
     this.mt = mi;
     this.ds = ds;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Adds new material into the list
 /// </summary>
 /// <param name="a">Material to add</param>
 public void AddMtrl(RRMtrl a)
 {
     this.mat.Add(a);
 }
Exemplo n.º 4
0
        private string ds;   // cross section description

        /// <summary>
        /// Default constructor
        /// </summary>
        public RRCrSc()
        {
            this.id = 1;
            this.mt = new RRMtrl();
            this.ds = "IPE 100";
        }
Exemplo n.º 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);
            }
        }