Beispiel #1
0
        private void Open_direction(LinkList <LINE> l_l, PO pk)
        {
            //开启尾边的未搜索方向
            Node <LINE> ltail, ltailp, lt;

            lt     = l_l.Head;
            ltail  = null;
            ltailp = null;
            while (lt.Next != null)
            {
                ltailp = lt;
                ltail  = lt.Next;
                lt     = lt.Next;
            }//找到最后的两个节点
            PO pt;

            pt = ltailp.Data.getanotherpo(pk);
            util u1 = new util();

            if (u1.Direct_2d(ltail.Data, pt) > 0)
            {
                ltail.Data.negtive = true;
            }
            else
            {
                ltail.Data.positive = true;
            }
        }
Beispiel #2
0
        private void Set_direction(LINE l0, PO p0)
        {
            /*
             * 根据p0与s的相互关系,决定s的某个方向上是否有效
             * 设定为无效,则对应的标志为
             */
            util  u1 = new util();
            float f;

            f = u1.Direct_2d(l0, p0);
            if (f > 0)
            {
                l0.positive = false;
            }
            else if (f < 0)
            {
                l0.negtive = false;
            }
        }
Beispiel #3
0
        public bool noSearched(LINE l0, PO p0)
        {
            /*
             * 判断某条线的某个方向是否被搜索过,
             * 未搜索过返回true,搜索过返回false
             */
            util  u1 = new util();
            float f;

            f = u1.Direct_2d(l0, p0);
            if (f > 0 && l0.positive)
            {
                return(true);
            }
            else if (f < 0 && l0.negtive)
            {
                return(true);
            }
            return(false);
        }
Beispiel #4
0
        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++;
                }
            }
        }
Beispiel #5
0
        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;
                    }
                }
            }
        }