Exemplo n.º 1
0
        public WFData Copy()
        {
            var newData = new WFData();
            var idDic   = new Dictionary <string, string>();

            for (int i = 0; i < wfNodes.Count; i++)
            {
                var newNode = wfNodes[i].Copy();
                newData.wfNodes.Add(newNode);
                idDic.Add(wfNodes[i].m_id, newNode.m_id);
            }
            for (int i = 0; i < wfBars.Count; i++)
            {
                var newBar = wfBars[i].Copy();
                if (idDic.ContainsKey(newBar.fromNodeId))
                {
                    newBar.ResetFromNodeID(idDic[newBar.fromNodeId]);
                }
                if (idDic.ContainsKey(newBar.toNodeId))
                {
                    newBar.ResetToNodeID(idDic[newBar.toNodeId]);
                }
                newData.wfBars.Add(newBar);
            }
            return(newData);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 生成一组[四角锥(菱形)]单元信息
        /// </summary>
        /// <param name="x_Size"></param>
        /// <param name="y_Size"></param>
        /// <param name="height"></param>
        /// <returns></returns>
        internal static WFData QuadDiamondSpaceGrid_Unit(float x_Size, float y_Size, float height)
        {
            var wfData = new WFData();
            var node1  = new WFNode(new Vector3(0, 0, 0), NodePosType.taperedBottom);
            var node2  = new WFNode(new Vector3(x_Size * 0.5f, 0, -y_Size * 0.5f), NodePosType.taperedBottom);
            var node3  = new WFNode(new Vector3(x_Size, 0, 0), NodePosType.taperedBottom);
            var node4  = new WFNode(new Vector3(x_Size * 0.5f, 0, y_Size * 0.5f), NodePosType.taperedBottom);
            var node5  = new WFNode(new Vector3(x_Size * 0.5f, -height, 0), NodePosType.taperedTop);

            wfData.wfNodes.Add(node1);
            wfData.wfNodes.Add(node2);
            wfData.wfNodes.Add(node3);
            wfData.wfNodes.Add(node4);
            wfData.wfNodes.Add(node5);

            wfData.wfBars.Add(new WFBar(node1.m_id, node2.m_id, BarPosType.upBar));     //1-2
            wfData.wfBars.Add(new WFBar(node1.m_id, node4.m_id, BarPosType.upBar));     //1-4
            wfData.wfBars.Add(new WFBar(node1.m_id, node5.m_id, BarPosType.centerBar)); //1-5
            wfData.wfBars.Add(new WFBar(node2.m_id, node3.m_id, BarPosType.upBar));     //2-3
            wfData.wfBars.Add(new WFBar(node2.m_id, node5.m_id, BarPosType.centerBar)); //2-5
            wfData.wfBars.Add(new WFBar(node3.m_id, node4.m_id, BarPosType.upBar));     //3-4
            wfData.wfBars.Add(new WFBar(node3.m_id, node5.m_id, BarPosType.centerBar)); //3-5
            wfData.wfBars.Add(new WFBar(node4.m_id, node5.m_id, BarPosType.centerBar)); //4-5
            return(wfData);
        }
        protected override WFData GenerateWFData(FrameRule clamp)
        {
            var    startPos = -new Vector3(clamp.size1, -clamp.height, clamp.size2) * 0.5f;
            WFData wfData   = new WFData();
            float  x_Size   = clamp.size1 / clamp.num1;
            float  y_Size   = clamp.size2 / clamp.num2;

            var topNodes = new List <WFNode>();

            for (int i = 0; i < clamp.num1; i++)
            {
                for (int j = 0; j < clamp.num2; j++)
                {
                    if (i > 0 && i < clamp.num1 - 1 && j > 0 && j < clamp.num2 - 1 && (i + j) % 2 == 0)
                    {
                        continue;
                    }
                    WFData data = CalcuteUtility.QuadrangularSpaceGrid_Unit(x_Size, y_Size, clamp.height);
                    data.AppendPosition(startPos + i * x_Size * Vector3.right + j * y_Size * Vector3.forward);
                    topNodes.Add(data.wfNodes.Find(x => x.type == NodePosType.taperedTop));
                    //Debug.Log(data.wfNodes.Find(x => x.type == NodePosType.taperedTop).m_id);
                    wfData.InsertData(data);
                }
            }
            var downData = CalcuteUtility.ConnectNeerBy(topNodes, Mathf.Sqrt(Mathf.Pow(x_Size, 2) + Mathf.Pow(y_Size, 2)), BarPosType.downBar, BoundConnectType.NoRule);

            wfData.InsertData(downData);

            return(wfData);
        }
Exemplo n.º 4
0
        protected override WFData GenerateWFData(FrameRule clamp)
        {
            var    startPos = -new Vector3(clamp.size1, -clamp.height, clamp.size2) * 0.5f;
            WFData wfData   = new WFData();
            float  x_Size   = clamp.size1 / clamp.num1;
            float  y_Size   = clamp.size2 / clamp.num2;

            WFNode[,] topNodes = new WFNode[clamp.num1, clamp.num2];

            for (int i = 0; i < clamp.num1; i++)
            {
                for (int j = 0; j < clamp.num2; j++)
                {
                    if (i > 0 && i < clamp.num1 - 1 && j > 0 && j < clamp.num2 - 1 && i % 2 != 0 && j % 2 != 0)
                    {
                        continue;
                    }
                    WFData data = CalcuteUtility.QuadrangularSpaceGrid_Unit(x_Size, y_Size, clamp.height);
                    data.AppendPosition(startPos + i * x_Size * Vector3.right + j * y_Size * Vector3.forward);
                    topNodes[i, j] = data.wfNodes.Find(x => x.type == NodePosType.taperedTop);
                    wfData.InsertData(data);
                }
            }
            var downData = CalcuteUtility.ConnectNeerBy(topNodes, BarPosType.downBar);

            wfData.InsertData(downData);

            return(wfData);
        }
Exemplo n.º 5
0
        private void CreateDoubleLayer(WFData wfData, float height)
        {
            var dataCopy = wfData.Copy();

            dataCopy.AppendRotation(Quaternion.Euler(new Vector3(180, 0, 0)));
            dataCopy.AppendPosition(new Vector3(0, -height, 0));
            wfData.InsertData(dataCopy);
        }
Exemplo n.º 6
0
        protected override WFData GenerateWFDataUnit(FrameRule clamp)
        {
            float  x_Size = clamp.size1 / clamp.num1;
            float  y_Size = clamp.size2 / clamp.num2;
            WFData data   = CalcuteUtility.TrussTypeDiamondSpaceGrid_Unit(x_Size, y_Size, clamp.height);

            return(data);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 生成一组[桁架型(菱形)]单元信息
        /// 左下前角为原点
        /// </summary>
        /// <param name="clamp"></param>
        /// <returns></returns>
        internal static WFData TrussTypeDiamondSpaceGrid_Unit(float x_Size, float y_Size, float height)
        {
            var wfData = new WFData();
            var node1  = new WFNode(new Vector3(0, 0, 0));                               //1
            var node2  = new WFNode(new Vector3(x_Size * 0.5f, 0, -y_Size * 0.5f));      //2
            var node3  = new WFNode(new Vector3(x_Size * 0.5f, height, -y_Size * 0.5f)); //3
            var node4  = new WFNode(new Vector3(0, height, 0));                          //4
            var node5  = new WFNode(new Vector3(x_Size * 0.5f, 0, y_Size * 0.5f));       //5
            var node6  = new WFNode(new Vector3(x_Size, 0, 0));                          //6
            var node7  = new WFNode(new Vector3(x_Size, height, 0));                     //7
            var node8  = new WFNode(new Vector3(x_Size * 0.5f, height, y_Size * 0.5f));  //8

            wfData.wfNodes.Add(node1);
            wfData.wfNodes.Add(node2);
            wfData.wfNodes.Add(node3);
            wfData.wfNodes.Add(node4);

            wfData.wfNodes.Add(node5);
            wfData.wfNodes.Add(node6);
            wfData.wfNodes.Add(node7);
            wfData.wfNodes.Add(node8);


            //wfData.wfBars.Add(new WFBar(node1.m_id, node2.m_id));//1-2
            //wfData.wfBars.Add(new WFBar(node1.m_id, node4.m_id));//1-4
            //wfData.wfBars.Add(new WFBar(node1.m_id, node5.m_id));//1-5
            //wfData.wfBars.Add(new WFBar(node1.m_id, node8.m_id));//1-8
            //wfData.wfBars.Add(new WFBar(node2.m_id, node3.m_id));//2-3
            //wfData.wfBars.Add(new WFBar(node2.m_id, node4.m_id));//2-4
            //wfData.wfBars.Add(new WFBar(node2.m_id, node6.m_id));//2-6
            //wfData.wfBars.Add(new WFBar(node2.m_id, node7.m_id));//2-7
            //wfData.wfBars.Add(new WFBar(node3.m_id, node4.m_id));//3-4
            //wfData.wfBars.Add(new WFBar(node3.m_id, node7.m_id));//3-7
            //wfData.wfBars.Add(new WFBar(node4.m_id, node8.m_id));//4-8
            //wfData.wfBars.Add(new WFBar(node5.m_id, node6.m_id));//5-6
            //wfData.wfBars.Add(new WFBar(node5.m_id, node8.m_id));//5-8
            //wfData.wfBars.Add(new WFBar(node6.m_id, node7.m_id));//6-7
            //wfData.wfBars.Add(new WFBar(node6.m_id, node8.m_id));//6-8
            //wfData.wfBars.Add(new WFBar(node7.m_id, node8.m_id));//7-8

            wfData.wfBars.Add(new WFBar(node1.m_id, node2.m_id, BarPosType.downBar));   //1-2
            wfData.wfBars.Add(new WFBar(node1.m_id, node4.m_id, BarPosType.centerBar)); //1-4
            wfData.wfBars.Add(new WFBar(node1.m_id, node5.m_id, BarPosType.downBar));   //1-5
            wfData.wfBars.Add(new WFBar(node1.m_id, node8.m_id, BarPosType.centerBar)); //1-8
            wfData.wfBars.Add(new WFBar(node2.m_id, node3.m_id, BarPosType.centerBar)); //2-3
            wfData.wfBars.Add(new WFBar(node2.m_id, node4.m_id, BarPosType.centerBar)); //2-4
            wfData.wfBars.Add(new WFBar(node2.m_id, node6.m_id, BarPosType.downBar));   //2-6
            wfData.wfBars.Add(new WFBar(node2.m_id, node7.m_id, BarPosType.centerBar)); //2-7
            wfData.wfBars.Add(new WFBar(node3.m_id, node4.m_id, BarPosType.upBar));     //3-4
            wfData.wfBars.Add(new WFBar(node3.m_id, node7.m_id, BarPosType.upBar));     //3-7
            wfData.wfBars.Add(new WFBar(node4.m_id, node8.m_id, BarPosType.upBar));     //4-8
            wfData.wfBars.Add(new WFBar(node5.m_id, node6.m_id, BarPosType.downBar));   //5-6
            wfData.wfBars.Add(new WFBar(node5.m_id, node8.m_id, BarPosType.centerBar)); //5-8
            wfData.wfBars.Add(new WFBar(node6.m_id, node7.m_id, BarPosType.centerBar)); //6-7
            wfData.wfBars.Add(new WFBar(node6.m_id, node8.m_id, BarPosType.centerBar)); //6-8
            wfData.wfBars.Add(new WFBar(node7.m_id, node8.m_id, BarPosType.upBar));     //7-8
            return(wfData);
        }
Exemplo n.º 8
0
        protected override WFData GenerateWFData(FrameRule clamp)
        {
            float  x_Size   = clamp.size1 / clamp.num1;
            float  y_Size   = clamp.size2 / clamp.num2;
            var    startPos = -new Vector3(clamp.size1, -clamp.height, clamp.size2 - y_Size) * 0.5f;
            WFData wfData   = new WFData();


            WFNode[,] topNodes = new WFNode[clamp.num1, clamp.num2];
            List <WFNode> bundNodes = new List <WFNode>();

            for (int i = 0; i < clamp.num1; i++)
            {
                for (int j = 0; j < clamp.num2; j++)
                {
                    WFData data     = CalcuteUtility.QuadDiamondSpaceGrid_Unit(x_Size, y_Size, clamp.height);
                    var    position = startPos + i * x_Size * Vector3.right + j * y_Size * Vector3.forward;
                    data.AppendPosition(position);
                    topNodes[i, j] = data.wfNodes.Find(x => x.type == NodePosType.taperedTop);
                    wfData.InsertData(data);

                    if (i == 0)//左
                    {
                        var node = data.wfNodes.Find(x => Vector3.Distance(x.position, position) < 0.1f);
                        bundNodes.Add(node);
                    }
                    if (j == 0)
                    {//下
                        var downPos = position + x_Size * Vector3.right * 0.5f - y_Size * Vector3.forward * 0.5f;
                        var node    = data.wfNodes.Find(x => Vector3.Distance(x.position, downPos) < 0.1f);
                        bundNodes.Add(node);
                    }
                    if (i == clamp.num1 - 1)//右
                    {
                        var rightPos = position + x_Size * Vector3.right;
                        var node     = data.wfNodes.Find(x => Vector3.Distance(x.position, rightPos) < 0.1f);
                        bundNodes.Add(node);
                    }
                    if (j == clamp.num2 - 1)//上
                    {
                        var upPos = position + x_Size * Vector3.right * 0.5f + y_Size * Vector3.forward * 0.5f;
                        var node  = data.wfNodes.Find(x => Vector3.Distance(x.position, upPos) < 0.1f);
                        bundNodes.Add(node);
                    }
                }
            }

            var downData = CalcuteUtility.ConnectNeerBy(topNodes, BarPosType.downBar);

            wfData.InsertData(downData);

            var bundData = CalcuteUtility.ConnectNeerBy(bundNodes, Mathf.Sqrt(Mathf.Pow(x_Size, 2) + Mathf.Pow(y_Size, 2)), BarPosType.upBar);

            wfData.InsertData(bundData);

            return(wfData);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 连接相邻点
        /// </summary>
        /// <param name="topNodes"></param>
        /// <returns></returns>
        internal static WFData ConnectNeerBy(WFNode[,] topNodes, string barType)
        {
            WFData data   = new WFData();
            var    xCount = topNodes.GetLength(0);
            var    yCount = topNodes.GetLength(1);

            for (int i = 0; i < xCount; i++)
            {
                for (int j = 0; j < yCount; j++)
                {
                    var node = topNodes[i, j];

                    if (node == null)
                    {
                        continue;
                    }

                    data.wfNodes.Add(node);
                    if (i > 0)//左
                    {
                        var node_l = topNodes[i - 1, j];
                        if (node_l != null)
                        {
                            data.wfBars.Add(new WFBar(node.m_id, node_l.m_id, barType));
                        }
                    }
                    if (i < xCount - 1)//右
                    {
                        var node_r = topNodes[i + 1, j];
                        if (node_r != null)
                        {
                            data.wfBars.Add(new WFBar(node.m_id, node_r.m_id, barType));
                        }
                    }
                    if (j > 0)//下
                    {
                        var node_d = topNodes[i, j - 1];
                        if (node_d != null)
                        {
                            data.wfBars.Add(new WFBar(node.m_id, node_d.m_id, barType));
                        }
                    }
                    if (j < yCount - 1)//上
                    {
                        var node_u = topNodes[i, j + 1];
                        if (node_u != null)
                        {
                            data.wfBars.Add(new WFBar(node.m_id, node_u.m_id, barType));
                        }
                    }
                    //Debug.Log(i + "" + j + topNodes[i, j].m_id);
                }
            }
            return(data);
        }
Exemplo n.º 10
0
        protected override WFData GenerateWFData(FrameRule clamp)
        {
            float  x_Size   = clamp.size1 / clamp.num1;
            float  y_Size   = clamp.size2 / clamp.num2;
            var    startPos = -new Vector3(clamp.size1, clamp.height, clamp.size2 - y_Size) * 0.5f;
            WFData wfData   = new WFData();

            var bundNodes = new List <WFNode>();

            for (int i = 0; i < clamp.num1; i++)
            {
                for (int j = 0; j < clamp.num2; j++)
                {
                    WFData data     = CalcuteUtility.TrussTypeDiamondSpaceGrid_Unit(x_Size, y_Size, clamp.height);
                    var    position = startPos + i * x_Size * Vector3.right + j * y_Size * Vector3.forward;
                    data.AppendPosition(position);
                    wfData.InsertData(data);

                    if (i == 0)//左
                    {
                        var nodes = data.wfNodes.FindAll(x => IsPointSmilarity(x.position, position));
                        bundNodes.AddRange(nodes);
                    }
                    if (j == 0)
                    {//下
                        var downPos = position + x_Size * Vector3.right * 0.5f - y_Size * Vector3.forward * 0.5f;
                        var nodes   = data.wfNodes.FindAll(x => IsPointSmilarity(x.position, downPos));
                        bundNodes.AddRange(nodes);
                    }
                    if (i == clamp.num1 - 1)//右
                    {
                        var rightPos = position + x_Size * Vector3.right;
                        var nodes    = data.wfNodes.FindAll(x => IsPointSmilarity(x.position, rightPos));
                        bundNodes.AddRange(nodes);
                    }
                    if (j == clamp.num2 - 1)//上
                    {
                        var upPos = position + x_Size * Vector3.right * 0.5f + y_Size * Vector3.forward * 0.5f;
                        var nodes = data.wfNodes.FindAll(x => IsPointSmilarity(x.position, upPos));
                        bundNodes.AddRange(nodes);
                    }
                }
            }

            var bundData = CalcuteUtility.ConnectNeerBy(bundNodes, Mathf.Sqrt(Mathf.Pow(x_Size, 2) + Mathf.Pow(y_Size, 2)), BarPosType.upBar);

            wfData.InsertData(bundData);

            return(wfData);
        }
Exemplo n.º 11
0
        internal void InsertData(WFData data)
        {
            Dictionary <string, string> guidChanged = new Dictionary <string, string>();

            foreach (var item in data.wfNodes)
            {
                var same = wfNodes.Find(x => Vector3.Distance(x.position, item.position) < 0.1f);
                if (same != null)
                {
                    guidChanged.Add(item.m_id, same.m_id);
                }
                else
                {
                    wfNodes.Add(item);
                }
            }
            foreach (var item in data.wfBars)
            {
                bool formNodeSame = guidChanged.ContainsKey(item.fromNodeId);
                bool toNodeSame   = guidChanged.ContainsKey(item.toNodeId);

                if (formNodeSame && !toNodeSame)
                {
                    var newBar = item.Copy();
                    newBar.ResetFromNodeID(guidChanged[item.fromNodeId]);
                    wfBars.Add(newBar);
                }
                else if (!formNodeSame && toNodeSame)
                {
                    var newBar = item.Copy();
                    newBar.ResetToNodeID(guidChanged[item.toNodeId]);
                    wfBars.Add(newBar);
                }
                else if (!formNodeSame && !toNodeSame)
                {
                    wfBars.Add(item);
                }
                else
                {
                    var newBar = item.Copy();
                    newBar.ResetFromNodeID(guidChanged[item.fromNodeId]);
                    newBar.ResetToNodeID(guidChanged[item.toNodeId]);
                    if (wfBars.Find(x => x.IsSame(newBar)) == null)
                    {
                        wfBars.Add(newBar);
                    }
                }
            }
        }
        public static WFData GetTestData()
        {
            var data = new WFData();

            data.wfNodes = new List <WFNode>();
            var node1 = new WFNode(Vector3.zero);

            data.wfNodes.Add(node1);
            var node2 = new WFNode(Vector3.one);

            data.wfNodes.Add(node2);

            data.wfBars = new List <WFBar>();
            var bar = new WFBar(node1.m_id, node2.m_id, BarPosType.upBar);

            data.wfBars.Add(bar);
            return(data);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 生成一组[桁架型(三向交叉)]单元信息
        /// 左下前角为原点
        /// </summary>
        /// <param name="clamp"></param>
        /// <returns></returns>
        internal static WFData TrussTypeThreeDirectionSpaceGrid_Unit(float x_Size, float y_Size, float height)
        {
            var wfData = new WFData();
            var node1  = new WFNode(new Vector3(0, 0, 0));
            var node2  = new WFNode(new Vector3(x_Size, 0, 0));
            var node3  = new WFNode(new Vector3(x_Size, height, 0));
            var node4  = new WFNode(new Vector3(0, height, 0));
            var node5  = new WFNode(new Vector3(0, 0, y_Size));
            var node6  = new WFNode(new Vector3(x_Size, 0, y_Size));
            var node7  = new WFNode(new Vector3(x_Size, height, y_Size));
            var node8  = new WFNode(new Vector3(0, height, y_Size));

            wfData.wfNodes.Add(node1);
            wfData.wfNodes.Add(node2);
            wfData.wfNodes.Add(node3);
            wfData.wfNodes.Add(node4);

            wfData.wfNodes.Add(node5);
            wfData.wfNodes.Add(node6);
            wfData.wfNodes.Add(node7);
            wfData.wfNodes.Add(node8);


            wfData.wfBars.Add(new WFBar(node1.m_id, node2.m_id, BarPosType.downBar));   //1-2
            wfData.wfBars.Add(new WFBar(node1.m_id, node4.m_id, BarPosType.centerBar)); //1-4
            wfData.wfBars.Add(new WFBar(node1.m_id, node5.m_id, BarPosType.downBar));   //1-5
            wfData.wfBars.Add(new WFBar(node1.m_id, node6.m_id, BarPosType.downBar));   //1-6
            wfData.wfBars.Add(new WFBar(node1.m_id, node8.m_id, BarPosType.centerBar)); //1-8
            wfData.wfBars.Add(new WFBar(node2.m_id, node3.m_id, BarPosType.centerBar)); //2-3
            wfData.wfBars.Add(new WFBar(node2.m_id, node4.m_id, BarPosType.centerBar)); //2-4
            wfData.wfBars.Add(new WFBar(node2.m_id, node6.m_id, BarPosType.downBar));   //2-6
            wfData.wfBars.Add(new WFBar(node2.m_id, node7.m_id, BarPosType.centerBar)); //2-7
            wfData.wfBars.Add(new WFBar(node3.m_id, node4.m_id, BarPosType.upBar));     //3-4
            wfData.wfBars.Add(new WFBar(node3.m_id, node7.m_id, BarPosType.upBar));     //3-7
            wfData.wfBars.Add(new WFBar(node4.m_id, node6.m_id, BarPosType.centerBar)); //4-6
            wfData.wfBars.Add(new WFBar(node4.m_id, node7.m_id, BarPosType.upBar));     //4-7
            wfData.wfBars.Add(new WFBar(node4.m_id, node8.m_id, BarPosType.upBar));     //4-8
            wfData.wfBars.Add(new WFBar(node5.m_id, node6.m_id, BarPosType.downBar));   //5-6
            wfData.wfBars.Add(new WFBar(node5.m_id, node8.m_id, BarPosType.centerBar)); //5-8
            wfData.wfBars.Add(new WFBar(node6.m_id, node7.m_id, BarPosType.centerBar)); //6-7
            wfData.wfBars.Add(new WFBar(node6.m_id, node8.m_id, BarPosType.centerBar)); //6-8
            wfData.wfBars.Add(new WFBar(node7.m_id, node8.m_id, BarPosType.upBar));     //7-8
            return(wfData);
        }
Exemplo n.º 14
0
        protected override WFData GenerateWFData(FrameRule clamp)
        {
            var    startPos = -new Vector3(clamp.size1, clamp.height, clamp.size2) * 0.5f;
            WFData wfData   = new WFData();
            float  x_Size   = clamp.size1 / clamp.num1;
            float  y_Size   = clamp.size2 / clamp.num2;

            for (int i = 0; i < clamp.num1; i++)
            {
                for (int j = 0; j < clamp.num2; j++)
                {
                    WFData data = CalcuteUtility.TrussTypeThreeDirectionSpaceGrid_Unit(x_Size, y_Size, clamp.height);
                    data.AppendPosition(startPos + i * x_Size * Vector3.right + j * y_Size * Vector3.forward);
                    wfData.InsertData(data);
                }
            }

            return(wfData);
        }
 private void RecordBoundNode(int i, int j, int num, WFData tdata, Vector3 pos, float unitSize, float unitHeight, List <WFNode> boundNodes)
 {
     if (i == -num)
     {
         var downNode = tdata.wfNodes.Find(x => CalcuteUtility.IsSimulatePos(x.position, pos));
         boundNodes.Add(downNode);
     }
     if (j == 0 && i >= -1)
     {
         var leftPos  = pos - unitSize * 0.5f * Vector3.right + unitHeight * Vector3.forward;
         var leftNode = tdata.wfNodes.Find(x => CalcuteUtility.IsSimulatePos(x.position, leftPos));
         boundNodes.Add(leftNode);
     }
     if (j == 2 * num - Mathf.Abs(i + 1) - 1 && i >= -1)
     {
         var rightPos  = pos + unitSize * 0.5f * Vector3.right + unitHeight * Vector3.forward;
         var rightNode = tdata.wfNodes.Find(x => CalcuteUtility.IsSimulatePos(x.position, rightPos));
         boundNodes.Add(rightNode);
     }
 }
        protected override WFData GenerateWFData(FrameRule clamp)
        {
            var data       = new WFData();
            var num        = clamp.num1;
            var size       = clamp.size1;
            var unitSize   = clamp.size1 / num;
            var unitHeight = Mathf.Sin(Mathf.Deg2Rad * 60) * unitSize;
            var startPos   = new Vector3(-size * 0.5f, clamp.height * 0.5f, -Mathf.Sin(Mathf.Deg2Rad * 60) * size);

            var boundNodes = new List <WFNode>();
            var topNodes   = new List <WFNode>();

            for (int i = -num; i < num; i++)
            {
                for (int j = 0; j < 2 * num - Mathf.Abs(i + 1); j++)
                {
                    var pos = startPos +
                              (j * unitSize - 0.5f * unitSize * (num - Mathf.Abs(i + 1))) * Vector3.right +
                              unitHeight * (i + num) * Vector3.forward;
                    var tdata = CalcuteUtility.TrigonumSpaceGrid_Unit(unitSize, clamp.height);
                    tdata.AppendPosition(pos);
                    data.InsertData(tdata);
                    //记录顶点用于连线
                    topNodes.Add(tdata.wfNodes.Find(x => x.type == NodePosType.taperedTop));
                    //记录边界节点用于连线
                    RecordBoundNode(i, j, num, tdata, pos, unitSize, unitHeight, boundNodes);
                }
            }

            var topData = CalcuteUtility.ConnectNeerBy(topNodes, unitSize, BarPosType.downBar, BoundConnectType.NoRule);

            data.InsertData(topData);

            var bundData = CalcuteUtility.ConnectNeerBy(boundNodes, unitSize, BarPosType.upBar, BoundConnectType.NoRule);

            data.InsertData(bundData);

            return(data);
        }
Exemplo n.º 17
0
        /// <summary>
        /// 生成一组[三角锥]单元信息
        /// 上面下角为原点
        /// </summary>
        /// <param name="x_Size"></param>
        /// <param name="y_Size"></param>
        /// <param name="height"></param>
        /// <returns></returns>
        internal static WFData TrigonumSpaceGrid_Unit(float edge, float height)
        {
            var wfData     = new WFData();
            var edgeHeight = edge * 0.5f * Mathf.Tan(Mathf.Deg2Rad * 60);
            var centr1     = edge * 0.5f / Mathf.Cos(Mathf.Deg2Rad * 30);
            var node1      = new WFNode(new Vector3(0, 0, 0), NodePosType.taperedBottom);
            var node2      = new WFNode(new Vector3(edge * 0.5f, 0, edgeHeight), NodePosType.taperedBottom);
            var node3      = new WFNode(new Vector3(-edge * 0.5f, 0, edgeHeight), NodePosType.taperedBottom);
            var node4      = new WFNode(new Vector3(0, -height, centr1), NodePosType.taperedTop);

            wfData.wfNodes.Add(node1);
            wfData.wfNodes.Add(node2);
            wfData.wfNodes.Add(node3);
            wfData.wfNodes.Add(node4);

            wfData.wfBars.Add(new WFBar(node1.m_id, node2.m_id, BarPosType.upBar));     //1-2
            wfData.wfBars.Add(new WFBar(node1.m_id, node3.m_id, BarPosType.upBar));     //1-3
            wfData.wfBars.Add(new WFBar(node1.m_id, node4.m_id, BarPosType.centerBar)); //1-4
            wfData.wfBars.Add(new WFBar(node2.m_id, node3.m_id, BarPosType.upBar));     //2-3
            wfData.wfBars.Add(new WFBar(node2.m_id, node4.m_id, BarPosType.centerBar)); //2-4
            wfData.wfBars.Add(new WFBar(node3.m_id, node4.m_id, BarPosType.centerBar)); //3-4
            return(wfData);
        }
Exemplo n.º 18
0
        /// <summary>
        /// (边界连接)
        /// </summary>
        /// <param name="bundNodes"></param>
        /// <param name="barType"></param>
        /// <returns></returns>
        internal static WFData ConnectNeerBy(List <WFNode> bundNodes, float distence, string barType, BoundConnectType connectType = BoundConnectType.XOrYAxis)
        {
            var data = new WFData();

            for (int i = 0; i < bundNodes.Count; i++)
            {
                var node = bundNodes[i];
                data.wfNodes.Add(node);
                if (i < bundNodes.Count - 1)
                {
                    for (int j = i + 1; j < bundNodes.Count; j++)
                    {
                        var otherNode = bundNodes[j];
                        if (Vector3.Distance(node.position, otherNode.position) < distence + 0.1f)
                        {
                            bool match = false;

                            switch (connectType)
                            {
                            case BoundConnectType.XAxisOnly:
                                match = Mathf.Abs(node.position.x - otherNode.position.x) < 0.1f;
                                break;

                            case BoundConnectType.YAxisOnly:
                                match = Mathf.Abs(node.position.z - otherNode.position.z) < 0.1f;
                                break;

                            case BoundConnectType.XOrYAxis:
                                match = Mathf.Abs(node.position.x - otherNode.position.x) < 0.1f ||
                                        Mathf.Abs(node.position.z - otherNode.position.z) < 0.1f;
                                break;

                            case BoundConnectType.NoXAxis:
                                match = Mathf.Abs(node.position.x - otherNode.position.x) > 0.1f;
                                break;

                            case BoundConnectType.NoYAxis:
                                match = Mathf.Abs(node.position.z - otherNode.position.z) > 0.1f;
                                break;

                            case BoundConnectType.NoXAndYAxis:
                                match = Mathf.Abs(node.position.x - otherNode.position.x) > 0.1f &&
                                        Mathf.Abs(node.position.z - otherNode.position.z) > 0.1f;
                                break;

                            case BoundConnectType.NoRule:
                                match = true;
                                break;

                            default:
                                break;
                            }
                            if (match)
                            {
                                data.wfBars.Add(new WFBar(node.m_id, otherNode.m_id, barType));
                            }
                        }
                    }
                }
            }
            return(data);
        }