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; } } }
private void shadowPO(PO shap, PO shapflag, PO pap, PO papflag) { /* * 将影子点的边转移到父点中去 * shap是影子点,shapflag是影子点的标记点 * pap是父点,papflag是父点的标记点 */ util u1 = new util(); if (pap.ll.Head.Data.Po_insideme(papflag)) {//如果标记点在父点的首边上 if (shap.ll.Head.Data.Po_insideme(shapflag)) { #region case1 Node <LINE> lnt = shap.ll.Head; while (lnt != null) { //用父点换掉边中的影子点 lnt.Data.Po_insideme_and_changeit(pap); pap.ll.Head_Insert(lnt.Data); lnt = lnt.Next; } #endregion case1 } else { #region case2 LinkList <LINE> lt = new LinkList <LINE>(); Node <LINE> lnt = shap.ll.Head; while (lnt != null)//将shap的线链反序 { lt.Head_Insert(lnt.Data); lnt = lnt.Next; } lnt = lt.Head; while (lnt != null) { lnt.Data.Po_insideme_and_changeit(pap); pap.ll.Head_Insert(lnt.Data); lnt = lnt.Next; } #endregion case2 } } else {//如果标记点在父点的尾边上 if (shap.ll.Head.Data.Po_insideme(shapflag)) { shap.ToString(); #region case3 Node <LINE> lnt = shap.ll.Head; while (lnt != null) { lnt.Data.Po_insideme_and_changeit(pap); pap.ll.Insert(lnt.Data); lnt = lnt.Next; } #endregion case3 } else { #region case4 LinkList <LINE> lt = new LinkList <LINE>(); Node <LINE> lnt = shap.ll.Head; while (lnt != null)//将shap的线链反序 { lt.Head_Insert(lnt.Data); lnt = lnt.Next; } lnt = lt.Head; while (lnt != null) { lnt.Data.Po_insideme_and_changeit(pap); pap.ll.Insert(lnt.Data); lnt = lnt.Next; } #endregion case4 } } work_pl.Delete(shap); //如果此时父节点的尾边封闭,则开启其尾边相应方向 if (!pap.ll.Last.Data.negtive && !pap.ll.Last.Data.positive && pkey.key != 3) { Open_direction(pap.ll, pap); } }