示例#1
0
        /// 节点集输出至文件
        /// <summary>
        /// 节点集输出至文件
        /// </summary>
        /// <param name="Ps">节点集位置</param>
        /// <param name="Nums">节点集编号</param>
        /// <param name="Reverse_Check">是否倒序输出</param>
        /// <param name="Num_Pre">判断第一个节点是否输出的编号,相同则不输出</param>
        /// <param name="sw">输出对象</param>
        public static void Ns_Out(ref List <WPoint2D> Ps, ref List <int> Nums, bool Reverse_Check, int Num_Pre, ref StreamWriter sw)
        {
            int Quan = Ps.Count;

            if (Reverse_Check == false)
            {
                if (Nums[0] != Num_Pre)
                {
                    WMFuncs2D.N_Out(Ps[0], Nums[0], ref sw);
                }
                for (int i = 1; i < Quan; i++)
                {
                    WMFuncs2D.N_Out(Ps[i], Nums[i], ref sw);
                }
            }
            else
            {
                if (Nums[Quan - 1] != Num_Pre)
                {
                    WMFuncs2D.N_Out(Ps[Quan - 1], Nums[Quan - 1], ref sw);
                }
                for (int i = Quan - 2; i >= 0; i--)
                {
                    WMFuncs2D.N_Out(Ps[i], Nums[i], ref sw);
                }
            }
        }
示例#2
0
        public static WElement2D[] Mesh_SingleRim(ref List <int> Nums, ref List <WPoint2D> Ps, ref WMesh2D_Para MP, string Name)
        {
            StreamWriter Sw = new System.IO.StreamWriter(MP.Path + Name + ".rim");
            List <int>   Ns = new List <int>();
            int          N  = 0;

            N = WMFuncs2D.NsID_App(ref Ps, ref Ns, N);                  /////形成节点编号
            WMFuncs2D.Ns_Out(ref Ps, ref Ns, false, 0, ref Sw);
            Sw.Close();
            Poly_SingleRim(Ps.Count, MP.Path, Name);
            WMesh2D_Mesh Mesh = Mesh2D_TriangleMesh.Triangle_Mesh(ref MP, Name);      /////调用

            if (Mesh == null)
            {
                return(null);
            }
            for (int i = 0; i < Mesh.QEs; i++)
            {
                if (Mesh.Elements[i].Kind == 4)
                {
                    Mesh.Elements[i] = new WElement2D(Mesh.Elements[i].Kind,
                                                      Nums[Mesh.Elements[i].N1], Nums[Mesh.Elements[i].N2],
                                                      Nums[Mesh.Elements[i].N3], Nums[Mesh.Elements[i].N4]);
                }
                else if (Mesh.Elements[i].Kind == 3)
                {
                    Mesh.Elements[i] = new WElement2D(Mesh.Elements[i].Kind,
                                                      Nums[Mesh.Elements[i].N1], Nums[Mesh.Elements[i].N2],
                                                      Nums[Mesh.Elements[i].N3], 0);
                }
            }
            return(Mesh.Elements.ToArray());
        }
示例#3
0
        /// 找到0节点和节点编号的圈圈
        private static void Get_Rim(ref WEntity2D[] Rim_Curves, ref List <WPoint2D> Ps_Out, ref List <int> Ns_Out)
        {
            for (int i = 0; i < Rim_Curves.Length; i++)
            {
                if (((WCurve2D)Rim_Curves[i]).Meshed_Check == false)
                {
                    return;                                                    /////如果有线没有Mesh则返回-1
                }
            }
            int[] Sorts = Geos2D_Other.Sort_Curves(Rim_Curves);

            int Num;
            bool Tc;                   /////判断某条线是否首尾颠倒,true为颠倒,false为不颠倒
            ///////处理第一条线///////
            Num = 0;
            WCurve2D C         = (WCurve2D)Rim_Curves[Num];
            List <int> Ns      = new List <int>();
            List <WPoint2D> Ps = new List <WPoint2D>();
            for (int i = 1; i < C.Nodes.Count; i++)
            {
                Ps.Add(C.Nodes[i]);      /////将Curve的Node复制出来至Ps
                Ns.Add(C.Nodes_num[i]);
            }
            Ps_Out = Ps;
            Ns_Out = Ns;

            //////处理中间线//////////
            for (int i = 1; i <= Sorts.Length - 1; i++)
            {
                Num = (int)(Math.Floor((double)(Sorts[i] / 2)));
                if (Sorts[i] - 2 * Num == 0)
                {
                    Tc = false;
                }
                else
                {
                    Tc = true;         /////首尾颠倒则为true
                }
                Ps = new List <WPoint2D>();
                Ns = new List <int>();
                C  = (WCurve2D)Rim_Curves[Num];
                for (int j = 0; j < C.Nodes.Count; j++)
                {
                    Ps.Add(C.Nodes[j]); /////将Curve的Node复制出来至Ps
                    Ns.Add(C.Nodes_num[j]);
                }
                WMFuncs2D.Points_Reverse(ref Ps, Tc);                       /////翻转点集
                WMFuncs2D.Nums_Reverse(ref Ns, Tc);                         /////翻转点集
                Ps.RemoveAt(0);                                             /////去掉起点
                Ns.RemoveAt(0);                                             /////去掉起点

                for (int j = 0; j < Ps.Count; j++)
                {
                    Ps_Out.Add(Ps[j]);
                    Ns_Out.Add(Ns[j]);
                }
            }
        }
示例#4
0
        /// 返回值为新的自由节点数量,用于DoubleRim
        private static int Rim_Output(ref WEntity2D[] Rim_Curves, string Path, string Name, int N)
        {
            for (int i = 0; i < Rim_Curves.Length; i++)
            {
                if (((WCurve2D)Rim_Curves[i]).Meshed_Check == false)
                {
                    return(-1);                                                   /////如果有线没有Mesh则返回-1
                }
            }
            StreamWriter Sw = new System.IO.StreamWriter(Path + Name + ".rim");
            int[] Sorts     = Geos2D_Other.Sort_Curves(Rim_Curves);

            int Num;
            bool Tc;                   /////判断某条线是否首尾颠倒,true为颠倒,false为不颠倒
            WCurve2D C;
            List <WPoint2D> Ps;
            List <int> Ns = new List <int>();
            int QuanI     = N;
            ///////处理第一条线///////
            Num = 0;
            C   = (WCurve2D)Rim_Curves[Num];
            Ps  = new List <WPoint2D>();
            for (int i = 0; i < C.Nodes.Count; i++)
            {
                Ps.Add(C.Nodes[i]);                                     /////将Curve的Node复制出来至Ps
            }
            Ps.RemoveAt(0);                                             /////去掉起点,因为最后一条线包含该点
            N = WMFuncs2D.NsID_App(ref Ps, ref Ns, N);                  /////形成节点编号
            WMFuncs2D.Ns_Out(ref Ps, ref Ns, false, 0, ref Sw);

            //////处理中间线//////////
            for (int i = 1; i <= Sorts.Length - 1; i++)
            {
                Num = (int)(Math.Floor((double)(Sorts[i] / 2)));
                if (Sorts[i] - 2 * Num == 0)
                {
                    Tc = false;
                }
                else
                {
                    Tc = true;         /////首尾颠倒则为true
                }
                Ps = new List <WPoint2D>();
                C  = (WCurve2D)Rim_Curves[Num];
                for (int j = 0; j < C.Nodes.Count; j++)
                {
                    Ps.Add(C.Nodes[j]);                                     /////将Curve的Node复制出来至Ps
                }
                WMFuncs2D.Points_Reverse(ref Ps, Tc);                       /////翻转点集
                Ps.RemoveAt(0);                                             /////去掉起点

                N = WMFuncs2D.NsID_App(ref Ps, ref Ns, N);                  /////定义节点编号
                WMFuncs2D.Ns_Out(ref Ps, ref Ns, false, 0, ref Sw);         /////输出
            }
            Sw.Close();
            return(N - QuanI);
        }
示例#5
0
        /// <summary>
        /// Mesh单条线
        /// </summary>
        /// <param name="Cin"></param>
        /// <param name="Mesh_Length"></param>
        public static void Mesh_Curve(WEntity2D Cin, double Mesh_Length)
        {
            WCurve2D C = (WCurve2D)Cin;
            int      Times;

            if (C.Meshed_Check == true)
            {
                if (C.StartPoint.DistanceTo(C.Nodes[0]) > (C.StartPoint.DistanceTo(C.Nodes[C.Nodes.Count - 1])))
                {
                    WMFuncs2D.Points_Reverse(ref C.Nodes, true);                       /////翻转点集
                }
                return;
            }
            Times   = (int)Math.Ceiling(C.Length / Mesh_Length);
            C.Nodes = Geos2D_Modify.DotCurve_Times(C, Times);
        }
示例#6
0
 /// 节点集输出至文件,用在Glass上
 /// <summary>
 /// 节点集输出至文件,用在Glass上
 /// </summary>
 /// <param name="Ps">节点集位置</param>
 /// <param name="Nums">节点集编号</param>
 /// <param name="sw">输出对象</param>
 /// <param name="Mid_Check">判断中间的节点是否输出</param>
 /// <param name="HT_Check">判断两头的节点是否输出</param>
 /// <param name="Round">保留小数点数位</param>
 public static void Ns_Out(ref List <WPoint2D> Ps, ref List <int> Nums, ref StreamWriter sw, bool Mid_Check, bool HT_Check)
 {
     if (HT_Check == true)
     {
         WMFuncs2D.N_Out(Ps[0], Nums[0], ref sw);
     }
     if (Mid_Check == true)
     {
         for (int i = 1; i < Ps.Count - 1; i++)
         {
             WMFuncs2D.N_Out(Ps[i], Nums[i], ref sw);
         }
     }
     if (HT_Check == true)
     {
         WMFuncs2D.N_Out(Ps[Ps.Count - 1], Nums[Ps.Count - 1], ref sw);
     }
 }
示例#7
0
        /// <summary>
        /// Mesh线集合
        /// </summary>
        /// <param name="Cs"></param>
        /// <param name="Mesh_Length"></param>
        public static void Mesh_Curves(ref WEntity2D[] Cs, double Mesh_Length)
        {
            WCurve2D C;
            int      Times;

            for (int i = 0; i < Cs.Length; i++)
            {
                C = (WCurve2D)Cs[i];
                if (C.Meshed_Check == true)
                {
                    if (C.StartPoint.DistanceTo(C.Nodes[0]) > (C.StartPoint.DistanceTo(C.Nodes[C.Nodes.Count - 1])))
                    {
                        WMFuncs2D.Points_Reverse(ref C.Nodes, true);                       /////翻转点集
                    }
                    continue;
                }
                Times   = (int)Math.Ceiling(C.Length / Mesh_Length);
                C.Nodes = Geos2D_Modify.DotCurve_Times(Cs[i], Times);
            }
        }