예제 #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <object> seles  = new List <object>();
            double        intTol = 0.005;
            double        segTol = 0.5;

            if (!DA.GetDataList(0, seles))
            {
                return;
            }
            if (!DA.GetData(1, ref intTol))
            {
                return;
            }
            if (!DA.GetData(2, ref segTol))
            {
                return;
            }

            string          modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString();
            sRhinoConverter rhcon     = new sRhinoConverter(modelUnit, "Meters");

            if (modelUnit == "Feet")
            {
                intTol = 0.015;
                segTol = 1.5;
            }

            List <object>    pelements    = new List <object>();
            List <IFrameSet> beamelements = new List <IFrameSet>();

            foreach (object o in seles)
            {
                GH_ObjectWrapper wap   = new GH_ObjectWrapper(o);
                IFrameSet        bsori = wap.Value as IFrameSet;
                if (bsori != null)
                {
                    beamelements.Add(bsori.DuplicatesFrameSet());
                }
                sPointLoad pl = wap.Value as sPointLoad;
                if (pl != null)
                {
                    pelements.Add(pl);
                }
                sPointSupport ps = wap.Value as sPointSupport;
                if (ps != null)
                {
                    pelements.Add(ps);
                }
            }

            rhcon.SplitSegmentizesBeamSet(ref beamelements, intTol, segTol, pelements);

            /*
             * string groupInfo = "";
             * DataTree<sBeamSet> beamTree = new DataTree<sBeamSet>();
             * var grouped = beamelements.GroupBy(b => b.beamSetName);
             * int groupID = 0;
             * foreach (var bgroup in grouped)
             * {
             *  GH_Path bpth = new GH_Path(groupID);
             *  groupInfo += "BeamSet" + groupID + ": " + bgroup.ElementAt(0).beamSetName + "\n";
             *  foreach (sBeamSet sb in bgroup)
             *  {
             *      beamTree.Add(sb, bpth);
             *  }
             *  groupID++;
             * }
             *
             * this.Message = groupInfo;
             */

            DA.SetDataList(0, beamelements);
            DA.SetDataList(1, pelements);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <object> sBeamObjs = new List <object>();
            Brep          b         = null;
            double        tol       = 0.05;

            if (!DA.GetDataList(0, sBeamObjs))
            {
                return;
            }
            if (!DA.GetData(1, ref b))
            {
                return;
            }
            if (!DA.GetData(2, ref tol))
            {
                return;
            }

            string          modelUnit          = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString();
            sRhinoConverter rhcon              = new sRhinoConverter(modelUnit, "Meters");
            sRhinoConverter rhcon_ToRhinoModel = new sRhinoConverter("Meters", modelUnit);

            Brep scaleB = rhcon.EnsureUnit(b);

            List <Point3d>  pts  = new List <Point3d>();
            List <Vector3d> vecs = new List <Vector3d>();

            List <object> duplicated          = new List <object>();
            int           nonSegmentizedCount = 0;

            this.Message = "";
            foreach (object ob in sBeamObjs)
            {
                GH_ObjectWrapper wap = new GH_ObjectWrapper(ob);
                IFrameSet        bs  = wap.Value as IFrameSet;
                if (bs != null)
                {
                    IFrameSet dubs = bs.DuplicatesFrameSet();
                    if (dubs.frames.Count > 0)
                    {
                        dubs.EnsureBeamElement();
                        rhcon.AwareBeamUpVectorsOnBrep(ref dubs, scaleB, tol);
                        foreach (sFrame ssb in dubs.frames)
                        {
                            pts.Add(rhcon_ToRhinoModel.EnsureUnit(rhcon.ToRhinoPoint3d(ssb.axis.PointAt(0.5))));
                            vecs.Add(rhcon.ToRhinoVector3d(ssb.upVector));
                        }
                        duplicated.Add(dubs);
                    }
                    else
                    {
                        nonSegmentizedCount++;
                    }
                }

                /*
                 * sBeam sb = wap.Value as sBeam;
                 * if(sb != null)
                 * {
                 *  sBeam dusb = sb.DuplicatesBeam();
                 *  Vector3d nv = rhcon.GetNormalVectorAtPointOnBrep(rhcon.ToRhinoPoint3d(dusb.axis.PointAt(0.5)), scaleB, tol);
                 *  dusb.AwareLocalPlane(rhcon.TosXYZ(nv));
                 *  duplicated.Add(dusb);
                 * }
                 */
            }

            if (nonSegmentizedCount == 0)
            {
                DA.SetDataList(0, duplicated);
                DA.SetDataList(1, pts);
                DA.SetDataList(2, vecs);
            }
            else
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Segmentize Beam Set First To Assign Upvectors");
                //this.Message = "Segmentize Beam Set First To Assign Upvectors";
            }
        }