Ejemplo n.º 1
0
        private static GH_Line GH_LineFromStbNode(StbNode from, StbNode to)
        {
            var ptFrom = new Point3d(from.X, from.Y, from.Z);
            var ptTo   = new Point3d(to.X, to.Y, to.Z);

            return(new GH_Line(new Line(ptFrom, ptTo)));
        }
Ejemplo n.º 2
0
        internal static Point3d GetFrameTagPosition(string idStart, string idEnd, IEnumerable <StbNode> nodes)
        {
            StbNode startNode = nodes.First(node => node.id == idStart);
            StbNode endNode   = nodes.First(node => node.id == idEnd);

            return(new Point3d((startNode.X + endNode.X) / 2.0, (startNode.Y + endNode.Y) / 2.0, (startNode.Z + endNode.Z) / 2.0
                               ));
        }
Ejemplo n.º 3
0
        private static Point3d[] WallNodeToPoint3ds(StbNode[] nodes, string[] nodeIds)
        {
            var pts = new Point3d[nodeIds.Length];

            for (int i = 0; i < nodeIds.Length; i++)
            {
                string  nodeId = nodeIds[i];
                StbNode node   = nodes.First(n => n.id == nodeId);
                pts[i] = new Point3d(node.X, node.Y, node.Z);
            }

            return(pts);
        }
Ejemplo n.º 4
0
        public GH_Structure <GH_Brep> Wall(IEnumerable <StbWall> walls, IEnumerable <StbOpen> opens)
        {
            var brepList = new GH_Structure <GH_Brep>();

            if (walls == null)
            {
                return(brepList);
            }

            foreach ((StbWall wall, int i) in walls.Select((wall, index) => (wall, index)))
            {
                StbWallOffset[] offsets   = wall.StbWallOffsetList;
                var             curveList = new PolylineCurve[2];
                double          thickness = BrepMaker.Wall.GetThickness(_sections, wall);
                string[]        nodeIds   = wall.StbNodeIdOrder.Split(' ');
                var             wallPts   = new List <Point3d>();
                foreach (string nodeId in nodeIds)
                {
                    var offsetVec = new Vector3d();
                    if (offsets != null)
                    {
                        foreach (StbWallOffset offset in offsets)
                        {
                            if (nodeId == offset.id_node)
                            {
                                offsetVec = new Vector3d(offset.offset_X, offset.offset_Y, offset.offset_Z);
                                break;
                            }
                        }
                    }

                    StbNode node = _nodes.First(n => n.id == nodeId);
                    wallPts.Add(new Point3d(node.X, node.Y, node.Z) + offsetVec);
                }
                wallPts.Add(wallPts[0]);
                var      centerCurve = new PolylineCurve(wallPts);
                Vector3d normal      = Vector3d.CrossProduct(centerCurve.TangentAtEnd, centerCurve.TangentAtStart);
                curveList[0] = new PolylineCurve(wallPts.Select(pt => pt + normal * thickness / 2));
                curveList[1] = new PolylineCurve(wallPts.Select(pt => pt - normal * thickness / 2));
                Brep brep = Brep.CreateFromLoft(curveList, Point3d.Unset, Point3d.Unset, LoftType.Straight, false)[0].CapPlanarHoles(_tolerance[0]);
                CheckBrepOrientation(brep);

                brep = ApplyWallOpen(opens, wall, wallPts, brep);
                brepList.Append(new GH_Brep(brep), new GH_Path(0, i));
            }

            return(brepList);
        }
Ejemplo n.º 5
0
        public GH_Structure <GH_Line> Beams()
        {
            var lines = new GH_Structure <GH_Line>();

            if (_members.StbBeams == null)
            {
                return(lines);
            }

            foreach ((StbBeam member, int i) in _members.StbBeams.Select((member, index) => (member, index)))
            {
                StbNode nodeStart = _nodes.First(node => node.id == member.id_node_start);
                StbNode nodeEnd   = _nodes.First(node => node.id == member.id_node_end);

                lines.Append(GH_LineFromStbNode(nodeStart, nodeEnd), new GH_Path(0, i));
            }

            return(lines);
        }
Ejemplo n.º 6
0
        public GH_Structure <GH_Line> Posts()
        {
            var lines = new GH_Structure <GH_Line>();

            if (_members.StbPosts == null)
            {
                return(lines);
            }

            foreach ((StbPost member, int i) in _members.StbPosts.Select((member, index) => (member, index)))
            {
                StbNode nodeBottom = _nodes.First(node => node.id == member.id_node_bottom);
                StbNode nodeTop    = _nodes.First(node => node.id == member.id_node_top);

                lines.Append(GH_LineFromStbNode(nodeBottom, nodeTop), new GH_Path(0, i));
            }

            return(lines);
        }
Ejemplo n.º 7
0
        public GH_Structure <GH_Brep> Slab(IEnumerable <StbSlab> slabs)
        {
            var brepList = new GH_Structure <GH_Brep>();

            if (slabs == null)
            {
                return(brepList);
            }

            foreach ((StbSlab slab, int i) in slabs.Select((slab, index) => (slab, index)))
            {
                StbSlabOffset[] offsets   = slab.StbSlabOffsetList;
                var             curveList = new PolylineCurve[2];
                double          depth     = BrepMaker.Slab.GetDepth(_sections, slab);
                string[]        nodeIds   = slab.StbNodeIdOrder.Split(' ');
                var             topPts    = new List <Point3d>();
                foreach (string nodeId in nodeIds)
                {
                    var offsetVec = new Vector3d();
                    if (offsets != null)
                    {
                        foreach (StbSlabOffset offset in offsets)
                        {
                            if (nodeId == offset.id_node)
                            {
                                offsetVec = new Vector3d(offset.offset_X, offset.offset_Y, offset.offset_Z);
                            }
                        }
                    }

                    StbNode node = _nodes.First(n => n.id == nodeId);
                    topPts.Add(new Point3d(node.X, node.Y, node.Z) + offsetVec);
                }

                topPts.Add(topPts[0]);
                curveList[0] = new PolylineCurve(topPts);
                brepList.Append(CreateSlabBrep(depth, curveList, topPts), new GH_Path(0, i));
            }

            return(brepList);
        }
Ejemplo n.º 8
0
        private static List <BuilderBeam> StbBraceToK3dBeam(List <string> k3Ids, StbNode[] nodes, IEnumerable <StbBrace> braces)
        {
            if (braces == null)
            {
                return(new List <BuilderBeam>());
            }

            var k3dLine3s = new List <Line3>();
            var k3dKit    = new KarambaCommon.Toolkit();

            foreach (StbBrace brace in braces)
            {
                StbNode nodeStart = nodes.First(node => node.id == brace.id_node_start);
                StbNode nodeEnd   = nodes.First(node => node.id == brace.id_node_end);
                var     ptFrom    = new Point3(nodeStart.X / 1000d, nodeStart.Y / 1000d, nodeStart.Z / 1000d);
                var     ptTo      = new Point3(nodeEnd.X / 1000d, nodeEnd.Y / 1000d, nodeEnd.Z / 1000d);
                k3dLine3s.Add(new Line3(ptFrom, ptTo));
            }

            return(k3dKit.Part.LineToBeam(k3dLine3s, k3Ids, new List <CroSec>(), new MessageLogger(), out _, true));
        }
Ejemplo n.º 9
0
        private static Point3d[] SlabNodeToPoint3ds(IReadOnlyList <string> nodeIds, StbNode[] nodes, StbSlabOffset[] offsets)
        {
            var pts = new Point3d[nodeIds.Count];

            for (var i = 0; i < nodeIds.Count; i++)
            {
                string  nodeId    = nodeIds[i];
                StbNode node      = nodes.First(n => n.id == nodeId);
                var     offsetVec = new Vector3d();
                if (offsets != null)
                {
                    foreach (StbSlabOffset offset in offsets.Where(offset => nodeId == offset.id_node))
                    {
                        offsetVec = new Vector3d(offset.offset_X, offset.offset_Y, offset.offset_Z);
                    }
                }

                pts[i] = new Point3d(node.X, node.Y, node.Z) + offsetVec;
            }

            return(pts);
        }
Ejemplo n.º 10
0
        internal static Point3d GetWallTagPosition(string idOrder, StbWallOffset[] offsets, IEnumerable <StbNode> nodes)
        {
            string[] nodeIds = idOrder.Split(' ');
            var      pts     = new Point3d[nodeIds.Length];

            for (int i = 0; i < nodeIds.Length; i++)
            {
                string  nodeId    = nodeIds[i];
                StbNode node      = nodes.First(n => n.id == nodeId);
                var     offsetVec = new Vector3d();
                if (offsets != null)
                {
                    foreach (var offset in offsets.Where(offset => nodeId == offset.id_node))
                    {
                        offsetVec = new Vector3d(offset.offset_X, offset.offset_Y, offset.offset_Z);
                    }
                }
                pts[i] = new Point3d(node.X, node.Y, node.Z) + offsetVec;
            }

            return(new Point3d(pts.Average(n => n.X), pts.Average(n => n.Y), pts.Average(n => n.Z)));
        }