Exemplo n.º 1
0
 public PO GetPd(LINE l0)
 {
     /*
      * 获取一个面中除去某条边外的另一个点
      */
     if (p1.IsEqualToMe(l0.p1) && p2.IsEqualToMe(l0.p2))
     {
         return(p3);
     }
     if (p1.IsEqualToMe(l0.p2) && p2.IsEqualToMe(l0.p1))
     {
         return(p3);
     }
     if (p3.IsEqualToMe(l0.p1) && p2.IsEqualToMe(l0.p2))
     {
         return(p1);
     }
     if (p3.IsEqualToMe(l0.p2) && p2.IsEqualToMe(l0.p1))
     {
         return(p1);
     }
     if (p1.IsEqualToMe(l0.p1) && p3.IsEqualToMe(l0.p2))
     {
         return(p2);
     }
     if (p1.IsEqualToMe(l0.p2) && p3.IsEqualToMe(l0.p1))
     {
         return(p2);
     }
     return(null);
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public bool Po_insideme(PO p0)
 {
     //如果p0是该线的端点,则返回true,否则返回false
     if (p0.IsEqualToMe(p1) || p0.IsEqualToMe(p2))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 4
0
 public PO getanotherpo(PO p0)
 {
     //返回线的两个端点中除p0的另一个点
     if (p1.IsEqualToMe(p0))
     {
         return(p2);
     }
     else
     {
         return(p1);
     }
 }
Exemplo n.º 5
0
        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
            }
        }