예제 #1
0
        public static WMesh2D_Mesh Mesh_SingleRim(ref WEntity2D[] Rim, string Name, ref WMesh2D_Para MP)
        {
            WShapeRim2D Shape = Rim_Output(ref Rim, MP.Path, Name);

            if (Shape == null)
            {
                return(null);
            }
            Poly_SingleRim(Shape.Count, MP.Path, Name);
            WMesh2D_Mesh Mesh = Mesh2D_TriangleMesh.Triangle_Mesh(ref MP, Name);      /////调用

            if (Mesh == null)
            {
                return(null);
            }
            Mesh.Shapes.Add(Shape);
            Mesh.Input_Bound(Shape.Xmin, Shape.Xmax, Shape.Ymin, Shape.Ymax);
            return(Mesh);
        }
예제 #2
0
        /// 返回值为自由节点组成的圈圈,用于显示,用于SingleRim
        private static WShapeRim2D Rim_Output(ref WEntity2D[] Rim_Curves, string Path, string Name)
        {
            for (int i = 0; i < Rim_Curves.Length; i++)
            {
                if (((WCurve2D)Rim_Curves[i]).Meshed_Check == false)
                {
                    return(null);                                                   /////如果有线没有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>();
            WShapeRim2D Shape = new WShapeRim2D(Color.Black, 1f);
            int N             = 0;
            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);
            Shape.Add_Ps(ref Ps, ref Ns, false, 0);

            //////处理中间线//////////
            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);         /////输出
                Shape.Add_Ps(ref Ps, ref Ns, false, 0);
            }
            Sw.Close();
            return(Shape);
        }