public bool Equal_to_me(LINE l0) { return(true); }
private void Insert(LINE l0) { util u1 = new util(); pg.ToString(); /*获取线链的头边和尾边的外端点*/ PO PLa, PFa; if (pkey == l0.p1) { PLa = l0.p2; } else { PLa = l0.p1; } if (pkey == pre_l.Head.Data.p1) { PFa = pre_l.Head.Data.p2; } else { PFa = pre_l.Head.Data.p1; } //PFa.ToString(); // pg.ToString(); if (u1.IsXl(pg, PLa, PFa, pkey)) { //pg是当前边首边的外端点 AddLine(PFa, PLa, pkey); Set_direction(pre_l.Head.Data, PLa); Set_direction(l0, pkey); } else { if (pg.selected) { //如果pg已经被选过 #region pg==PFa; LINE lt;//获取相应边 if (pg == PFa) { lt = Is_OutSide(PLa, PFa); lt = Is_OutSide(PLa, pg); if (lt != null) { //如果PFa-PLa已存在 u1.InFile(u1.infopath, "PFa-PLa existed"); Set_direction(pre_l.Head.Data, PLa); Set_direction(pre_l.Last.Data, PFa); Set_direction(lt, pkey); return; } else { // u1.InFile(u1.infopath, "PFa==pg"); AddLine(PFa, PLa, pkey); Set_direction(pre_l.Head.Data, PLa); Set_direction(l0, pkey); return; } } #endregion pg=PFa #region last'soutside //如果pg是last的边链的外端点 lt = Is_OutSide(PLa, pg); if (lt != null) { //u1.InFile(u1.infopath, "last's outside"); AddLine(pkey, pg, PLa); Set_direction(lt, pkey); Set_direction(pre_l.Last.Data, pg); if (PLa.p_parent != null) //如果当前点是影子点,调整边链 { //u1.InFile(u1.infopath, "in shadow"); shadowpo(PLa, pkey, PLa.p_parent, pg); } return; } #endregion last'soutside #region first'soutside //如果pg是first的边链的外端点 lt = Is_OutSide(PFa, pg); if (lt != null) { LINE lt2 = AddLine(pkey, pg, PLa); AddLine(PLa, pg, pkey); Set_direction(lt, pkey); Set_direction(pre_l.Head.Data, pg); Set_direction(lt2, PFa); Set_direction(pre_l.Last.Data, pg); return; } #endregion first'soutside #region arbitrary location //如果pg是非特殊位置 PO pt = new PO(pg.x, pg.y, pg.z); pt.p_parent = pg; pg = pt; //u1.InFile(u1.infopath, "here1"); AddLine(pkey, pg, PLa); // u1.InFile(u1.infopath, "here2"); AddLine(PLa, pg, pkey); //u1.InFile(u1.infopath, "here3"); Set_direction(l0, pg); // u1.InFile(u1.infopath, "here4"); work_pl.Insert(pg); //u1.InFile(u1.infopath,"here5"); pg.selected = true; #endregion } else { //pg作为普通点处理 AddLine(pkey, pg, PLa); AddLine(PLa, pg, pkey); Set_direction(l0, pg); work_pl.Insert(pg); //work_pl.Dispaly(); pg.selected = true; } } }
public void GetLL(LINE l0) { ll.Insert(l0); return; }
private void Shadow_Delete(LINE lpa, PO lpa_pk, LINE lshadow, PO ls_pk) { /* * 将影子点的边转移到父点中去 * shap是影子点,shapflag是影子点的标记点 * pap是父点,papflag是父点的标记点 */ util u1 = new util(); if (lpa.sl.Head.Data.Belongme(lpa_pk)) {//如果标记点在父点的首边上 if (lshadow.sl.Head.Data.Belongme(ls_pk)) { info.Insert("case1"); #region case1 Node <SURFACE> sn = lshadow.sl.Head; while (sn != null) { //用父点换掉边中的影子点 lpa.sl.Head_Insert(sn.Data); sn = sn.Next; } #endregion case1 } else { info.Insert("case2"); #region case2 LinkList <SURFACE> st = new LinkList <SURFACE>(); Node <SURFACE> sn = lshadow.sl.Head; while (sn != null)//将shap的线链反序 { st.Head_Insert(sn.Data); sn = sn.Next; } sn = st.Head; while (sn != null) { lpa.sl.Head_Insert(sn.Data); sn = sn.Next; } #endregion case2 } } else {//如果标记点在父点的尾边上 if (lshadow.sl.Head.Data.Belongme(ls_pk)) { info.Insert("case3"); #region case3 Node <SURFACE> sn = lshadow.sl.Head; while (sn != null) { //用父点换掉边中的影子点 lpa.sl.Insert(sn.Data); sn = sn.Next; } #endregion } else { info.Insert("case4"); #region case4 LinkList <SURFACE> st = new LinkList <SURFACE>(); Node <SURFACE> sn = lshadow.sl.Head; while (sn != null)//将shap的线链反序 { st.Head_Insert(sn.Data); sn = sn.Next; } sn = st.Head; while (sn != null) { lpa.sl.Insert(sn.Data); sn = sn.Next; } #endregion } } lpa.p1.ll.Delete(lshadow); lpa.p2.ll.Delete(lshadow); sn_current = lpa.sl.Last; }
private void Insert(LINE lk) { /* * lk:某个正在被操作的边,本函数的目的是将某个生成面加到与该 * 边以工作面相连的边的面链合适的位置 */ util u1 = new util(); SURFACE Last_s, First_s;//保存l0面链尾上的面对象; Last_s = lk.sl.Last.Data; First_s = lk.sl.Head.Data; PO pi, pj, pd, pfd;//当前所处理的面的三个顶点 pi = lk.p1; pj = lk.p2; pd = Last_s.GetPd(lk); //获取面slast上除边l0外的剩余的点 pfd = lk.sl.Head.Data.GetPd(lk); //获取面链上首面除边l0外的剩余的点 LINE lk1, lk2; //取l0面链尾面除lk外的其他两条边 lk1 = Last_s.GetLine(pi, pd); lk2 = Last_s.GetLine(pj, pd); LINE l1, l2, l3; //新生成的三条边 SURFACE s, s1, s2; //新生成的三个面 if (!u1.noSearched(First_s, pg) && u1.noSearched(First_s, pd)) { pg = pfd; } if (pg.selected) { int State; State = Stateofsurface(Last_s, pg); if (State == 1 || State == 0) { info.Insert("pg与Last_s的一个定点或零个顶点共边"); #region pg与Last_s的一个定点或零个顶点共边 l1 = Get_LINE_From_One_Po(pi, pg); l2 = Get_LINE_From_One_Po(pd, pg); l3 = Get_LINE_From_One_Po(pj, pg); //生成的三条边l1,l2,l3,加入工作链中 Set_direction(Last_s, pg); s = New_SURFACE(pi, pj, pg); s.l1 = l1; s.l2 = l3; s.l3 = lk; PAINT.GetSL(s); Set_direction(s, pd); s1 = New_SURFACE(pi, pd, pg); s1.l1 = l1; s1.l2 = lk1; s1.l3 = l2; PAINT.GetSL(s1); Set_direction(s1, pj); s2 = New_SURFACE(pg, pj, pd); s2.l1 = l2; s2.l2 = l3; s2.l3 = lk2; PAINT.GetSL(s2); Set_direction(s2, pi); //将生成的面加到边的面链中 AddSurface(s, lk, Last_s); AddSurface(s, l1, Last_s);//将面加到l1的面链中去 AddSurface(s, l3, Last_s); AddSurface(s1, l1, Last_s); AddSurface(s1, lk1, Last_s); AddSurface(s1, l2, Last_s); AddSurface(s2, l3, Last_s); AddSurface(s2, lk2, Last_s); AddSurface(s2, l2, Last_s); #endregion sn_current = sn_current.Next; } else { info.Insert("pg与Last_s的两个顶点或三个顶点共边"); LINE l_shadow = Get_LINE_From_One_Po(lk, pg); if (l_shadow != null && !First_s.Belongme(pg)) { if (u1.Direct(l_shadow.sl.Head.Data, pg) * u1.Direct(l_shadow.sl.Head.Data, pd) < 0) { pg = l_shadow.sl.Head.Data.GetPd(lk); } if (u1.Direct(l_shadow.sl.Last.Data, pg) * u1.Direct(l_shadow.sl.Last.Data, pd) < 0) { pg = l_shadow.sl.Last.Data.GetPd(lk); } #region pg与Last_s的两个顶点或三个顶点共边 l1 = New_LINE(pi, pg); l2 = New_LINE(pd, pg); l3 = New_LINE(pj, pg); Set_direction(Last_s, pg); s = New_SURFACE(lk, pg); s.l1 = l1; s.l2 = l3; s.l3 = lk; Set_direction(s, pd); s1 = New_SURFACE(lk1, pg); s1.l1 = l1; s1.l2 = lk1; s1.l3 = l2; Set_direction(s1, pj); s2 = New_SURFACE(lk2, pg); s2.l1 = l2; s2.l2 = l3; s2.l3 = lk2; Set_direction(s2, pi); //将生成的面加到边的面链中 AddSurface(s, lk, Last_s); AddSurface(s, l1, Last_s);//将面加到l1的面链中去 AddSurface(s, l3, Last_s); AddSurface(s1, l1, Last_s); AddSurface(s1, lk1, Last_s); AddSurface(s1, l2, Last_s); AddSurface(s2, l3, Last_s); AddSurface(s2, lk2, Last_s); AddSurface(s2, l2, Last_s); #endregion Shadow_Delete(lk, pd, l_shadow, pg); } else { #region pg与Last_s的两个顶点或三个顶点共边 l1 = New_LINE(pi, pg); l2 = New_LINE(pd, pg); l3 = New_LINE(pj, pg); Set_direction(Last_s, pg); s = New_SURFACE(lk, pg); s.l1 = l1; s.l2 = l3; s.l3 = lk; Set_direction(s, pd); s1 = New_SURFACE(lk1, pg); s1.l1 = l1; s1.l2 = lk1; s1.l3 = l2; Set_direction(s1, pj); s2 = New_SURFACE(lk2, pg); s2.l1 = l2; s2.l2 = l3; s2.l3 = lk2; Set_direction(s2, pi); //将生成的面加到边的面链中 AddSurface(s, lk, Last_s); AddSurface(s, l1, Last_s);//将面加到l1的面链中去 AddSurface(s, l3, Last_s); AddSurface(s1, l1, Last_s); AddSurface(s1, lk1, Last_s); AddSurface(s1, l2, Last_s); AddSurface(s2, l3, Last_s); AddSurface(s2, lk2, Last_s); AddSurface(s2, l2, Last_s); #endregion sn_current = sn_current.Next; } } } else { #region pg是一个普通点 l1 = new LINE(pg, pi); l2 = new LINE(pg, pd); l3 = new LINE(pg, pj); PAINT.GetLL(l1); PAINT.GetLL(l2); PAINT.GetLL(l3); //生成的三条边l1,l2,l3,加入工作链中 pg.ll.Insert(l1); pg.ll.Insert(l2); pg.ll.Insert(l3); pi.ll.Insert(l1); pd.ll.Insert(l2); pj.ll.Insert(l3); Set_direction(Last_s, pg); s = New_SURFACE(pi, pj, pg); s.l1 = l1; s.l2 = l3; s.l3 = lk; PAINT.GetSL(s); Set_direction(s, pd); s1 = New_SURFACE(pi, pd, pg); s1.l1 = l1; s1.l2 = lk1; s1.l3 = l2; PAINT.GetSL(s1); Set_direction(s1, pj); s2 = New_SURFACE(pg, pj, pd); s2.l1 = l2; s2.l2 = l3; s2.l3 = lk2; PAINT.GetSL(s2); Set_direction(s2, pi); //将生成的面加到边的面链中 AddSurface(s, lk, Last_s); AddSurface(s, l1, Last_s);//将面加到l1的面链中去 AddSurface(s, l3, Last_s); AddSurface(s1, l1, Last_s); AddSurface(s1, lk1, Last_s); AddSurface(s1, l2, Last_s); AddSurface(s2, l3, Last_s); AddSurface(s2, lk2, Last_s); AddSurface(s2, l2, Last_s); pg.selected = true; work_pl.Insert(pg); #endregion sn_current = sn_current.Next; } }
private void Insert1() { util u1 = new util(); LINE l0 = nt_current.Data; pg.ToPrint(info); /*获取线链的头边和尾边的外端点*/ PO PLa, PFa; if (pkey.IsEqualToMe(l0.p1)) { PLa = l0.p2; } else { PLa = l0.p1; } if (pkey.IsEqualToMe(pre_l.Head.Data.p1)) { PFa = pre_l.Head.Data.p2; } else { PFa = pre_l.Head.Data.p1; } if (pg.selected) { info.Insert("po selected"); } else { info.Insert("po not selected"); } LINE lt;//获取相应边 info.Insert("t4"); #region PLa-PFa已存在 //如果PLa-PFa已存在,且尾边位于首边未搜索侧或首边两侧都搜索过 lt = Is_OutSide(PLa, PFa); if (lt != null) { info.Insert("ok"); } if (lt != null && (u1.noSearched(pre_l.Head.Data, PLa) || !pre_l.Head.Data.positive && !pre_l.Head.Data.negtive) && pkey.key != 3) { info.Insert("t1"); pkey.non_merged = false; Set_direction(pre_l.Head.Data, PLa); Set_direction(pre_l.Last.Data, PFa); Set_direction(lt, pkey); nt_current = nt_current.Next; // u1.InFile(u1.tri_num, (numbertri++).ToString() + '\t' + pkey.number + '\t' + PLa.number + '\t' + PFa.number); return; } #endregion //后面的没有PLa-PFa已存在的情况 #region pg位于其已搜索侧 if (!u1.noSearched(pre_l.Head.Data, pg) && u1.noSearched(pre_l.Head.Data, PLa) || pg == PFa) { //pg是当前边首边的外端点 info.Insert("t3"); pkey.non_merged = false; Set_direction(pre_l.Head.Data, PLa); Set_direction(l0, PFa); AddLine(PFa, PLa, pkey); nt_current = nt_current.Next; return; //u1.InFile(u1.tri_num, (numbertri++).ToString() + '\t' + pkey.number + '\t' + PLa.number + '\t' + PFa.number); } #endregion if (pg.selected) { //如果pg已经被选过 #region delete shadowpo //当前被处理的点的影子点位于pg的边链上 LINE shadow_l = Is_OutSide(pg, pkey); if (shadow_l != null) { info.Insert("shadow_pg_side"); PO shadow_po = shadow_l.getanotherpo(pg); PO shadow_po1, shadow_po2, shadow_pokey; shadow_po1 = shadow_po.ll.Head.Data.getanotherpo(shadow_po); shadow_po2 = shadow_po.ll.Last.Data.getanotherpo(shadow_po); float shadow_ang1, shadow_ang2; shadow_pokey = shadow_po1; shadow_ang1 = u1.d2_Cal_Op_Angle(PLa, shadow_po1, pkey); shadow_ang2 = u1.d2_Cal_Op_Angle(PLa, shadow_po2, pkey); if (shadow_ang2 < shadow_ang1) { shadow_pokey = shadow_po2; } lt = Is_OutSide(shadow_pokey, PLa); if (lt == null) { lt = AddLine(shadow_pokey, PLa, shadow_po); } PAINT.GetLL(lt); shadowPO(shadow_po, shadow_pokey, pkey, PLa); nt_current = pkey.ll.Last; return; } #endregion #region last's outside //如果pg是last的边链的外端点 lt = Is_OutSide(PLa, pg); if (lt != null) { info.Insert("last's outside\n"); Set_direction(pre_l.Last.Data, pg); AddLine(pkey, pg, PLa); //以上两句代码的顺序不能反,否则会出错 Set_direction(lt, pkey); nt_current = nt_current.Next; return; } #endregion last'soutside #region shadow_deal #region create shadowpo //如果pg是非特殊位置 info.Insert("arbitrary POint\n"); PO pt = new PO(pg.x, pg.y, pg.z); if (pg.shadow_pl != null) { pg.shadow_pl.Insert(pt); } else { info.Insert("add new shadow po\n"); pg.shadow_pl = new LinkList <PO>(); pg.shadow_pl.Insert(pg); pg.shadow_pl.Insert(pt); } pt.shadow_pl = pg.shadow_pl; pg = pt; //u1.InFile(u1.infopath, "here1"); AddLine(pkey, pg, PLa); // u1.InFile(u1.infopath, "here2"); AddLine(PLa, pg, pkey); //u1.InFile(u1.infopath, "here3"); Set_direction(l0, pg); // u1.InFile(u1.infopath, "here4"); //u1.InFile(u1.tri_num, (numbertri++).ToString() + '\t' + pkey.number + '\t' + PLa.number + '\t' + pg.number); work_pl.Insert(pg); //u1.InFile(u1.infopath,"here5"); pg.selected = true; nt_current = nt_current.Next; #endregion #endregion } else { #region ordinary_po info.Insert("ordinary point" + pg.number); //pg作为普通点处理 pg.number = number++; pg.selected = true; //u1.InFile(u1.node_key, pg.number.ToString() + '\t' + pg.x + '\t' + pg.y + '\t' + pg.key); AddLine(pkey, pg, PLa); AddLine(PLa, pg, pkey); Set_direction(l0, pg); //u1.InFile(u1.tri_num, (numbertri++).ToString() + '\t' + pkey.number + '\t' + PLa.number + '\t' + pg.number); if (pg.key != 3) { work_pl.Insert(pg); } //work_pl.Dispaly(); nt_current = nt_current.Next; #endregion } }
public void glOnLeftMouseUp(object sender, MouseEventArgs e) { isLeftDrag = false; PO pt = Map_to_Space(e.X, e.Y); if (p_tags != null) { if (ADD_MODEL_vwell) { Clear(); c.Create_Vertical_Well(pt); c.START_form(this); ADD_MODEL_vwell = false; Delaunay_2D de = new Delaunay_2D(); de.GetOGL(this); de.Get_initialpl(c.initial_pl); de.Get_initial_center(c.center); de.GetPL(c.Get_p_l()); de.Start(); this.PlotGLKey(); return; } else if (ADD_MODEL_fault) { LINE l0 = new LINE(p_tags, pt); Clear(); c.Create_fault(l0); c.START_form(this); p_tags = null; ADD_MODEL_fault = false; l_tag = null; Delaunay_2D de = new Delaunay_2D(); de.GetOGL(this); de.Get_initialpl(c.initial_pl); de.Get_initial_center(c.center); de.GetPL(c.Get_p_l()); de.Start(); this.PlotGLKey(); return; } else if (ADD_MODEL_hwell) { LINE l0 = new LINE(p_tags, pt); Clear(); c.Create_h_well2d(l0); c.START_form(this); p_tags = null; ADD_MODEL_hwell = false; l_tag = null; Delaunay_2D de = new Delaunay_2D(); de.GetOGL(this); de.Get_initialpl(c.initial_pl); de.Get_initial_center(c.center); de.GetPL(c.Get_p_l()); de.Start(); this.PlotGLKey(); return; } else if (p_tags.key == 1 || p_tags.key == 2) { p_tags.x = pt.x; p_tags.y = pt.y; Clear(); c.START_form(this); Delaunay_2D de = new Delaunay_2D(); de.GetOGL(this); de.Get_initialpl(c.initial_pl); de.Get_initial_center(c.center); de.GetPL(c.Get_p_l()); de.Start(); this.PlotGLKey(); } } }
public void GetLL_triangle(LINE l0) { ll_triangle.Insert(l0); return; }
public void GetLL_pebi(LINE l0) { ll_pebi.Insert(l0); return; }
private void Cal_new_edge_po_insert(model2d m0, PO p1, PO p2) { util u1 = new util(); PO np; float f1, f2; f1 = 0; f2 = 0; bool flag = false; Node <PO> pn = m0.edge_pl.Head, pnt, pnt1; pnt1 = null; LINE lt = new LINE(p1, p2); //PAINT.pl_tag.Insert(m0.edge_pl.Last.Data); if (pn != null) { while (pn.Next != null) { //寻找与p1,p2相交的直线段 np = u1.IsXl(pn.Data, pn.Next.Data, p1, p2, ref f1, ref f2); if (f1 > 0 && f1 < 1 && np != null) {//将np插入到pn-pnt之间 pnt = new Node <PO>(np); PAINT.pl_tag.Insert(np); pnt.Next = pn.Next; pn.Next = pnt; pn = pn.Next; if (pnt1 == null) { pnt1 = pnt; //u1.InFile(u1.wherepath,"find point 1"); //u1.InFile(u1.wherepath, u1.Direct_2d(lt, pn.Next.Data)); //u1.InFile(u1.wherepath, u1.Direct_2d(lt, m0.center)); //PAINT.pl_tag.Insert(pn.Next.Data); //PAINT.pl_tag.Insert(m0.center); if (u1.Direct_2d(lt, pn.Next.Data) * u1.Direct_2d(lt, m0.center) < 0) { flag = true; //u1.InFile(u1.wherepath, "flag=true"); } } else { if (flag) { //u1.InFile(u1.wherepath, "deal 1"); pnt1.Next = pnt; return; } else { //u1.InFile(u1.wherepath, "deal 2"); m0.edge_pl.Head = pnt1; m0.edge_pl.Last = pnt; m0.edge_pl.Last.Next = null; return; } } } pn = pn.Next; } } //u1.InFile(u1.wherepath, "middle"); np = u1.IsXl(pn.Data, m0.edge_pl.Head.Data, p1, p2, ref f1, ref f2); if (f1 > 0 && f1 < 1 && np != null) { //将np插入到pn-pnt之间 np.key = 2; PAINT.pl_tag.Insert(np); pnt = new Node <PO>(np); pnt.Next = pn.Next; pn.Next = pnt; if (pnt1 != null) { if (flag) { //u1.InFile(u1.wherepath, "deal 1"); pnt1.Next = pnt; return; } else { //u1.InFile(u1.wherepath, "deal 2"); m0.edge_pl.Head = pnt1; m0.edge_pl.Last = pnt; return; } } } }