/// 将计算出夹丝线与边界线的交点加入边界线的节点中 private static void Add_Ps2_Bnds(ref List <WPoint2D> Pts, ref WCurve2D[] Bds_O) { for (int j = 0; j < Pts.Count; j++) { Bds_O[Pts[j].CheckNum].Nodes.Add(new WPoint2D(Pts[j].X, Pts[j].Y, 0)); for (int k = 0; k < Bds_O.Length; k++) { if (Bds_O[k].Meshed_Check == true) { continue; } if (k == Pts[j].CheckNum) { continue; } if (Geos2D_Other.Check_PsMerge(Pts[j], Bds_O[k].StartPoint) == true) { Bds_O[k].Nodes.Add(new WPoint2D(Pts[j].X, Pts[j].Y, 0)); } if (Geos2D_Other.Check_PsMerge(Pts[j], Bds_O[k].EndPoint) == true) { Bds_O[k].Nodes.Add(new WPoint2D(Pts[j].X, Pts[j].Y, 0)); } } Pts[j] = new WPoint2D(Pts[j].X, Pts[j].Y, 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]); } } }
/// 返回值为新的自由节点数量,用于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); }
/// 找到某点所在的Bnd的编号 private static List <int> Bnd_Find(WPoint2D P, ref WCurve2D[] Bnds) { List <int> Out = new List <int>(); double Dt; for (int i = 0; i < Bnds.Length; i++) { Dt = Geos2D_Other.ClosestDistance_P2C(Bnds[i], P, true); if (Dt < WGeos2D_Paras.E_Merge) { Out.Add(i); } } return(Out); }
public WRim2D(ref WEntity2D[] Cs, List <int> Rim) { this.Meshed = false; this.Nums = Rim; this.Trace = 0; this.Smaller = new List <int>(); this.Curves = new WEntity2D[Rim.Count]; this.Shape = new List <WPoint2D>(); this.Layer = "Rims"; this.Color = Color.AliceBlue; this.Color_Shape = Color.Black; this.Kind = GeoKind.Rim; Initial_Bound(); /// WCurve2D C; WPoint2D P0 = new WPoint2D(); WPoint2D P1 = new WPoint2D(); WPoint2D P2 = new WPoint2D(); for (int i = 0; i < Rim.Count; i++) { this.Curves[i] = Cs[Rim[i]]; C = (WCurve2D)Cs[Rim[i]]; Update_Bound(C.Xmax, C.Ymax); Update_Bound(C.Xmin, C.Ymin); /////形成边界 if (i == 0) { P1 = ((WCurve2D)(Cs[Rim[Rim.Count - 1]])).StartPoint; P2 = ((WCurve2D)(Cs[Rim[Rim.Count - 1]])).EndPoint; if (Geos2D_Other.Check_PsMerge(P1, C.StartPoint) == true || Geos2D_Other.Check_PsMerge(P2, C.StartPoint) == true) { P0 = C.StartPoint; } if (Geos2D_Other.Check_PsMerge(P1, C.EndPoint) == true || Geos2D_Other.Check_PsMerge(P2, C.EndPoint) == true) { P0 = C.EndPoint; } } P0 = Add_Curve2Shape(C, P0); } }
public void Merge_Duplicate() { Geos2D_Other.Merge_Points(ref Rim); /////去掉多余节点 }
/// <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); }
/// 找到所有的边界线及所有的区域 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)); }