/// <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); }
/// <summary> /// 从一个Poly文件,Mesh后形成mesh文件 /// </summary> /// <param name="Name">poly文件的完整文件名</param> /// <param name="MP"></param> /// <returns></returns> public static bool Triangle_Mesh(string Name, ref WMesh2D_Para MP) { 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(false); } 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); Mesh_Output(MP.Path, Name, ref Ns, ref Es, MP.QN_Ini); File.Delete(MP.Path + Name + ".poly"); File.Delete(MP.Path + Name + "_.poly"); return(true); }