コード例 #1
0
ファイル: Mesh_Glass.cs プロジェクト: wuxiaod1987/WCAE
        /// 寻找某个点集的节点编号,若节点不存在则创造节点
        private static List <int> Get_NodeNums(List <WPoint2D> Ps, WMesh2D_Mesh Mesh, ref int N)
        {
            List <int> Nums  = new List <int>();  /////注意节点编号是从0开始的
            bool       Check = false;

            for (int i = 0; i < Ps.Count; i++)
            {
                Check = false;
                for (int j = 1; j < Mesh.Nodes.Count; j++)
                {
                    if (WMFuncs2D.Near_Check(Ps[i], Mesh.Nodes[j]) == true)
                    {
                        Nums.Add(j);
                        Check = true;
                        break;
                    }
                }
                if (Check == true)
                {
                    continue;
                }
                N++;
                Mesh.Add_N(Ps[i], N);
                Nums.Add(N);
            }
            return(Nums);
        }
コード例 #2
0
ファイル: WMesh2D_IO.cs プロジェクト: wuxiaod1987/WCAE
        public static void Write_WMeshFile(string Path, ref WMesh2D_Mesh Mesh)
        {
            StreamWriter Sw = new StreamWriter(Path + Mesh.Name + ".mesh");

            Sw.WriteLine("Parameters of the Mesh:");
            Sw.WriteLine(Mesh.Q_FreeNs);
            Sw.WriteLine("  Following Lines are Nodes");
            Sw.WriteLine("______________________________");
            for (int i = 1; i < Mesh.Nodes.Count; i++)
            {
                Sw.WriteLine(Convert.ToString(i) + "	"+
                             Convert.ToString(Mesh.Nodes[i].X) + "," +
                             Convert.ToString(Mesh.Nodes[i].Y) + "," +
                             Convert.ToString(Mesh.Nodes[i].Trace));
            }
            Sw.WriteLine("");
            Sw.WriteLine("  Following Lines are Elements");
            Sw.WriteLine("______________________________");
            for (int i = 0; i < Mesh.Elements.Count; i++)
            {
                Sw.WriteLine(Convert.ToString(Mesh.Elements[i].Kind) + "	"+
                             Convert.ToString(Mesh.Elements[i].N1) + "," +
                             Convert.ToString(Mesh.Elements[i].N2) + "," +
                             Convert.ToString(Mesh.Elements[i].N3) + "," +
                             Convert.ToString(Mesh.Elements[i].N4));
            }
            Sw.Close();
        }
コード例 #3
0
ファイル: Mesh2D_MeshFree.cs プロジェクト: wuxiaod1987/WCAE
        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());
        }
コード例 #4
0
ファイル: Mesh_Pole.cs プロジェクト: wuxiaod1987/WCAE
        private static WMesh2D_Mesh Mesh_SinglePole(WRim2D Rim, ref GLCommon GLC, ref List <WPoint2D>[] Ptts, string Name)
        {
            WMFuncs2D.Mesh_Curves(ref Rim.Curves, GLC.Mesh_Length);  /////Mesh每条线
            WMesh2D_Mesh Mesh = Mesh2D_MeshFree.Mesh_SingleRim(ref Rim.Curves, Name, ref GLC.MP);

            if (Mesh == null)
            {
                return(null);
            }
            int R = (int)(Rim.Color.R * 0.8);
            int G = (int)(Rim.Color.G * 0.8);
            int B = (int)(Rim.Color.B * 0.8);

            Mesh.Color = Color.FromArgb(255, R, G, B);
            Mesh.Trace = 2;
            PotentNs_App(ref Mesh.Nodes, ref Ptts, GLC.Potent_Lmax);
            int Quan_E = Mesh.QEs;

            for (int i = 0; i < Quan_E; i++)
            {
                Mesh.Elements.Add(new WElement2D(Mesh.Elements[i].Kind * (-1),
                                                 Mesh.Elements[i].N1,
                                                 Mesh.Elements[i].N2,
                                                 Mesh.Elements[i].N3,
                                                 Mesh.Elements[i].N4));
            }
            return(Mesh);
        }
コード例 #5
0
        /// <summary>
        /// 从一个Poly文件,Mesh后形成Mesh2D类
        /// </summary>
        /// <param name="MP"></param>
        /// <param name="Name">简短文件名</param>
        /// <returns></returns>
        public static WMesh2D_Mesh Triangle_Mesh(ref WMesh2D_Para MP, string Name)
        {
            Tiangle_Call New_Call = new Tiangle_Call(MP.Path + Name + ".poly", ref MP);

            #region 多线程
            ThreadStart start  = new ThreadStart(New_Call.Triangulate_Refine);
            Thread      thread = new Thread(start);
            thread.Name = "Tiangle_Call";
            thread.Start();

            while (true)
            {
                if (thread.ThreadState == System.Threading.ThreadState.Stopped)
                {
                    break;
                }
            }
            #endregion
            #region 单线程
            //New_Call.Triangulate_Refine();
            #endregion

            bool C = New_Call.Out;
            if (C == false)
            {
                return(null);
            }
            Mesh mesh = New_Call.Mesh;

            Node[]    Ns = new Node[0];       /////注意该数组是从1开始的,目的是为了Element使用方便
            Element[] Es = new Element[0];

            FileWriter.WritePoly(mesh, MP.Path + Name + "_.poly");
            FileWriter.Trans_Mesh(mesh, ref Ns, ref Es);
            Mesh2D_TriangleComb.Elements_Combine(ref Ns, ref Es, ref MP);
            /////
            WMesh2D_Mesh Mesh = new WMesh2D_Mesh(Name);
            Mesh.Q_FreeNs = MP.QN_Ini;
            for (int i = 1; i < Ns.Length; i++)
            {
                Mesh.Nodes.Add(new WNode2D(i, Ns[i].x, Ns[i].y, 0));
            }
            for (int i = 0; i < Es.Length; i++)
            {
                if (Es[i].Valid == false)
                {
                    continue;
                }
                Mesh.Elements.Add(new WElement2D(Es[i].Kind, Es[i].N1, Es[i].N2, Es[i].N3, Es[i].N4));
            }
            File.Delete(MP.Path + Name + ".poly");
            File.Delete(MP.Path + Name + "_.poly");
            Ns   = null;
            Es   = null;
            mesh = null;

            return(Mesh);
        }
コード例 #6
0
ファイル: WFEM_NegVideo.cs プロジェクト: wuxiaod1987/WCAE
        public static WFEM_NegOut Create(ref WFEM_NegPara NP, WMesh2D_Mesh Mesh, string ResultFile, String ProgramPath, String[] Titles)
        {
            double[] RESM = new double[2];
            RESM = FindLimit(ResultFile);   /////如果不限制最大/最小值则需要找到最大/最小值
            StreamReader sr = new StreamReader(ResultFile);

            sr.ReadLine();
            int Quan_Frames = Convert.ToInt16(sr.ReadLine());

            sr.ReadLine();
            int Quan_Nodes = Convert.ToInt16(sr.ReadLine());

            sr.ReadLine();
            /////
            double[] RES  = new double[Quan_Nodes + 1];
            String   Path = NP.PicPath;
            String   Name = NP.PicName;

            NP.PicPath = Path + "VT" + DateTime.Now.TimeOfDay.ToString().Replace(":", "");
            Directory.CreateDirectory(NP.PicPath);
            NP.PicPath += "\\";
            WFEM_NegOut ParaOut = null;

            for (int i = 0; i < Quan_Frames; i++)
            {
                if (NP.VidTitleOut == true && Titles.Length == Quan_Frames)
                {
                    NP.PicTitle = Titles[i];
                }
                //Debugger.Break();
                for (int j = 1; j <= Quan_Nodes; j++)
                {
                    RES[j] = Convert.ToDouble(sr.ReadLine());
                }
                sr.ReadLine();
                NP.PicName = (i + 1).ToString();
                ParaOut    = WFEM_NegContour.Draw_to_PNG(ref NP, Mesh, ref RES, ref RESM);
            }
            //=============================//
            Process Proc = new Process();
            String  Arg  = NP.PicPath + ",";

            Arg += (Path + Name + ".avi" + ",");
            Arg += (NP.PicWidth.ToString() + ",");
            Arg += (NP.PicHeight.ToString() + ",");
            Arg += (NP.VidFrameRate.ToString() + ",");
            Arg += (Quan_Frames.ToString() + ",");
            /////
            Proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            Proc.StartInfo.FileName    = ProgramPath + "\\VideoCreator\\VideoCreator.exe";
            //Console.WriteLine(Proc.StartInfo.FileName);
            Proc.StartInfo.Arguments = Arg;
            Proc.Start();
            ///
            NP.PicPath = Path;
            NP.PicName = Name;
            return(ParaOut); /////返回最后一帧的结果
        }
コード例 #7
0
        private static Bitmap Draw_to_Bitmap(ref WFEM_NegPara NP, WMesh2D_Mesh Mesh, ref double[] RES, ref WFEM_NegOut ParaOut)
        {
            #region 结果的最小值,最大值
            double[] RESM_in = new double[0]; int[] NodeM_in = new int[0];
            Compute_ResPara(ref RES, ref RESM_in, ref NodeM_in);
            //Debugger.Break();
            if (ParaOut.RESM == null)
            {
                ParaOut.RESM  = RESM_in;
                ParaOut.NodeM = NodeM_in;
            }
            #endregion

            #region 求取颜色变量
            ParaOut.Res_Each = Compute_ResEach(ref NP, ref RES, ref ParaOut.RESM);
            #endregion

            #region "初始化绘图工具"
            Bitmap   bitmap  = new Bitmap(NP.PicWidth, NP.PicHeight);
            Graphics graphic = Graphics.FromImage(bitmap);
            graphic.Clear(NP.Color_BackGround);
            #endregion

            #region 绘制Lable及Title
            int LableHeight = NP.PicRim;
            if (NP.ShowLable == true)
            {
                LableHeight = Draw_Label(ref NP, ref graphic, ref ParaOut.Res_Each);  /////绘制Label
            }
            int TitleHeight = NP.PicRim;
            if (NP.ShowTitle == true)
            {
                TitleHeight = Draw_Title(ref NP, ref graphic, NP.PicTitle);   /////绘制Title
            }
            #endregion

            #region 求取绘图比例
            double[] DrawRate = Compute_DrawRate((Mesh.Xmax - Mesh.Xmin),     /////求取绘图比例
                                                 (Mesh.Ymax - Mesh.Ymin),
                                                 NP.PicWidth - NP.PicRim * 2,
                                                 NP.PicHeight - TitleHeight - LableHeight);
            #endregion

            /////绘制所有单元
            ParaOut.Areas = Draw_Elements(ref NP, ref Mesh,
                                          ref RES, ref ParaOut.Res_Each,
                                          ref graphic, ref DrawRate, LableHeight);

            /////绘制最大值最小值
            Draw_MaxMin(ref NP, ref graphic, Mesh,
                        RESM_in, NodeM_in,
                        DrawRate, NP.PicHeight - LableHeight, TitleHeight);

            graphic.Dispose();
            return(bitmap);
        }
コード例 #8
0
ファイル: WMesh2D_IO.cs プロジェクト: wuxiaod1987/WCAE
        public static void Read_WMeshFile(string FileName, ref WMesh2D_Mesh Mesh)
        {
            StreamReader sr = new StreamReader(FileName);

            sr.ReadLine();
            sr.ReadLine();
            sr.ReadLine();
            sr.ReadLine();
            string t = sr.ReadLine();

            string[] t_1;
            int      No  = 0;
            int      QNo = Mesh.Nodes.Count - 1; /////已经读入的节点的数量

            ///获取节点信息
            t   = t.Split('	')[1];
            t_1 = t.Split(',');
            No++;
            Mesh.Nodes.Add(new WNode2D(Convert.ToDouble(t_1[0]),
                                       Convert.ToDouble(t_1[1])));
            t = sr.ReadLine();
            while (t != "")
            {
                t   = t.Split('	')[1];
                t_1 = t.Split(',');
                No++;
                Mesh.Nodes.Add(new WNode2D(Convert.ToDouble(t_1[0]),
                                           Convert.ToDouble(t_1[1])));
                t = sr.ReadLine();
            }
            ///获取单元信息
            sr.ReadLine();
            sr.ReadLine();
            int K;

            while (sr.Peek() != -1)
            {
                t_1 = sr.ReadLine().Split('	');
                if (t_1[0] == "0")
                {
                    continue;
                }
                K   = Convert.ToInt16(t_1[0]);
                t_1 = t_1[1].Split(',');
                Mesh.Elements.Add(new WElement2D(K,
                                                 Convert.ToInt32(t_1[0]) + QNo,
                                                 Convert.ToInt32(t_1[1]) + QNo,
                                                 Convert.ToInt32(t_1[2]) + QNo,
                                                 Convert.ToInt32(t_1[3]) + QNo));
            }
            sr.Close();
            sr.Dispose();
        }
コード例 #9
0
        /// 绘制2D结果的云图
        /// <summary>
        /// 绘制2D结果的云图
        /// </summary>
        /// <param name="NP">云图绘制参数</param>
        /// <param name="Mesh">需要绘制的Mesh</param>
        /// <param name="RES">每个节点的结果数组,数组编号应与节点编号一致</param>
        /// <returns></returns>
        public static WFEM_NegOut Draw_to_PNG(ref WFEM_NegPara NP, WMesh2D_Mesh Mesh, ref double[] RES)
        {
            WFEM_NegOut ParaOut = new WFEM_NegOut();

            ParaOut.RES = RES;
            Bitmap bitmap = Draw_to_Bitmap(ref NP, Mesh, ref RES, ref ParaOut);

            /////保存并结束
            bitmap.Save(NP.PicPath + NP.PicName + ".png");
            bitmap.Dispose();
            return(ParaOut);
        }
コード例 #10
0
ファイル: Mesh_Glass.cs プロジェクト: wuxiaod1987/WCAE
 /// 寻找某个已有节点编号,不存在则
 private static int Get_NodeNum(WPoint2D P, WMesh2D_Mesh Mesh, ref int N)
 {
     for (int j = 1; j < Mesh.Nodes.Count; j++)
     {
         if (WMFuncs2D.Near_Check(P, Mesh.Nodes[j]) == true)
         {
             return(j);
         }
     }
     N++;
     Mesh.Add_N(P, N);
     return(N);
 }
コード例 #11
0
        /// 读取单元,转换单元编号,输出
        private static void MeshFile_ElementRead(ref int[] Ns, ref WMesh2D_Mesh Mesh_in, ref WMesh2D_Mesh Mesh_Out)
        {
            WElement2D E;

            for (int i = 0; i < Mesh_in.Elements.Count; i++)
            {
                E    = Mesh_in.Elements[i];
                E.N1 = Ns[E.N1];
                E.N2 = Ns[E.N2];
                E.N3 = Ns[E.N3];
                E.N4 = Ns[E.N4];
                Mesh_Out.Elements.Add(E);
            }
        }
コード例 #12
0
        /// 读取剩余节点并直接输出
        /// <param name="Ns">用Ref传递的节点编号数组,该数组会被逐渐扩充</param>
        /// <param name="Num">用以记录节点数量的变量,输出值也为该参数</param>
        private static int Read_OtherNodes(ref int[] Ns, ref WMesh2D_Mesh Mesh_in, ref WMesh2D_Mesh Mesh_Out, int Num)
        {
            int Quan = Ns.Length;

            for (int i = Mesh_in.Q_FreeNs + 1; i < Mesh_in.Nodes.Count; i++)
            {
                Quan++;
                Array.Resize <int>(ref Ns, Quan);
                Num++;
                Ns[Quan - 1] = Num;
                Mesh_Out.Add_N(Mesh_in.Nodes[i]);
            }
            return(Num);
        }
コード例 #13
0
        /// 求单元的各种参数
        /// <summary>
        /// 求单元的各种参数
        /// </summary>
        private static void Compute_ElementParas(ref WMesh2D_Mesh Mesh, int EN, ref double[] RES,
                                                 ref int[] Ns_CIs, ref double[] E_Rs, ref int[] E_CIs, ref WNode2D[] E_Ns)
        {
            int K = Mesh.Elements[EN].Kind;

            E_Rs    = new double[K + 1]; E_Ns = new WNode2D[K + 1]; E_CIs = new int[K + 1]; /////为了循环方便,将最后0#节点数值复制到最后
            E_Rs[0] = RES[Mesh.Elements[EN].N1]; E_Ns[0] = Mesh.Nodes[Mesh.Elements[EN].N1]; E_CIs[0] = Ns_CIs[Mesh.Elements[EN].N1];
            E_Rs[1] = RES[Mesh.Elements[EN].N2]; E_Ns[1] = Mesh.Nodes[Mesh.Elements[EN].N2]; E_CIs[1] = Ns_CIs[Mesh.Elements[EN].N2];
            E_Rs[2] = RES[Mesh.Elements[EN].N3]; E_Ns[2] = Mesh.Nodes[Mesh.Elements[EN].N3]; E_CIs[2] = Ns_CIs[Mesh.Elements[EN].N3];
            if (K == 4)
            {
                E_Rs[3] = RES[Mesh.Elements[EN].N4]; E_Ns[3] = Mesh.Nodes[Mesh.Elements[EN].N4]; E_CIs[3] = Ns_CIs[Mesh.Elements[EN].N4];
            }
            E_Rs[K] = E_Rs[0]; E_Ns[K] = E_Ns[0]; E_CIs[K] = E_CIs[0];                   /////为了循环方便,将最后0#节点数值复制到最后
        }
コード例 #14
0
ファイル: Mesh_Free.cs プロジェクト: wuxiaod1987/WCAE
        /// <summary>
        /// Mesh内部区域
        /// </summary>
        private static WMesh2D_Mesh Mesh_InnerFree(WRim2D Rim, ref GLCommon GLC, string Name)
        {
            WMFuncs2D.Mesh_Curves(ref Rim.Curves, GLC.Mesh_Length);  /////Mesh每条线
            WMesh2D_Mesh Mesh = Mesh2D_MeshFree.Mesh_SingleRim(ref Rim.Curves, Name, ref GLC.MP);

            if (Mesh == null)
            {
                return(null);
            }
            int R = (int)(Rim.Color.R * 0.8);
            int G = (int)(Rim.Color.G * 0.8);
            int B = (int)(Rim.Color.B * 0.8);

            Mesh.Color = Color.FromArgb(255, R, G, B);
            Mesh.Trace = 3;
            return(Mesh);
        }
コード例 #15
0
        /// 网格合并
        /// <summary>
        /// 网格合并
        /// </summary>
        /// <param name="Mesh1"></param>
        /// <param name="Mesh2"></param>
        /// <param name="Name_New">新网格的名称</param>
        /// <returns></returns>
        public static WMesh2D_Mesh Mesh_Combine(WMesh2D_Mesh Mesh1, WMesh2D_Mesh Mesh2, string Name_New)
        {
            Initial();
            WMesh2D_Mesh Mesh_Out = new WMesh2D_Mesh(Name_New);

            Combine_FreeNodes(ref Mesh1, ref Mesh2, ref Mesh_Out);           /////处理自由节点,形成两个Mesh的自由节点的新的编号

            Num = Read_OtherNodes(ref Ns1, ref Mesh1, ref Mesh_Out, Num);
            Num = Read_OtherNodes(ref Ns2, ref Mesh2, ref Mesh_Out, Num);

            MeshFile_ElementRead(ref Ns1, ref Mesh1, ref Mesh_Out);
            MeshFile_ElementRead(ref Ns2, ref Mesh2, ref Mesh_Out);

            Ns1 = new int[0];
            Ns2 = new int[0];

            return(Mesh_Out);
        }
コード例 #16
0
ファイル: Mesh2D_MeshFree.cs プロジェクト: wuxiaod1987/WCAE
        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);
        }
コード例 #17
0
ファイル: Mesh_Pole.cs プロジェクト: wuxiaod1987/WCAE
        private static void Out_toMesh(ref List <int>[] Rims, ref WMesh2D_Para MP, ref WEntity2D[] Poles, ref WMesh2D_Mesh Mesh)
        {
            WEntity2D[]    Rim_Curves;
            WMesh2D_Mesh[] Meshs_t = new WMesh2D_Mesh[Rims.Length];
            for (int i = 0; i < Rims.Length; i++)
            {
                Rim_Curves = new WEntity2D[Rims[i].Count];
                for (int j = 0; j < Rims[i].Count; j++)
                {
                    Rim_Curves[j] = (WEntity2D)Poles[Rims[i][j]];
                }
                Meshs_t[i] = Mesh2D_MeshFree.Mesh_SingleRim(ref Rim_Curves, Convert.ToString(i), ref MP);
            }

            Mesh = Meshs_t[0];
            for (int i = 1; i < Rims.Length; i++)
            {
                Mesh = Mesh2D_Merge_Mesh2Mesh.Mesh_Combine(Mesh, Meshs_t[i], "Pole");
            }
            Meshs_t = null;
        }
コード例 #18
0
ファイル: Mesh_Glass.cs プロジェクト: wuxiaod1987/WCAE
        /// 分割点集为线段集合
        private static void Divide_Ps(List <WPoint2D> Ps, ref int N, ref WEntity2D[] Bds, int Trace, WMesh2D_Mesh Mesh, bool Meshed, double Mesh_Length)
        {
            List <int> Nums = Get_NodeNums(Ps, Mesh, ref N);               /////得到Pts的节点编号集合,从0开始
            int        Q;

            for (int i = 0; i < Ps.Count - 1; i++)
            {
                Array.Resize <WEntity2D>(ref Bds, Bds.Length + 1);
                Q      = Bds.Length - 1;
                Bds[Q] = new WLine2D(Ps[i], Ps[i + 1]);
                ((WLine2D)(Bds[Q])).Trace = Trace;
                if (Meshed == true)
                {
                    ((WLine2D)(Bds[Q])).Nodes.Add(Ps[i]);
                    ((WLine2D)(Bds[Q])).Nodes.Add(Ps[i + 1]);
                    ((WLine2D)(Bds[Q])).Nodes_num.Add(Nums[i]);
                    ((WLine2D)(Bds[Q])).Nodes_num.Add(Nums[i + 1]);
                }
                else
                {
                    WMFuncs2D.Mesh_Curve(Bds[Q], Mesh_Length);
                    ((WLine2D)(Bds[Q])).Nodes_num.Add(Nums[i]);
                    for (int j = 1; j < ((WLine2D)(Bds[Q])).Nodes.Count - 1; j++)
                    {
                        N++;
                        Mesh.Add_N(((WLine2D)(Bds[Q])).Nodes[j], N);
                        ((WLine2D)(Bds[Q])).Nodes_num.Add(N);
                    }
                    ((WLine2D)(Bds[Q])).Nodes_num.Add(Nums[i + 1]);
                }
            }
        }
コード例 #19
0
ファイル: Mesh_Glass.cs プロジェクト: wuxiaod1987/WCAE
        private static WMesh2D_Mesh Mesh_FreeRim(ref WEntity2D[] WBs, ref WEntity2D[] Ws, ref GLCommon GLC, string Name)
        {
            WMesh2D_Mesh Mesh_Glass = new WMesh2D_Mesh(Name);

            /////
            WEntity2D[]  Bds  = new WEntity2D[0];                                            /////所有的内部边界线
            List <int>[] Rims = Find_BdsRims(ref WBs, ref Ws, ref GLC, ref Bds, Mesh_Glass); /////找到所有的边界线及所有的区域
            /////逐个Rim分别Mesh
            WElement2D[]    Es = new WElement2D[0];
            WEntity2D[]     Rim;
            List <int>      Ns = new List <int>();
            List <WPoint2D> Ps = new List <WPoint2D>();

            /////
            for (int i = 0; i < Rims.Length; i++)
            {
                Rim = new WEntity2D[Rims[i].Count];
                for (int j = 0; j < Rim.Length; j++)
                {
                    Rim[j] = Bds[Rims[i][j]];
                }

                Es = Mesh2D_SingleLayerMesh.Do_Mesh(ref Rim, i.ToString(), ref GLC.MP);
                if (Es == null || Es.Length == 0)
                {
                    for (int j = 0; j < Rim.Length; j++)
                    {
                        for (int k = 0; k < ((WCurve2D)Rim[j]).Nodes.Count - 1; k++)
                        {
                            Ps.Add(((WCurve2D)Rim[j]).Nodes[k]);
                            Ns.Add(((WCurve2D)Rim[j]).Nodes_num[k]);
                        }
                    }
                    Es = Mesh2D_MeshFree.Mesh_SingleRim(ref Ns, ref Ps, ref GLC.MP, i.ToString());
                }
                if (Es == null || Es.Length == 0)
                {
                    continue;
                }
                Mesh_Glass.Add_Es(ref Es);
            }
            if (Mesh_Glass.QEs == 0)
            {
                return(null);
            }
            else
            {
                for (int i = 0; i < Bds.Length; i++)
                {
                    if (Bds[i].Trace != -2)
                    {
                        continue;
                    }
                    Es = new WElement2D[0];
                    WMFuncs2D.E2sID_App(ref ((WCurve2D)Bds[i]).Nodes_num, ref Es, 0, true);  /////Beam单元生成
                    if (Es == null || Es.Length == 0)
                    {
                        continue;
                    }
                    Mesh_Glass.Add_Es(ref Es);                                               /////Beam单元输出
                }
            }
            /////
            int Nt = 0;

            for (int i = 0; i < WBs.Length; i++)
            {
                if (((WCurve2D)WBs[i]).Meshed_Check == true)
                {
                    continue;
                }
                ((WCurve2D)WBs[i]).Nodes = new List <WPoint2D>();
                for (int j = 0; j < Bds.Length; j++)
                {
                    Nt = ((WCurve2D)Bds[j]).Trace;
                    if (Nt != i)
                    {
                        continue;
                    }
                    for (int k = 0; k < ((WCurve2D)Bds[j]).Nodes.Count - 1; k++)
                    {
                        ((WCurve2D)WBs[i]).Nodes.Add(((WCurve2D)Bds[j]).Nodes[k]);
                    }
                }
                ((WCurve2D)WBs[i]).Nodes.Add(new WPoint2D(((WCurve2D)WBs[i]).EndPoint.X, ((WCurve2D)WBs[i]).EndPoint.Y));
            }
            //////
            return(Mesh_Glass);
        }
コード例 #20
0
ファイル: WMeshRenderer.cs プロジェクト: wuxiaod1987/WCAE
        public void RenderSingleMesh(Graphics g, ScreenTrans zoom, RenderParameter RParas, WMesh2D_Mesh Mesh)
        {
            PointF P;

            PointF[] Ps;

            Brush tB = new SolidBrush(Mesh.Color);

            int Num;
            int Kind;

            /////节点转换
            PointF[] Ns = new PointF[Mesh.QNs + 1];
            for (int i = 1; i <= Mesh.QNs; i++)
            {
                Ns[i] = new PointF((float)Mesh.Nodes[i].X, (float)Mesh.Nodes[i].Y);
                Ns[i] = zoom.WorldToScreen(Ns[i].X, Ns[i].Y);
            }
            /////使用Shape输出
            bool Check_Fill = false;
            //if (Mesh.Shapes != null && Mesh.Shapes.Count != 0)
            //{
            //    for (int i = 0; i < Mesh.Shapes.Count; i++)
            //    {
            //        Ps = new PointF[Mesh.Shapes[i].Count];
            //        for (int j = 0; j < Mesh.Shapes[i].Count; j++)
            //        {
            //            Ps[j] = new PointF((float)Mesh.Shapes[i][j].X, (float)Mesh.Shapes[i][j].Y);
            //            Ps[j] = zoom.WorldToScreen(Ps[j].X, Ps[j].Y);
            //        }
            //        g.FillPolygon(tB, Ps);
            //    }
            //    Check_Fill = true;
            //}
            /////
            bool Check_Frame = false;

            if (Mesh.NsPairs != null && Mesh.NsPairs.Length > 0)
            {
                Ps = new PointF[2];
                for (int i = 0; i < Mesh.NsPairs.Length; i++)
                {
                    g.DrawLine(RParas.PenES, Ns[Mesh.NsPairs[i].N1], Ns[Mesh.NsPairs[i].N2]);
                }
                Check_Frame = true;
            }
            /////单元输出
            if (Check_Fill == false || Check_Frame == false)
            {
                for (int i = 0; i < Mesh.QEs; i++)
                {
                    Kind = Mesh.Elements[i].Kind;
                    if (Kind < 3)
                    {
                        continue;
                    }
                    /////
                    Ps = new PointF[Kind + 1];

                    Num = Mesh.Elements[i].N1;
                    if (Num < 0)
                    {
                        continue;
                    }
                    Ps[0] = Ns[Num];
                    Num   = Mesh.Elements[i].N2;
                    if (Num < 0)
                    {
                        continue;
                    }
                    Ps[1] = Ns[Num];
                    Num   = Mesh.Elements[i].N3;
                    if (Num < 0)
                    {
                        continue;
                    }
                    Ps[2] = Ns[Num];
                    if (Kind == 4)
                    {
                        Num = Mesh.Elements[i].N4;
                        if (Num < 0)
                        {
                            continue;
                        }
                        Ps[3] = Ns[Num];
                    }
                    Ps[Kind] = Ps[0];
                    /////
                    if (Check_Fill == false)
                    {
                        g.FillPolygon(tB, Ps);
                    }
                    if (Check_Frame == false)
                    {
                        g.DrawPolygon(RParas.PenES, Ps);
                    }
                }
            }
            /////
            for (int i = 0; i < Mesh.Elements.Count; i++)
            {
                Kind = Mesh.Elements[i].Kind;
                if (Kind == 2)
                {
                    Ps    = new PointF[2];
                    Num   = Mesh.Elements[i].N1;
                    Ps[0] = Ns[Num];
                    Num   = Mesh.Elements[i].N2;
                    Ps[1] = Ns[Num];
                    g.DrawLine(RParas.PenEB, Ps[0], Ps[1]);
                    continue;
                }
            }

            if (RParas.SwitchN == false)
            {
                return;
            }
            for (int i = 1; i < Mesh.Nodes.Count; i++)
            {
                P = new PointF((float)Mesh.Nodes[i].X, (float)Mesh.Nodes[i].Y);
                P = zoom.WorldToScreen(P.X, P.Y);
                g.FillEllipse(RParas.BrushN, P.X - RParas.Rn / 2, P.Y - RParas.Rn / 2, RParas.Rn, RParas.Rn);
            }
        }
コード例 #21
0
ファイル: Mesh_Glass.cs プロジェクト: wuxiaod1987/WCAE
        /// 找到所有的边界线及所有的区域
        private static List <int>[] Find_BdsRims(ref WEntity2D[] WBs, ref WEntity2D[] Ws, ref GLCommon GLC, ref WEntity2D[] Bds, WMesh2D_Mesh Mesh)
        {
            int             N = 0;  /////记录节点编号
            List <WPoint2D> Pts;    /////辅助点集
            int             Q, Q2;
            /////找到每条边界线与夹丝线的交点
            WCurve2D C;

            for (int i = 0; i < WBs.Length; i++)
            {
                C = (WCurve2D)(WBs[i]);
                if (C.Meshed_Check == true)
                {
                    Geos2D_Other.Merge_Points(ref C.Nodes);  /////去掉多余节点
                    Pts = C.Nodes;
                    if (WMFuncs2D.Length_P2P(C.StartPoint, Pts[0]) > WMFuncs2D.Length_P2P(C.EndPoint, Pts[0]))
                    {
                        WMFuncs2D.Points_Reverse(ref Pts, true);
                    }
                    if (WMFuncs2D.Near_Check(Pts[0], C.StartPoint) == false)
                    {
                        Pts.Insert(0, C.StartPoint);
                    }
                    if (WMFuncs2D.Near_Check(Pts[Pts.Count - 1], C.EndPoint) == false)
                    {
                        Pts.Add(C.EndPoint);
                    }
                    C.Nodes = Pts;
                    /////
                    Divide_Ps(Pts, ref N, ref Bds, -1, Mesh, true, GLC.Mesh_Length);    /////分割点集为线段集合
                }
                else
                {
                    Pts = Geos2D_Intersection.Intersection_Cv2Ls(WBs[i], ref Ws); /////找与上下边线的交点作为划分的边界
                    if (Pts.Count < 2)
                    {
                        Array.Resize <WEntity2D>(ref Bds, Bds.Length + 1);
                        Bds[Bds.Length - 1] = WBs[i];
                        ((WCurve2D)Bds[Bds.Length - 1]).Trace = -1;
                        WMFuncs2D.Mesh_Curve(Bds[Bds.Length - 1], GLC.Mesh_Length);
                        ((WCurve2D)Bds[Bds.Length - 1]).Nodes_num = Get_NodeNums(((WCurve2D)Bds[Bds.Length - 1]).Nodes, Mesh, ref N);
                        continue;
                    }
                    else
                    {
                        Geos2D_Other.Merge_Points(ref Pts);  /////去掉多余节点
                    }
                    if (WMFuncs2D.Length_P2P(C.StartPoint, Pts[0]) > WMFuncs2D.Length_P2P(C.EndPoint, Pts[0]))
                    {
                        WMFuncs2D.Points_Reverse(ref Pts, true);
                    }
                    if (WMFuncs2D.Near_Check(Pts[0], C.StartPoint) == false)
                    {
                        Pts.Insert(0, C.StartPoint);
                    }
                    if (WMFuncs2D.Near_Check(Pts[Pts.Count - 1], C.EndPoint) == false)
                    {
                        Pts.Add(C.EndPoint);
                    }
                    /////
                    Divide_Ps(Pts, ref N, ref Bds, i, Mesh, false, GLC.Mesh_Length);    /////分割点集为线段集合
                }
            }
            Mesh.Q_FreeNs = N;
            /////找到所有夹丝线的交点,形成新的直线加入
            for (int i = 0; i < Ws.Length; i++)
            {
                Pts = Geos2D_Intersection.Intersection_L2Cvs((WLine2D)Ws[i], ref WBs); /////找与上下边线的交点作为划分的边界
                if (Pts.Count == 0)
                {
                    continue;                                                          /////夹丝线与上下边界不一定会有交点
                }
                Geos2D_Other.Merge_Points(ref Pts);                                    /////去掉多余节点
                if (Pts.Count == 1)
                {
                    continue;
                }
                /////
                Array.Resize <WEntity2D>(ref Bds, Bds.Length + 1);
                Q            = Bds.Length - 1;
                Bds[Q]       = new WLine2D(Pts[0], Pts[1]);
                Bds[Q].Trace = -2;
                WMFuncs2D.Mesh_Curve(Bds[Q], GLC.Mesh_Length);                                                    /////生成该线的节点
                N = WMFuncs2D.NsID_App(ref ((WCurve2D)Bds[Q]).Nodes, ref ((WCurve2D)Bds[Q]).Nodes_num, false, N); /////Mesh该线,注意头尾不要
                Mesh.Add_Ns(ref ((WCurve2D)Bds[Q]).Nodes, ref ((WCurve2D)Bds[Q]).Nodes_num, true, false);         /////将节点编号输入至Mesh中,注意头尾不要
                ((WCurve2D)Bds[Q]).Nodes_num[0] = Get_NodeNum(((WCurve2D)Bds[Q]).Nodes[0], Mesh, ref N);
                Q2 = ((WCurve2D)Bds[Q]).Nodes_num.Count - 1;
                ((WCurve2D)Bds[Q]).Nodes_num[Q2] = Get_NodeNum(((WCurve2D)Bds[Q]).Nodes[Q2], Mesh, ref N);
            }

            return(Geo2D_CurvesRims.Get_Rims(ref Bds, 1));
        }
コード例 #22
0
        private static void Combine_FreeNodes(ref WMesh2D_Mesh Mesh1, ref WMesh2D_Mesh Mesh2, ref WMesh2D_Mesh Mesh_Out)
        {
            QF1 = Mesh1.Q_FreeNs;
            QF2 = Mesh2.Q_FreeNs;

            Array.Resize <int>(ref Ns1, QF1 + 1);
            Array.Resize <int>(ref Ns2, QF2 + 1);
            for (int i = 0; i <= QF1; i++)
            {
                Ns1[i] = 0;
            }
            for (int i = 0; i <= QF2; i++)
            {
                Ns2[i] = 0;
            }

            for (int i = 1; i <= QF1; i++)
            {
                for (int j = 1; j <= QF2; j++)
                {
                    if (Near_Check(Mesh1.Nodes[i].X, Mesh1.Nodes[i].Y, Mesh2.Nodes[j].X, Mesh2.Nodes[j].Y, WGeos2D_Paras.E_Merge) == true)
                    {
                        Ns1[i] = j * (-1);  /////用负数表示重合节点的编号
                        Ns2[j] = i * (-1);  /////用正数表示输出时的节点编号
                        Nc++;
                    }
                }
            }

            Mesh_Out.Q_FreeNs = QF1 + QF2 - Nc;
            ///输出Mesh1的自由节点
            for (int i = 1; i <= QF1; i++)
            {
                if (Ns1[i] == 0)
                {
                    Num++;
                    Mesh_Out.Add_N(new WNode2D(Num, Mesh1.Nodes[i].X, Mesh1.Nodes[i].Y, Mesh1.Nodes[i].Trace));
                    Ns1[i] = Num;
                }
            }
            ///输出Mesh2的自由节点
            for (int i = 1; i <= QF2; i++)
            {
                if (Ns2[i] == 0)
                {
                    Num++;
                    Mesh_Out.Add_N(new WNode2D(Num, Mesh2.Nodes[i].X, Mesh2.Nodes[i].Y, Mesh2.Nodes[i].Trace));
                    Ns2[i] = Num;
                }
            }
            ///////////////////////
            ///处理重复节点
            string t = "";
            int    Trace_T;
            int    T1, T2;
            int    Nt = 0;

            for (int i = 1; i <= QF1; i++)
            {
                if (Ns1[i] < 0)
                {
                    Num++;
                    //if (Mesh2.Nodes[Ns1[i] * (-1)].Trace != 0)
                    //    Trace_T = Mesh2.Nodes[Ns1[i] * (-1)].Trace;
                    //else
                    //    Trace_T = Mesh1.Nodes[i].Trace;

                    T1 = Mesh2.Nodes[Ns1[i] * (-1)].Trace;
                    T2 = Mesh1.Nodes[i].Trace;
                    if (T1 == T2)
                    {
                        Trace_T = T1;
                    }
                    else
                    {
                        if (T1 < 0 && T2 > 0)
                        {
                            Trace_T = T1 - T2;
                        }
                        else if (T1 > 0 && T2 < 0)
                        {
                            Trace_T = T2 - T1;
                        }
                        else
                        {
                            Trace_T = T1 + T2;
                        }
                    }

                    Mesh_Out.Add_N(new WNode2D(Num, Mesh1.Nodes[i].X, Mesh1.Nodes[i].Y, Trace_T));
                    Nt = -1 * i;
                    for (int j = 1; j <= QF2; j++)
                    {
                        if (Ns2[j] == Nt)
                        {
                            Ns2[j] = Num;
                        }
                    }
                    Ns1[i] = Num;
                }
            }
        }
コード例 #23
0
        /// 绘制所有单元
        /// <summary>
        /// 绘制所有单元
        /// </summary>
        private static double[] Draw_Elements(ref WFEM_NegPara NP, ref WMesh2D_Mesh Mesh,
                                              ref double[] RES, ref double[] Res_Each,
                                              ref Graphics graphic, ref double[] DrawRate, int LableHeight)
        {
            #region 绘图工具
            Pen     RimPen  = new Pen(NP.ColorEleRim, NP.PicEleRimWidth);
            Brush[] FBrushs = new Brush[NP.Color_Contours.Length];
            for (int i = 0; i < NP.Color_Contours.Length; i++)
            {
                FBrushs[i] = new SolidBrush(NP.Color_Contours[i]);
            }
            #endregion

            #region 找出所有节点的CI
            int[] Ns_CIs = Find_Ns_CIs(ref RES, ref Res_Each);
            #endregion

            #region 临时中间变量
            ///单元节点参数
            int       K;                                            /////单元类型
            double[]  E_Rs = new double[0];                         /////每个单元每个节点的结果值
            WNode2D[] E_Ns = new WNode2D[0];                        /////每个单元的节点
            int[]     E_CIs = new int[0];                           /////每个单元每个节点的颜色编号,从0开始
            int       CI_max, CI_min;                               /////每个单元每个节点的CI最值
            Point[]   PsT = new Point[0];                           /////用于画图的临时图像点
            WNode2D[] NsT;
            WNode2D[] All_Ns  = new WNode2D[0];                     /////将每个单元的所有节点,中间节点混合放置在此
            int[]     All_CIs = new int[0];                         /////计算中间节点时使用的临时变量
            int       Q;
            double[]  Areas = new double[NP.Color_Contours.Length]; /////用于输出的每个CI的单元面积总和
            #endregion

            #region 绘制单元
            for (int i = 0; i < Mesh.Elements.Count; i++)
            {
                K = Mesh.Elements[i].Kind;
                if (K < 3)
                {
                    continue;
                }
                /////初始化四个点的位置,结果,Color_Index
                Compute_ElementParas(ref Mesh, i, ref RES, ref Ns_CIs, ref E_Rs, ref E_CIs, ref E_Ns);
                CI_max = E_CIs.Max(); CI_min = E_CIs.Min();
                /////如果各个节点;的Color_Index完全相同则直接画图
                if (CI_max == CI_min)
                {
                    PsT = Nodes_To_Points(ref E_Ns, Mesh.Xmin, Mesh.Ymin, ref DrawRate, true, NP.PicHeight - LableHeight);
                    graphic.FillPolygon(FBrushs[CI_max], PsT);
                    if (NP.ShowEleRim == true)
                    {
                        graphic.DrawPolygon(RimPen, PsT);                         /////绘制单元边界
                    }
                    Element_Area(ref E_Ns, ref Areas, CI_max, true);
                    continue;
                }

                /////四个节点Color_Index不完全相等的情况
                ///求取中间节点,并和单元节点放在一起
                All_Ns = new WNode2D[0]; All_CIs = new int[0];
                for (int j = 0; j < K; j++)
                {
                    NodesInter_Compute(ref E_Ns[j], ref E_Ns[j + 1],       /////节点
                                       E_Rs[j], E_Rs[j + 1],               /////节点上的结果数值
                                       E_CIs[j], E_CIs[j + 1], CI_max, ref Res_Each,
                                       ref All_Ns, ref All_CIs, E_CIs, E_Rs);
                }

                for (int j = CI_min; j <= CI_max; j++)
                {
                    NsT = new WNode2D[0];
                    Q   = 0;
                    for (int k = 0; k < All_Ns.Length; k++)
                    {
                        if (All_CIs[k] == j)
                        {
                            Q++; Array.Resize <WNode2D>(ref NsT, Q); NsT[Q - 1] = All_Ns[k]; continue;
                        }
                        if (All_CIs[k] == j + 1)
                        {
                            Q++; Array.Resize <WNode2D>(ref NsT, Q); NsT[Q - 1] = All_Ns[k]; continue;
                        }
                    }
                    PsT = Nodes_To_Points(ref NsT, Mesh.Xmin, Mesh.Ymin, ref DrawRate, false, NP.PicHeight - LableHeight);
                    graphic.FillPolygon(FBrushs[j], PsT);
                    if (NP.ShowEleRim == true)
                    {
                        graphic.DrawPolygon(RimPen, PsT);                         /////绘制单元边界
                    }
                    Element_Area(ref NsT, ref Areas, CI_max, false);
                }
            }
            #endregion

            return(Areas);
        }
コード例 #24
0
        /// 绘制最大值、最小值的Lable
        /// <summary>
        /// 绘制最大值、最小值的Lable
        /// </summary>
        /// <param name="NP"></param>
        /// <param name="Gf"></param>
        /// <param name="Mesh"></param>
        /// <param name="RESM"></param>
        /// <param name="NodeM"></param>
        /// <param name="DrawRate"></param>
        /// <param name="Pic_YL">渲染区域下边界Pic坐标</param>
        /// <param name="Pic_YU">渲染区域上边界Pic坐标</param>
        private static void Draw_MaxMin(ref WFEM_NegPara NP, ref Graphics Gf, WMesh2D_Mesh Mesh, double[] RESM, int[] NodeM, double[] DrawRate, int Pic_YL, int Pic_YU)
        {
            if (NP.ShowMaxMin == false)
            {
                return;
            }
            Font         font   = new Font(NP.LableFont, NP.LableTextHeight);
            Brush        brush  = new SolidBrush(Color.Black);
            StringFormat format = new StringFormat();
            ///
            int    X, Y, xt, yt;
            string t1, t2, t3, t4;

            int[] lts;
            int   lmax;

            //==========Draw Max========//
            X = (int)((Mesh.Nodes[NodeM[1]].X - Mesh.Xmin) / DrawRate[0] + DrawRate[1]);
            Y = (int)(Pic_YL - (Mesh.Nodes[NodeM[1]].Y - Mesh.Ymin) / DrawRate[0] - DrawRate[2]);
            /////
            t1     = "Max.= " + Math.Round(RESM[1], 2).ToString();
            t2     = "Node: " + NodeM[1].ToString();
            t3     = "x = " + Math.Round(Mesh.Nodes[NodeM[1]].X, 2).ToString();
            t4     = "y = " + Math.Round(Mesh.Nodes[NodeM[1]].Y, 2).ToString();
            lts    = new int[4];
            lts[0] = (int)(Gf.MeasureString(t1, font).Width);
            lts[1] = (int)(Gf.MeasureString(t2, font).Width);
            lts[2] = (int)(Gf.MeasureString(t3, font).Width);
            lts[3] = (int)(Gf.MeasureString(t4, font).Width);
            lmax   = lts.Max();
            if (Y < (Pic_YL - Pic_YU) / 2)
            {
                yt = Y - NP.LableTextHeight / 2;
                if (X < NP.PicWidth / 2)
                {
                    xt = X + NP.LableTextHeight / 2;                      ///第二象限
                }
                else
                {
                    xt = X - lmax - NP.LableTextHeight / 2;                  ///第一象限
                }
            }
            else
            {
                yt = Y - (int)(NP.LableTextHeight * 5.5);
                if (X < NP.PicWidth / 2)
                {
                    xt = X + NP.LableTextHeight / 2;                      ///第三象限
                }
                else
                {
                    xt = X - lmax - NP.LableTextHeight / 2;                  ///第四象限
                }
            }
            ///
            Gf.DrawString(t1, font, brush, new PointF(xt, yt));
            if (NP.ShowMaxMinNode == true)
            {
                yt = yt + (int)(1.5 * NP.LableTextHeight);
                Gf.DrawString(t2, font, brush, new PointF(xt, yt));
                yt = yt + (int)(1.5 * NP.LableTextHeight);
                Gf.DrawString(t3, font, brush, new PointF(xt, yt));
                yt = yt + (int)(1.5 * NP.LableTextHeight);
                Gf.DrawString(t4, font, brush, new PointF(xt, yt));
            }

            xt = X - NP.LableTextHeight / 4;
            yt = Y - NP.LableTextHeight / 4;
            Gf.FillEllipse(brush, new Rectangle(xt, yt, NP.LableTextHeight / 2, NP.LableTextHeight / 2));

            //==========Draw Min========//
            t1     = "Min.= " + Math.Round(RESM[0], 2).ToString();
            t2     = "Node: " + NodeM[0].ToString();
            t3     = "x = " + Math.Round(Mesh.Nodes[NodeM[0]].X, 2).ToString();
            t4     = "y = " + Math.Round(Mesh.Nodes[NodeM[0]].Y, 2).ToString();
            lts[0] = (int)(Gf.MeasureString(t1, font).Width);
            lts[1] = (int)(Gf.MeasureString(t2, font).Width);
            lts[2] = (int)(Gf.MeasureString(t3, font).Width);
            lts[3] = (int)(Gf.MeasureString(t4, font).Width);
            lmax   = lts.Max();
            ///
            X = (int)((Mesh.Nodes[NodeM[0]].X - Mesh.Xmin) / DrawRate[0] + DrawRate[1]);
            Y = (int)(Pic_YL - (Mesh.Nodes[NodeM[0]].Y - Mesh.Ymin) / DrawRate[0] - DrawRate[2]);
            if (Y < (Pic_YL - Pic_YU) / 2)
            {
                yt = Y - NP.LableTextHeight / 2;                          ///第二象限
                if (X < NP.PicWidth / 2)
                {
                    xt = X + NP.LableTextHeight / 2;                      ///第一象限
                }
                else
                {
                    xt = X - lmax - NP.LableTextHeight / 2;
                }
            }
            else
            {
                yt = Y - (int)(NP.LableTextHeight * 5.5);                 ///第三象限
                if (X < NP.PicWidth / 2)
                {
                    xt = X + NP.LableTextHeight / 2;                      ///第四象限
                }
                else
                {
                    xt = X - lmax - NP.LableTextHeight / 2;
                }
            }
            ///
            Gf.DrawString(t1, font, brush, new PointF(xt, yt));
            if (NP.ShowMaxMinNode == true)
            {
                yt = yt + (int)(1.5 * NP.LableTextHeight);
                Gf.DrawString(t2, font, brush, new PointF(xt, yt));
                yt = yt + (int)(1.5 * NP.LableTextHeight);
                Gf.DrawString(t3, font, brush, new PointF(xt, yt));
                yt = yt + (int)(1.5 * NP.LableTextHeight);
                Gf.DrawString(t4, font, brush, new PointF(xt, yt));
            }

            xt = X - NP.LableTextHeight / 4;
            yt = Y - NP.LableTextHeight / 4;
            Gf.FillEllipse(brush, new Rectangle(xt, yt, NP.LableTextHeight / 2, NP.LableTextHeight / 2));
        }
コード例 #25
0
ファイル: Mesh_Glass.cs プロジェクト: wuxiaod1987/WCAE
        /// <summary>
        /// 生成夹丝区域的节点,单元,输出,绘制等
        /// </summary>
        /// <param name="AxisX">横向轴线</param>
        /// <param name="WBs">夹丝线</param>
        /// <param name="Ws">夹丝区域的上下边界线</param>
        /// <remarks></remarks>
        private static WMesh2D_Mesh Mesh_SingleRim(ref WLine2D AxisX,
                                                   ref WEntity2D[] WBs, ref WEntity2D[] Ws,
                                                   ref GLCommon GLC)
        {
            WMesh2D_Mesh Glass_Mesh = new WMesh2D_Mesh("Wires");

            Glass_Mesh.Shapes.Add(new WShapeRim2D(Color.Black, 1f));
            /////
            int N  = 0;                                            /////节点编号
            int E4 = 0;                                            /////Shell单元编号
            int E2 = 0;                                            /////Beam单元编号

            WEntity2D[] WBs_V = Sort_WBs(AxisX, ref WBs, ref GLC); /////找到竖向边界排序输出,并在边界线数组中去除竖向边界线
            if (WBs_V.Length == 0)
            {
                return(null);
            }
            WCurve2D Bd_L = (WCurve2D)WBs_V[0];                     /////左侧边界
            WCurve2D Bd_R = (WCurve2D)WBs_V[1];                     /////右侧边界

            WCurve2D[] Bds_O = new WCurve2D[WBs.Length];            /////上下边界线
            for (int i = 0; i < WBs.Length; i++)
            {
                Bds_O[i] = (WCurve2D)WBs[i];
            }

            ///////先求出上下边界
            List <WPoint2D> Ps_WiL = new List <WPoint2D>();           /////记录所有线与上边界的交点,从左至右
            List <WPoint2D> Ps_WiU = new List <WPoint2D>();           /////记录所有线与下边界的交点,从左至右
            List <WPoint2D> Pts;                                      /////辅助点集

            for (int i = 0; i <= Ws.Length - 1; i++)
            {
                Pts = Geos2D_Intersection.Intersection_L2Cvs((WLine2D)Ws[i], ref WBs); /////找与上下边线的交点作为划分的边界
                if (Pts.Count == 0)
                {
                    continue;                        /////夹丝线与上下边界不一定会有交点
                }
                Add_Ps2_Bnds(ref Pts, ref Bds_O);

                Geos2D_Other.Merge_Points(ref Pts);  /////去掉多余节点
                if (Pts[0].Y > Pts[1].Y)
                {
                    Ps_WiU.Add(Pts[0]);
                    Ps_WiL.Add(Pts[1]);
                }
                else
                {
                    Ps_WiU.Add(Pts[1]);
                    Ps_WiL.Add(Pts[0]);
                }
            }

            ///////对上下左右边界进行网格划分//////
            Bd_L.Nodes = Geos2D_Modify.DotCurve_Times(Bd_L, GLC.Mesh_WireTimes); /////左边界划分
            Bd_R.Nodes = Geos2D_Modify.DotCurve_Times(Bd_R, GLC.Mesh_WireTimes); /////右边界划分
            WMFuncs2D.Ps_Sort(Bd_L.Nodes, false, true);                          /////从下到上排列左边界节点
            WMFuncs2D.Ps_Sort(Bd_R.Nodes, false, true);                          /////从下到上排列右边界节点

            //////Shell//////
            List <int> Ns_WiL = new List <int>();                                //////记录所有线与上边界的交点的节点编号(Shell),从左至右
            List <int> Ns_WiU = new List <int>();                                //////记录所有线与下边界的交点的节点编号(Shell),从左至右

            N = WMFuncs2D.NsID_App(ref Bd_L.Nodes, ref Bd_L.Nodes_num, N);       //////将左边界的节点进行划分并输入Bnd中(Shell)
            N = WMFuncs2D.NsID_App(ref Ps_WiU, ref Ns_WiU, N);                   //////将上边界的节点进行划分(Shell)
            N = WMFuncs2D.NsID_App(ref Bd_R.Nodes, ref Bd_R.Nodes_num, N, true); //////将右边界的节点进行划分并输入Bnd中(Shell),注意需要反向
            N = WMFuncs2D.NsID_App(ref Ps_WiL, ref Ns_WiL, N, true);             //////将下边界的节点进行划分,注意需要反向(Shell)

            //Add_HT2_Bnds(ref Bd_L.Nodes, ref Bds_O);                           //////将左边界头尾节点加入上下边界中(为了节点顺序对,右边界在最后输入)

            //////输出
            Glass_Mesh.Q_FreeNs = Bd_L.Nodes.Count * 2 + Ns_WiL.Count * 2;             /////自由节点数量输出(Shell)
            Glass_Mesh.Add_Ns(ref Bd_L.Nodes, ref Bd_L.Nodes_num, false, 0);           /////输出左边界的节点至Shell节点文件中
            Glass_Mesh.Add_Ns(ref Ps_WiU, ref Ns_WiU, false, 0);                       /////输出上边界的节点至Shell节点文件中
            Glass_Mesh.Add_Ns(ref Bd_R.Nodes, ref Bd_R.Nodes_num, true, 0);            /////输出右边界的节点至Shell节点文件中,注意反向
            Glass_Mesh.Add_Ns(ref Ps_WiL, ref Ns_WiL, true, 0);                        /////输出下边界的节点至Shell节点文件中,注意反向
            /////将边界点放到Shape中
            Glass_Mesh.Shapes[0].Add_Ps(ref Bd_L.Nodes, ref Bd_L.Nodes_num, false, 0); /////输出左边界的节点至Shell节点文件中
            Glass_Mesh.Shapes[0].Add_Ps(ref Ps_WiU, ref Ns_WiU, false, 0);             /////输出上边界的节点至Shell节点文件中
            Glass_Mesh.Shapes[0].Add_Ps(ref Bd_R.Nodes, ref Bd_R.Nodes_num, true, 0);  /////输出右边界的节点至Shell节点文件中,注意反向
            Glass_Mesh.Shapes[0].Add_Ps(ref Ps_WiL, ref Ns_WiL, true, 0);              /////输出下边界的节点至Shell节点文件中,注意反向

            /////对夹丝线进行网格划分//////
            List <WPoint2D> Ps1 = Bd_L.Nodes;
            List <WPoint2D> Ps2 = new List <WPoint2D>();
            List <int>      Ns1 = Bd_L.Nodes_num;
            List <int>      Ns2 = new List <int>();

            WElement2D[] Es = new WElement2D[0];

            for (int i = 0; i <= Ws.Length - 1; i++)
            {
                Ps2 = Geos2D_Modify.DotCurve_Times(Ws[i], Ps_WiU[i], Ps_WiL[i], GLC.Mesh_WireTimes, ref GLC.WGC); /////划分夹丝线
                WMFuncs2D.Ps_Sort(Ps2, false, true);                                                              /////从下到上排列节点
                //Add_HT2_Bnds(ref Ps2, ref Bds_O);                               /////将头尾节点加入上下边界中
                //////Shell//////
                N                  = WMFuncs2D.NsID_App(ref Ps2, ref Ns2, false, N);    /////生成Shell单元的节点编号(注意头尾不要)
                Ns2[0]             = Ns_WiL[i];                                         /////为生成单元,用下边界节点替换最下点编号
                Ns2[Ns2.Count - 1] = Ns_WiU[i];                                         /////为生成单元,用上边界节点替换最上点编号
                E4                 = WMFuncs2D.E4sID_App(ref Ns1, ref Ns2, ref Es, E4); /////生成Shell单元
                Glass_Mesh.AddCross_NodesPair(ref Ns1, ref Ns2);                        /////将节点之间架桥,用于显示
                /////输出
                Glass_Mesh.Add_Ns(ref Ps2, ref Ns2, true, false);                       /////将Shell的中间节点输出至文件(注意头尾不要)
                Glass_Mesh.Add_Es(ref Es);                                              /////输出Shell单元

                E2 = WMFuncs2D.E2sID_App(ref Ns2, ref Es, E2, true);                    /////Beam单元生成
                Glass_Mesh.Add_Es(ref Es);                                              /////Beam单元输出

                //////循环推进//////
                Ps1 = Ps2;
                Ns1 = Ns2;
            }

            ///////最右侧单元处理//////
            Ps2 = Bd_R.Nodes;
            Ns2 = Bd_R.Nodes_num;
            //Add_HT2_Bnds(ref Bd_R.Nodes, ref  Bds_O);                           /////将右侧边界头尾节点加入上下边界中
            E4 = WMFuncs2D.E4sID_App(ref Ns1, ref Ns2, ref Es, E4);               /////输入单元编号
            Glass_Mesh.AddCross_NodesPair(ref Ns1, ref Ns2);                      /////将节点之间架桥,用于显示
            Glass_Mesh.Add_Es(ref Es);
            return(Glass_Mesh);
        }