public void GetLL_triangle(LINE l0) { ll_triangle.Insert(l0); return; }
public void GetSL(SURFACE s0) { sl.Insert(s0); return; }
public void GetLL(LINE l0) { ll.Insert(l0); return; }
public void GetLL_pebi(LINE l0) { ll_pebi.Insert(l0); return; }
public void GetPL(PO pl1) { pl.Insert(pl1); return; }
public void ToPrint(LinkList <String> infost) { infost.Insert(":" + '(' + x + ',' + y + ',' + z + ')'); }
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 } }
private LINE Is_OutSide(PO p0, PO ptest) { /* * 检测ptest是否在p0的边链的某个边的外端点处 * 如果是,返回相应边,否则返回null */ PO POutside; Node <LINE> lnt = p0.ll.Head; if (p0.shadow_pl == null) { while (lnt != null) { if (p0.IsEqualToMe(lnt.Data.p1)) { POutside = lnt.Data.p2; } else { POutside = lnt.Data.p1; } if (POutside.IsEqualToMe(ptest)) { return(lnt.Data); } lnt = lnt.Next; } } else { info.Insert("here shadow"); Node <PO> pnt = p0.shadow_pl.Head; while (pnt != null) { lnt = pnt.Data.ll.Head; while (lnt != null) { if (p0.IsEqualToMe(lnt.Data.p1)) { POutside = lnt.Data.p2; } else { POutside = lnt.Data.p1; } if (POutside.IsEqualToMe(ptest)) { return(lnt.Data); } lnt = lnt.Next; } pnt = pnt.Next; } } return(null); }
void Four_po_netnumber(PO[] p) { /* * 输入:长方形区域的四个角点的坐标 * 输出:长方形所包括的网格的坐标 */ util u1 = new util(); int x1, x1g, x2, x2g, xm, X0, Y0, X1, Y1, i; PO p1d, p2d, pm; pm = new PO(); if (u1.Direct_2d(new LINE(p[1], p[2]), p[3]) * u1.Direct_2d(new LINE(p[1], p[2]), p[0]) >= 0) { pm.x = p[2].x; pm.y = p[2].y; p[2].x = p[3].x; p[2].y = p[3].y; p[3].x = pm.x; p[3].y = pm.y; } X0 = (int)(p[0].x / Xi); Y0 = (int)(p[0].y / Yi); X1 = (int)(p[3].x / Xi); Y1 = (int)(p[3].y / Yi); p1d = p[0]; p2d = p[0]; x1g = x2g = 0; net_choosed.Clear(); for (i = Y0 + 1; i <= Y1 + 1; i++) { if (p1d.x == p[1].x) { x1 = (int)(p[1].x / Xi); } else if (p1d.y == p[1].y) { x1 = (int)(p[1].x / Xi); } else { x1 = (int)(u1.Cal_po_on_Line(p1d, p[1], (i + x1g) * Yi) / Xi); } if (p2d.x == p[2].x) { x2 = (int)(p[2].x / Xi); } else if (p2d.y == p[2].y) { x2 = (int)(p[2].x / Xi); } else { x2 = (int)(u1.Cal_po_on_Line(p2d, p[2], (i + x2g) * Yi) / Xi); } if (i - 1 == (int)(p[1].y / Yi)) { x1 = (int)(p[1].x / Xi); p1d = p[3]; x1g = -1; } if (i - 1 == (int)(p[2].y / Yi)) { x2 = (int)(p[2].x / Xi); x2g = -1; p2d = p[3]; } if (x1 > x2) { xm = x1; x1 = x2; x2 = xm; } while (x1 <= x2) { net_choosed.Insert(new PO(x1, i - 1)); x1++; } } }