Exemple #1
0
        private void AddSurface(SURFACE s, LINE lk, SURFACE cur_s)
        {
            /*
             * 根据s与lk的面链的头尾的面的关系来确定s应该放在面链的头还是尾
             * 如果该边已经封闭则返回true,否则返回false
             */
            util    u1 = new util();
            SURFACE Last_s;

            if (lk.sl.Head == null)
            {
                lk.sl.Insert(s);
            }
            else
            {
                if (Surface_belong_line(lk, s))
                {
                    return;
                }
                Last_s = lk.sl.Last.Data;//获取面链尾部的面
                if (cur_s.id == Last_s.id)
                {
                    lk.sl.Insert(s);
                }
                else
                {
                    lk.sl.Head_Insert(s);
                }
            }
        }
Exemple #2
0
        public override string  ToString()
        {
            util u1 = new util();

            u1.InFile(u1.infopath, this);
            return(":" + '(' + x + ',' + y + ',' + z + ')');
        }
Exemple #3
0
        protected float Cal_distance_po_edge(PO p1, PO p2)
        {
            //计算p1沿p1-p2方向到边界的距离
            util  u1 = new util();
            PO    np;
            float f1, f2;

            f1 = 0;
            f2 = 0;
            Node <PO> pn = edge_pl.Head;

            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 && f2 >= 0 && f1 <= 1)
                {//将np插入到pn-pnt之间
                    return(np.Me_to_po_length(p1));
                }
                pn = pn.Next;
            }
            np = u1.IsXl(pn.Data, edge_pl.Head.Data, p1, p2, ref f1, ref f2);
            if (f1 > 0 && f1 < 1 && f2 >= 0 && f1 <= 1)
            {//将np插入到pn-pnt之间
                return(np.Me_to_po_length(p1));
            }
            return(0);
        }
Exemple #4
0
        private float[,] Array_Multi(float[,] a, float[,] b)
        {
            //计算矩阵乘法a*b;
            util u1 = new util();
            int  ro1, ro2, co1, co2;

            ro1 = 3;
            co1 = 3;
            ro2 = 3;
            co2 = b.Length;
            u1.InFile(u1.infopath, co2);
            float[,] re = new float[co1, ro2];
            float temp;

            for (int i = 0; i < co1; i++)
            {
                for (int j = 0; j < co2; j++)
                {
                    temp = 0;
                    for (int k = 0; k < co1; k++)
                    {
                        temp = temp + a[i, k] * b[k, j];
                    }
                    re[i, j] = temp;
                }
            }
            return(re);
        }
Exemple #5
0
        private void Open_direction(LINE l0, PO pk)
        {
            //开启尾面的未搜索方向
            Node <SURFACE> stail, stailp, sn;

            sn     = l0.sl.Head;
            stail  = null;
            stailp = null;
            while (sn.Next != null)
            {
                stailp = sn;
                stail  = sn.Next;
                sn     = sn.Next;
            }
            PO pt;

            pt = stailp.Data.GetPd(l0);
            util u1 = new util();

            if (u1.Direct(stail.Data, pt) > 0)
            {
                stail.Data.negtive = true;
            }
            else
            {
                stail.Data.positive = true;
            }
        }
Exemple #6
0
        public float Direct(SURFACE s0, PO p0)
        {
            util u1 = new util();
            PO   p1, p2, p3, vec1, vec2, vec, vecx;

            p1   = s0.p1;
            p2   = s0.p2;
            p3   = s0.p3;
            vec1 = new PO();
            vec2 = new PO();
            vec  = new PO();
            vecx = new PO();
            cal_vec(p1, p2, vec1);
            cal_vec(p1, p3, vec2);
            //u1.InFile("e:/info.txt","---start Direct---");
            //vec1.ToPrint();
            //vec2.ToPrint();
            cal_vecdot(vec1, vec2, vec);//计算向量积
            //vec.ToPrint();
            cal_vec(p1, p0, vecx);
            //vecx.ToPrint();
            //u1.InFile("e:/info.txt", "---end Direct---");
            if (System.Math.Abs(Dot(vec, vecx)) > 0.0001)
            {
                return(Dot(vec, vecx));
            }
            else
            {
                return(0);
            }
        }
Exemple #7
0
        private float[,] Inverse(float[,] a)
        {
            //求矩阵a的逆矩阵
            util u1 = new util();

            float[,] b = new float[3, 3];
            float deter;

            deter = a[0, 0] * a[1, 1] * a[2, 2] + a[0, 1] * a[1, 2] * a[2, 0] + a[1, 0] * a[2, 1] * a[0, 2] -
                    a[0, 2] * a[1, 1] * a[2, 0] - a[0, 0] * a[2, 1] * a[1, 2] - a[0, 1] * a[1, 0] * a[2, 2];
            if (deter != 0)
            {
                b[0, 0] = (a[1, 1] * a[2, 2] - a[1, 2] * a[2, 1]) / deter;
                b[0, 1] = -(a[1, 0] * a[2, 2] - a[1, 2] * a[2, 0]) / deter;
                b[0, 2] = (a[1, 0] * a[2, 1] - a[1, 1] * a[2, 0]) / deter;
                b[1, 0] = -(a[0, 1] * a[2, 2] - a[0, 2] * a[2, 1]) / deter;
                b[1, 1] = (a[0, 0] * a[2, 2] - a[0, 2] * a[2, 0]) / deter;
                b[1, 2] = -(a[0, 0] * a[2, 1] - a[0, 1] * a[2, 0]) / deter;
                b[2, 0] = (a[0, 1] * a[1, 2] - a[1, 1] * a[0, 2]) / deter;
                b[2, 1] = -(a[0, 0] * a[1, 2] - a[1, 0] * a[0, 2]) / deter;
                b[2, 2] = (a[0, 0] * a[1, 1] - a[1, 0] * a[0, 1]) / deter;
                return(b);
            }
            else
            {
                u1.InFile(u1.infopath, "det equals zero!!!");
                return(null);
            }
        }
Exemple #8
0
        public void SearchPoint(int num)
        {
            //Delaunay算法的主函数,遍历边链的每一条边,并分别进行处理
            util      u1 = new util();
            Node <PO> pt = work_pl.Head;

            u1.InFile(u1.infopath, "--start SearchPoint--");
            for (int i = 0; i < num; i++)
            {
                loc = i;
                if (pt == null)
                {
                    break;
                }
                u1.InFile(u1.infopath, i);
                pkey = pt.Data;
                pt.Data.ToString();//输出当前需要处理的点
                pre_l = pt.Data.ll;
                SearchLine();
                //PEBIGrid(pt.Data);
                pt = pt.Next;
                //pkey.ll.Dispaly();
                //u1.InFile(u1.infopath, i);
                //work_pl.Dispaly();
            }
            PAINT.SetPL(work_pl);
            u1.InFile(u1.infopath, "--SearchPoint end--");
        }
Exemple #9
0
        private void SearchD(SURFACE s0)
        {
            /*
             * 针对某个面,在模型的点链中搜索某个满足条件的点
             */
            pi = s0.p1;
            pj = s0.p2;
            pk = s0.p3;
            pg = null;
            Node <PO> pt = null;

            soliangle1 = 0;
            util u1 = new util();

            info.Insert("--start SearchD--");
            pt = pl.Head;
            while (pt != null)
            {
                soliangle2 = u1.d3_Cal_Solid_Angle(pt.Data, pi, pj, pk);
                if (soliangle1 < soliangle2 && u1.noSearched(s0, pt.Data))
                {
                    soliangle1 = soliangle2;
                    pg         = pt.Data;
                }
                pt = pt.Next;
            }
            info.Insert("--end SearchD--");
        }
Exemple #10
0
        public void SearchPoint_step(int stepx)
        {
            //Delaunay算法的主函数,遍历边链的每一条边,并分别进行处理
            util      u1 = new util();
            Node <PO> pt = work_pl.Head;

            info.Insert("--start SearchPOint--\n");
            for (int i = 0; i < stepx; i++)
            {
                info.Insert(":" + "-------" + i + "----------\n");
                if (pt == null)
                {
                    break;
                }
                if (STOP)
                {
                    break;
                }
                loc  = i;
                pkey = pt.Data;
                pt.Data.ToPrint(info);//输出当前需要处理的点
                pre_l = pt.Data.ll;
                SearchLine();
                PEBIGrid(pt.Data);
                pt            = pt.Next;
                Where_pointer = pt;
            }
            info.Insert("--SearchPOint end--");
        }
Exemple #11
0
        public override void GenerateNetPo()
        {
            float L, li, d, sof, distance1, distance2;     //sof是初始偏差值
            PO    tmp, po;

            PAINT.GetLL(l0);
            util u1 = new util();

            show_edge_l();
            L   = l0.Length();
            sof = (float)((L - System.Math.Floor(L / dx) * dx) / 2);
            for (int i = 1; i <= System.Math.Floor(L / dx) - 1; i++)
            {
                li        = (float)(sof + i * dx);
                tmp       = new PO();
                tmp.x     = (l0.p1.x * (L - li) + l0.p2.x * li) / L;
                tmp.y     = (l0.p1.y * (L - li) + l0.p2.y * li) / L;
                distance1 = Cal_distance_po_edge(tmp, u1.po_vertical(tmp, l0.p1, l0.p2, dy));
                distance2 = Cal_distance_po_edge(tmp, u1.po_vertical(tmp, l0.p2, l0.p1, dy));
                if (distance1 > distance2)
                {
                    distance1 = distance2;
                }
                po = u1.po_vertical(tmp, l0.p1, l0.p2, distance1 * 1 / 2);
                ge_p_l.Insert(po);
                PAINT.GetPL(po);
                po = u1.po_vertical(tmp, l0.p2, l0.p1, distance1 * 1 / 2);
                ge_p_l.Insert(po);
                PAINT.GetPL(po);
            }
        }
Exemple #12
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;
            }
        }
Exemple #13
0
        public void SearchPoint()
        {
            //Delaunay算法的主函数,遍历边链的每一条边,并分别进行处理
            util u1 = new util();

            u1.Tip_Time();
            Node <PO> pt = work_pl.Head;

            info.Insert("--start SearchPOint--");
            loc = 0;
            while (pt != null)
            {
                loc++;
                if (pt == null)
                {
                    break;
                }
                if (STOP)
                {
                    break;
                }
                pkey = pt.Data;
                pt.Data.ToPrint(info);//输出当前需要处理的点
                pre_l = pt.Data.ll;
                SearchLine();
                PEBIGrid(pt.Data);
                pt = pt.Next;
            }

            info.Insert("--SearchPOint end--\n");
            u1.Span_from_last_time("runtime");
        }
Exemple #14
0
        public override void GenerateNetPo()
        {
            int   sitan;
            float PI = 3.1415926f;
            util  u1 = new util();

            sitan = 10;
            PO vec, vec2, pc;//沿井身

            vec  = new PO(0, 0, 1);
            vec2 = new PO();
            pi   = new PO();
            pj   = new PO();
            for (int i = 5; i < 20; i = i + 4)
            {
                for (int j = 0; j < sitan; j++)
                {
                    vec2.x = (float)System.Math.Cos(2 * PI * j / sitan);
                    vec2.y = (float)System.Math.Sin(2 * PI * j / sitan);
                    vec2.z = 0;
                    pc     = u1.Po_vec_f(u1.vec_f(vec, 0), vec2, i);
                    if (i == 17 && j == 1)
                    {
                        pi = pc;
                    }
                    if (i == 17 && j == 2)
                    {
                        pj = pc;
                    }
                    PAINT.GetPL(pc);
                    ge_p_l.Insert(pc);
                }
            }
            //PAINT.GetLL(new LINE(pi,pj));
        }
Exemple #15
0
        private void SearchD(LINE l0)
        {
            /*
             * 针对某个面,在模型的点链中搜索某个满足条件的点
             */
            pg = null;
            Node <PO> pt = null;

            soliangle1 = 0;
            util u1 = new util();

            u1.InFile(u1.infopath, "--start SearchD--");
            pt = pl.Head;
            while (pt != null)
            {
                soliangle2 = u1.d2_Cal_Op_Angle(l0, pt.Data);
                if (soliangle1 < soliangle2 && u1.noSearched(l0, pt.Data))
                {
                    soliangle1 = soliangle2;
                    pg         = pt.Data;
                }
                pt = pt.Next;
            }
            u1.InFile(u1.infopath, "--end SearchD--");
        }
Exemple #16
0
        public PO Map_to_Space(int x, int y)
        {
            util u1 = new util();

            unsafe
            {
                double *modelview  = stackalloc double[16];
                double *projection = stackalloc double[16];
                int *   viewport   = stackalloc int[4];
                PO      pf;
                double  z;
                pf = new PO();
                GLU.glGetDoublev(GLU.GL_MODELVIEW_MATRIX, modelview);
                GLU.glGetDoublev(GLU.GL_PROJECTION_MATRIX, projection);
                GLU.glGetIntegerv(GLU.GL_VIEWPORT, viewport);
                GLU.glReadPixels(x, y, 1, 1, GLU.GL_DEPTH_COMPONENT, GLU.GL_FLOAT, &z);
                double world_x, world_y, world_z;
                GLU.gluUnProject((double)x, (double)(viewport[3] - y - 1), 1,
                                 modelview, projection, viewport,
                                 &world_x, &world_y, &world_z);
                pf.x = (float)world_x;
                pf.y = (float)world_y;
                pf.z = 0;
                return(pf);
            }
        }
Exemple #17
0
        public float Length()
        {
            PO   vec;
            util u1 = new util();

            vec = u1.cal_vec(p1, p2);
            return(vec.length());
        }
Exemple #18
0
        private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            util u1 = new util();

            PO[] pnc;
            pnc        = u1.Get_po_from_string(listBox2.SelectedItem.ToString());
            ogl1.l_tag = new LINE(pnc[0], pnc[1]);
            ogl1.PlotGLKey();
        }
Exemple #19
0
        public float Me_to_po_length(PO p0)
        {
            //返回该点到p0的距离
            util u1 = new util();
            PO   pt = u1.cal_vec(this, p0);

            pt.z = 0;
            return(pt.length());
        }
Exemple #20
0
        public void ToPrint()
        {
            util u1 = new util();

            u1.InFile(u1.infopath, "---LINE---");
            p1.ToPrint();
            p2.ToPrint();
            u1.InFile(u1.infopath, "---end---");
        }
Exemple #21
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            list(listBox1.SelectedIndex - 1, de);
            util u1 = new util();

            PO[] pnc;
            pnc         = u1.Get_po_from_string(listBox1.SelectedItem.ToString());
            ogl1.p_tags = pnc[0];
            ogl1.PlotGLKey();
        }
Exemple #22
0
        public override void GenerateNetPo()
        {
            util u1 = new util();

            show_edge_l();
            float yita, rx;
            int   ix, id, isita;
            PO    ptmp, pc;
            PO    pk;

            pc   = new PO();
            pc.x = (l0.p1.x + l0.p2.x) / 2;
            pc.y = (l0.p1.y + l0.p2.y) / 2;
            yita = (float)System.Math.Pow(ro / ri, 1.0 / (nr - 1));
            for (id = 0; id <= nd - 1; id++)
            {
                ptmp   = new PO();
                ptmp.x = ((nd - 1 - id) * l0.p1.x + id * l0.p2.x) / (nd - 1);
                ptmp.y = ((nd - 1 - id) * l0.p1.y + id * l0.p2.y) / (nd - 1);
                ge_p_l.Insert(ptmp);
                PAINT.GetPL(ptmp);
            }
            for (ix = 0; ix < nr; ix++)
            {
                rx = (float)(ri * System.Math.Pow(yita, ix));
                for (id = 1; id < nd - 1; id++)
                {
                    ptmp   = new PO();
                    ptmp.x = ((nd - 1 - id) * l0.p1.x + id * l0.p2.x) / (nd - 1);
                    ptmp.y = ((nd - 1 - id) * l0.p1.y + id * l0.p2.y) / (nd - 1);
                    pk     = u1.po_vertical(ptmp, l0.p1, l0.p2, rx);
                    ge_p_l.Insert(pk);
                    PAINT.GetPL(pk);
                    pk = u1.po_vertical(ptmp, l0.p2, l0.p1, rx);
                    ge_p_l.Insert(pk);
                    PAINT.GetPL(pk);
                }
                for (isita = 0; isita <= nsta / 2; isita++)
                {
                    ptmp   = new PO();
                    ptmp.x = (float)(l0.p1.x + rx * System.Math.Cos(2 * 3.1415926 * isita / nsta + u1.CalAgl(l0.p1, l0.p2) + 3.1415926 / 2));
                    ptmp.y = (float)(l0.p1.y + rx * System.Math.Sin(2 * 3.1415926 * isita / nsta + u1.CalAgl(l0.p1, l0.p2) + 3.1415926 / 2));
                    ge_p_l.Insert(ptmp);
                    PAINT.GetPL(ptmp);
                }
                for (isita = 0; isita <= nsta / 2; isita++)
                {
                    ptmp   = new PO();
                    ptmp.x = (float)(l0.p2.x + rx * System.Math.Cos(2 * 3.1415926 * isita / nsta + u1.CalAgl(l0.p1, l0.p2) + 3.1415926 * 1.5f));
                    ptmp.y = (float)(l0.p2.y + rx * System.Math.Sin(2 * 3.1415926 * isita / nsta + u1.CalAgl(l0.p1, l0.p2) + 3.1415926 * 1.5f));
                    ge_p_l.Insert(ptmp);
                    PAINT.GetPL(ptmp);
                }
            }
        }
Exemple #23
0
        public override string ToString()
        {
            util   u1  = new util();
            string str = "ok";

            u1.InFile(u1.infopath, "---LINE---");
            p1.ToPrint();
            p2.ToPrint();
            u1.InFile(u1.infopath, "---end---");
            return(":" + '(' + p1.x + ',' + p1.y + ',' + p1.z + ')' + '(' + p2.x + ',' + p2.y + ',' + p2.z + ')');
        }
Exemple #24
0
        public override string ToString()
        {
            util u1 = new util();

            u1.InFile(u1.infopath, "---surface---");
            p1.ToPrint();
            p2.ToPrint();
            p3.ToPrint();
            u1.InFile(u1.infopath, "---end---");
            return("ok");
        }
Exemple #25
0
        private void add_text()
        {
            System.IO.StreamReader st;
            util u1 = new util();

            st = new System.IO.StreamReader(u1.infopath, System.Text.Encoding.UTF8);
            string str = st.ReadToEnd();

            st.Close();
            textBox1.Text = str;
        }
Exemple #26
0
        public SURFACE Get_Surface(SURFACE s0)
        {
            /*
             * 返回在当前线的面链中与当前面s0相邻的面,而且该面在面s0的合适位置
             */
            util           u1 = new util();
            Node <SURFACE> sn = sl.Head;
            PO             pt;//用于记录需要检测的面上的一个点

            //如果s0是sl的第一个面,则返回sl的最后一个面
            if (sn.Data == s0 && sl.Head.Next != null)
            {
                pt = sl.Last.Data.GetPd(this);
                if (u1.noSearched(sn.Data, pt))
                {
                    return(sl.Last.Data);
                }
            }
            //如果s0是最后一个面,返回第一个面
            if (sl.Last.Data == s0 && sl.Head != sl.Last)
            {
                pt = sl.Head.Data.GetPd(this);
                if (u1.noSearched(sl.Last.Data, pt))
                {
                    return(sl.Head.Data);
                }
            }
            //如果s0既不是第一个面也不是最后一个面
            while (sn != null)
            {
                //考查s0的后一个面
                if (sn.Data == s0 && sn.Next != null)
                {
                    pt = sn.Next.Data.GetPd(this);
                    if (u1.noSearched(sn.Data, pt))
                    {
                        return(sn.Next.Data);
                    }
                }
                //考查s0的前一个面
                if (sn.Next != null && sn.Next.Data == s0)
                {
                    pt = sn.Data.GetPd(this);
                    if (u1.noSearched(sn.Next.Data, pt))
                    {
                        return(sn.Data);
                    }
                }
                sn = sn.Next;
            }
            //如果sl中不存在s0面
            return(null);
        }
Exemple #27
0
        private void DE_LL(fault2d f1, fault2d f2)
        {
            util u1 = new util();

            if (!Is_Conflict(f1, f2))
            {
                return;
            }
            else
            {
                CD_po_together(f1, f2);
            }
        }
Exemple #28
0
        private void DE_WW(well2d w1, well2d w2)
        {
            util u1 = new util();

            if (!Is_Conflict(w1, w2))
            {
                return;
            }
            else
            {
                CD_well_well(w1, w2);
            }
        }
Exemple #29
0
        public bool Is_po_inMe(PO p0)
        {
            util u1 = new util();

            if (edge_pl != null)
            {
                return(u1.Is_in_polygon(edge_pl, p0));
            }
            else
            {
                return(false);
            }
        }
Exemple #30
0
        public PO po_vertical(PO p1, PO p2, PO p3, float rx)
        {
            //以p1为起点,以与p2-p3确定的线相垂直的单位向量为方向,求点
            util u1 = new util();
            PO   pt, e;

            pt = new PO();
            e  = u1.cal_vec(p2, p3);
            e.unitVector();
            pt.x = p1.x + rx * e.y;
            pt.y = p1.y - rx * e.x;
            return(pt);
        }