示例#1
0
        private static WMesh2D_Mesh Mesh_FreeRim2(ref WEntity2D[] WBs, ref WEntity2D[] Ws, ref GLCommon GLC, string Name)
        {
            /////找到基础线
            WEntity2D Bas = WBs[0];

            for (int i = 0; i < WBs.Length; i++)
            {
                if (((WCurve2D)WBs[i]).Meshed_Check == true)
                {
                    Bas = WBs[i];
                    break;
                }
            }
            //////找到与Bas相交的夹丝线
            WEntity2D[] Wsc = new WEntity2D[0];
            for (int i = 0; i < Ws.Length; i++)
            {
                if (Geos2D_Intersection.Intersection_L2C((WLine2D)Ws[i], Bas).Count > 0)
                {
                    Array.Resize <WEntity2D>(ref Wsc, Wsc.Length + 1);
                    Wsc[Wsc.Length - 1] = Ws[i];
                }
            }
            /////

            return(null);
        }
示例#2
0
 private static List <WPoint2D> Intersection_Cv2Cvs(WEntity2D C, ref WEntity2D[] Cs)
 {
     if (C.Kind == GeoKind.Line)
     {
         return(Intersection_L2Cvs((WLine2D)C, ref Cs));
     }
     return(new List <WPoint2D>());
 }
示例#3
0
 public static WPoint2D ClosestPoint_P2C(WPoint2D P, WEntity2D C, bool Extent)
 {
     if (C.Kind == GeoKind.Line)
     {
         return(ClosestPoint_P2L(P, (WLine2D)C, Extent));
     }
     return(ClosestPoint_P2PL(P, (WPolyLine2D)C, Extent));
 }
示例#4
0
        /// 对夹丝边界线进行排序,从左至右输出竖向线
        private static WEntity2D[] Sort_WBs(WLine2D AxisX, ref WEntity2D[] WBs, ref GLCommon GLC)
        {
            int Quan = WBs.Length;

            WPoint2D[]      Ps = new WPoint2D[0]; /////夹丝边界线与横轴的交点点集
            List <WPoint2D> Pst;
            WPoint2D        P;

            int[] Ns = new int[0];
            int   N  = 0;

            for (int i = 0; i < Quan; i++)
            {
                Pst = Geos2D_Intersection.Intersection_L2C(AxisX, WBs[i]);
                if (Pst.Count == 0)
                {
                    continue;
                }
                P = Pst[0];
                Array.Resize <WPoint2D>(ref Ps, N + 1);
                Array.Resize <int>(ref Ns, N + 1);
                Ps[N] = P;
                Ns[N] = i;
                N++;
            }

            ///////得到竖向线并排序输出
            int[]       Sort = WMFuncs2D.Ps_Sort(ref Ps, true, true);
            WEntity2D[] Out  = new WEntity2D[N];
            for (int i = 0; i < N; i++)
            {
                Out[i] = WBs[Ns[Sort[i]]];
            }

            ///////去除竖向线
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < WBs.Length; j++)
                {
                    if (Ns[i] == j)
                    {
                        for (int k = j; k < WBs.Length - 1; k++)
                        {
                            WBs[k] = WBs[k + 1];
                        }
                        Array.Resize <WEntity2D>(ref WBs, WBs.Length - 1);

                        for (int k = i + 1; k < N; k++)
                        {
                            Ns[k] = Ns[k] - 1;
                        }
                        break;
                    }
                }
            }
            return(Out);
        }
示例#5
0
        /// 增加几何实例
        /// <summary>
        /// 增加几何实例
        /// </summary>
        public void Add_Geo(WEntity2D E)
        {
            int N;

            if (this.Entities.Count == 0)
            {
                N = 0;
            }
            else
            {
                N = this.Entities[this.Entities.Count - 1].ID + 1;
            }
            E.ID = N;
            if (Layers.Contains(E.Layer) == false)
            {
                Layers.Add(E.Layer);
            }
            Entities.Add(E);

            switch (E.Kind)
            {
            case GeoKind.Line:
                WLine2D L = (WLine2D)E;
                Bounds.Update(L.StartPoint.X, L.StartPoint.Y);
                Bounds.Update(L.EndPoint.X, L.EndPoint.Y);
                break;

            case GeoKind.PolyLine:
                WPolyLine2D P = (WPolyLine2D)E;
                for (int i = 0; i < P.Count; i++)
                {
                    Bounds.Update(P[i].X, P[i].Y);
                }
                break;

            case GeoKind.Spline:
                break;

            case GeoKind.Arc:
                break;

            case GeoKind.Circle:
                WCircle2D C = (WCircle2D)E;
                Bounds.Update(C.Center.X - C.R, C.Center.Y - C.R);
                Bounds.Update(C.Center.X + C.R, C.Center.Y + C.R);
                Bounds.Update(C.Center.X - C.R, C.Center.Y + C.R);
                Bounds.Update(C.Center.X + C.R, C.Center.Y - C.R);
                break;

            default:
                break;
            }
        }
示例#6
0
 /// 根据图层和颜色选择
 public static WEntity2D[] SelectLines(string layername, Color color, ref WGeometry2D WGC)
 {
     WEntity2D[] Out = new WEntity2D[0];
     for (int i = 0; i < WGC.Entities.Count; i++)
     {
         if (WGC.Entities[i].Layer == layername && WGC.Entities[i].Color.R == color.R && WGC.Entities[i].Color.G == color.G && WGC.Entities[i].Color.B == color.B)
         {
             Array.Resize <WEntity2D>(ref Out, Out.Length + 1);
             Out[Out.Length - 1] = WGC.Entities[i];
         }
     }
     return(Out);
 }
示例#7
0
 public static double ClosestDistance_P2C(WEntity2D E, WPoint2D P, bool Extent)
 {
     if (E.Kind == GeoKind.Line)
     {
         WLine2D L = (WLine2D)E;
         return(ClosestDistance_P2L(L.StartPoint, L.EndPoint, P, Extent));
     }
     else
     {
         WPolyLine2D PL = (WPolyLine2D)E;
         return(ClosestDistance_P2PL(P, PL, Extent));
     }
 }
示例#8
0
        public static void Combine_Curves(WEntity2D Co, WEntity2D Ct)
        {
            WCurve2D C1    = (WCurve2D)Co;
            WCurve2D C2    = (WCurve2D)Ct;
            int      check = -1;

            /////起点相连
            if ((C1.StartPoint.X - C2.StartPoint.X) < WGeos2D_Paras.E_Merge &&
                (C1.StartPoint.Y - C2.StartPoint.Y) < WGeos2D_Paras.E_Merge)
            {
                check = 1;
            }
        }
示例#9
0
 public static List <WPoint2D> DotCurve_Times(WEntity2D C, WPoint2D P1, WPoint2D P2, int Times, ref WGeometry2D WGC)
 {
     if (Times == 0 || Times == 1)
     {
         List <WPoint2D> Out = new List <WPoint2D>();
         Out.Add(((WCurve2D)C).StartPoint);
         Out.Add(((WCurve2D)C).EndPoint);
         return(Out);
     }
     if (C.Kind == GeoKind.Line)
     {
         return(Dotline_Times((WLine2D)C, P1, P2, Times));
     }
     return(DotPolyline_Times((WPolyLine2D)C, P1, P2, Times, ref WGC));
 }
示例#10
0
        public static List <WPoint2D> ClosestPoint_Ps2Cs(WEntity2D C, ref List <WPoint2D> Ps)
        {
            List <WPoint2D> Pso = new List <WPoint2D>();
            WPoint2D        P;

            for (int i = 0; i < Ps.Count; i++)
            {
                P = ClosestPoint_P2C(Ps[i], C, true);
                if (P == null)
                {
                    continue;
                }
                Pso.Add((WPoint2D)P);
            }
            return(Pso);
        }
示例#11
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);
        }
示例#12
0
        /// 对夹丝线进行排序,从左至右输出
        private static WEntity2D[] Sort_Wires(WLine2D AxisX, ref WEntity2D[] Wires, ref GLCommon GLC)
        {
            List <WPoint2D> Ps_Wires = Geos2D_Intersection.Intersection_L2Cvs(AxisX, ref Wires);  ///////得到交点

            int Quan = Wires.Length;

            int[] PNums = new int[Quan];   /////用于记录排列顺序
            for (int i = 0; i < Quan; i++)
            {
                PNums[i] = i;
            }
            int      Nt;
            WPoint2D Pt;     /////排列点

            for (int i = 0; i <= Quan - 2; i++)
            {
                for (int j = i + 1; j <= Quan - 1; j++)
                {
                    if (Ps_Wires[i].X > Ps_Wires[j].X)
                    {
                        Nt       = PNums[i];
                        PNums[i] = PNums[j];
                        PNums[j] = Nt;

                        Pt          = Ps_Wires[i];
                        Ps_Wires[i] = Ps_Wires[j];
                        Ps_Wires[j] = Pt;
                    }
                }
            }

            WEntity2D[] ID_Wires_Sorted = new WEntity2D[Quan];   /////按顺序记录排列后的线

            int N;

            for (int i = 0; i <= Quan - 1; i++)
            {
                N = PNums[i];
                ID_Wires_Sorted[i] = Wires[N];
            }

            Ps_Wires = null;
            return(ID_Wires_Sorted);
        }
示例#13
0
        /// <summary>
        /// PolyLine和Line数组之间的交点
        /// </summary>
        public static List <WPoint2D> Intersection_Cv2Ls(WEntity2D C, ref WEntity2D[] Ls)
        {
            List <WPoint2D> Ps  = new List <WPoint2D>();
            List <WPoint2D> Pts = new List <WPoint2D>();

            for (int i = 0; i < Ls.Length; i++)
            {
                Pts = Intersection_L2C((WLine2D)Ls[i], C);
                if (Pts == null || Pts.Count == 0)
                {
                    continue;
                }
                for (int j = 0; j < Pts.Count; j++)
                {
                    Ps.Add(Pts[j]);
                }
            }
            return(Ps);
        }
示例#14
0
        public static List <WPoint2D> Intersection_L2C(WLine2D L, WEntity2D C)
        {
            List <WPoint2D> Ps = new List <WPoint2D>();
            WPoint2D        P;

            if (C.Kind == GeoKind.Line)
            {
                P = Intersection_L2L((WLine2D)C, L);
                if (P != null)
                {
                    Ps.Add((WPoint2D)P);
                }
                return(Ps);
            }
            if (C.Kind == GeoKind.PolyLine)
            {
                return(Intersection_L2Pl((WPolyLine2D)C, L));
            }
            return(Ps);
        }
示例#15
0
        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;
        }
示例#16
0
        private void RenderSingleEntity(ScreenTrans zoom, WEntity2D E, bool SnapCheck)
        {
            switch (E.Kind)
            {
            case GeoKind.Line:
                RenderLines(zoom, (WLine2D)E, SnapCheck);
                break;

            case GeoKind.PolyLine:
                RenderPolyLines(zoom, (WPolyLine2D)E, SnapCheck);
                break;

            case GeoKind.Circle:
                RenderCircles(zoom, (WCircle2D)E, SnapCheck);
                break;

            case GeoKind.DText:
                RenderText(zoom, (WText2D)E);
                break;

            default:
                break;
            }
        }
示例#17
0
        /// <summary>
        /// 根据小段长度划分
        /// </summary>
        /// <param name="C">待划分曲线</param>
        /// <param name="Length">每一段的长度</param>
        /// <returns></returns>
        public static List <WPoint2D> DotCurve_Times(WEntity2D C, double Length)
        {
            int Time = (int)Math.Ceiling(((WCurve2D)C).Length / Length);

            return(DotCurve_Times(C, Time));
        }
示例#18
0
 /// 删除几何体
 /// <summary>
 /// 删除几何体
 /// </summary>
 /// <param name="E"></param>
 public void Del_Geo(WEntity2D E)
 {
     this.Entities.Remove(E);
 }
示例#19
0
        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);
        }