예제 #1
0
 public static Geo.Vector TripleToVector(HM.Triple v)
 {
     return(Geo.Vector.ByCoordinates(v.X, v.Y, v.Z));
 }
        public static Dictionary <string, object> FromLines(
            List <Geo.Line> lines,
            [DefaultArgument("[]")] List <string> names,
            [DefaultArgument("{}")] Dictionary <string, Geo.Vector> webNormalsDict,
            [DefaultArgument("{}")] Dictionary <string, int> priorityDict,
            [DefaultArgument("{}")] Dictionary <string, int> extensionDict,
            [DefaultArgument("null")] string options)
        {
            // Parse Options
            string[] option = options.ToString().Split(',');
            double   intersectionTolerance = (options == "null") ? 0.001 : Double.Parse(option[0]);
            double   planarityTolerance    = (options == "null") ? 0.001 : Double.Parse(option[1]);
            bool     generateBraces        = (options == "null") ? false : bool.Parse(option[2]);
            bool     threePieceBrace       = (options == "null") ? false : bool.Parse(option[3]);
            double   braceLength1          = (options == "null") ? 6 : Double.Parse(option[4]);
            double   braceLength2          = (options == "null") ? 3 : Double.Parse(option[5]);
            bool     firstConnectionIsFTF  = (options == "null") ? false : bool.Parse(option[6]);

            // Create empty dictionaries if unprovided
            if (webNormalsDict == null)
            {
                webNormalsDict = new Dictionary <string, Geo.Vector>();
            }
            if (priorityDict == null)
            {
                priorityDict = new Dictionary <string, int>();
            }
            if (extensionDict == null)
            {
                extensionDict = new Dictionary <string, int>();
            }
            names = CompleteListOfNames(names, lines.Count);

            // Convert Lines
            var hLines = new List <HM.Line>();

            foreach (Geo.Line l in lines)
            {
                hLines.Add(new HM.Line(new HM.Triple(l.StartPoint.X, l.StartPoint.Y, l.StartPoint.Z), new HM.Triple(l.EndPoint.X, l.EndPoint.Y, l.EndPoint.Z)));
            }

            // Convert webNormals
            var hWebNormalsDict = new Dictionary <string, HM.Triple>();

            foreach (string vectorName in webNormalsDict.Keys)
            {
                var vector = webNormalsDict[vectorName];
                hWebNormalsDict[vectorName] = new HM.Triple(vector.X, vector.Y, vector.Z);
            }

            HM.hStructure structure = HM.hStructure.StructureFromLines(
                hLines,
                names,
                hWebNormalsDict,
                priorityDict,
                extensionDict,
                intersectionTolerance,
                planarityTolerance,
                generateBraces,
                threePieceBrace,
                braceLength1,
                braceLength2,
                firstConnectionIsFTF);

            var mems       = structure.Members.ToList();
            var components = new List <Member>();

            foreach (HM.hMember m in mems)
            {
                components.Add(new Member(m));
            }
            return(new Dictionary <string, object>
            {
                { "members", components },
                { "braces", structure.BraceMembers.ToList() },
                { "connections", structure.Connections }
            });
        }
예제 #3
0
 public static Geo.Point TripleToPoint(HM.Triple pt)
 {
     return(Geo.Point.ByCoordinates(pt.X, pt.Y, pt.Z));
 }
예제 #4
0
 public static Vector3d TripleToVector(HM.Triple t)
 {
     return(new Vector3d(t.X, t.Y, t.Z));
 }
예제 #5
0
 public static Point3d TripleToPoint(HM.Triple t)
 {
     return(new Point3d(t.X, t.Y, t.Z));
 }
        /// <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 and assign initial invalid data.
            //    This way, if the input parameters fail to supply valid data, we know when to abort.
            HM.hMember member = null;

            // 2. Retrieve input data.
            if (!DA.GetData(0, ref member))
            {
                return;
            }

            // 3. Abort on invalid inputs.
            //if (!member.IsValid) { return; }

            var webAxisLine = member.WebAxis;
            var webNormal   = member.WebNormal;

            var OP1 = webAxisLine.StartPoint;
            var OP2 = webAxisLine.EndPoint;

            var webAxis = HM.Triple.ByTwoPoints(OP1, OP2);
            var normal  = webNormal;
            var lateral = webAxis.Cross(normal);

            lateral = lateral.Normalized();
            lateral = lateral.Scale(1.75);
            normal  = normal.Normalized();
            normal  = normal.Scale(1.5);
            var lateralR = new HM.Triple(lateral.X * -1, lateral.Y * -1, lateral.Z * -1);
            var webAxisR = new HM.Triple(webAxis.X * -1, webAxis.Y * -1, webAxis.Z * -1);
            var normalR  = new HM.Triple(normal.X * -1, normal.Y * -1, normal.Z * -1);

            var p0 = HMGHUtil.TripleToPoint(OP1.Add(normal.Add(lateral)));
            var p1 = HMGHUtil.TripleToPoint(OP2.Add(normal.Add(lateral)));
            var p2 = HMGHUtil.TripleToPoint(OP1.Add(lateral));
            var p3 = HMGHUtil.TripleToPoint(OP2.Add(lateral));
            var p6 = HMGHUtil.TripleToPoint(OP1.Add(normal.Add(lateralR)));
            var p7 = HMGHUtil.TripleToPoint(OP2.Add(normal.Add(lateralR)));
            var p4 = HMGHUtil.TripleToPoint(OP1.Add(lateralR));
            var p5 = HMGHUtil.TripleToPoint(OP2.Add(lateralR));

            lateral  = lateral.Normalized().Scale(1.25);
            lateralR = lateralR.Normalized().Scale(1.25);
            var p8  = HMGHUtil.TripleToPoint(OP1.Add(lateralR).Add(normal));
            var p9  = HMGHUtil.TripleToPoint(OP2.Add(lateralR).Add(normal));
            var p10 = HMGHUtil.TripleToPoint(OP1.Add(lateral).Add(normal));
            var p11 = HMGHUtil.TripleToPoint(OP2.Add(lateral).Add(normal));


            var flange1 = NurbsSurface.CreateFromCorners(p0, p1, p3, p2);
            var flange2 = NurbsSurface.CreateFromCorners(p4, p5, p7, p6);
            var web     = NurbsSurface.CreateFromCorners(p2, p3, p5, p4);
            var lip1    = NurbsSurface.CreateFromCorners(p0, p1, p11, p10);
            var lip2    = NurbsSurface.CreateFromCorners(p6, p7, p9, p8);

            var memGeo = new List <Brep>()
            {
                Brep.CreateFromSurface(flange1), Brep.CreateFromSurface(flange2), Brep.CreateFromSurface(web), Brep.CreateFromSurface(lip1), Brep.CreateFromSurface(lip2)
            };
            var brep = Brep.JoinBreps(memGeo, 0.001)[0];

            DA.SetData(0, brep);
        }
예제 #7
0
        public Triple ClosestPointOnLine(Triple pt)
        {
            var closestPointParameter = ParameterAtPoint(pt);

            return(PointAtParameter(closestPointParameter));
        }
예제 #8
0
 public Line(Triple start, Triple end)
 {
     this.StartPoint = start;
     this.EndPoint   = end;
 }