Пример #1
0
        public static List <itemWellLayerVoi> calVoi()
        {
            Voronoi voroObject = new Voronoi(0.1);
            int     iExtentDis = 200; //外边距
            List <itemWellLayerVoi> listLayerVoronoi = new List <itemWellLayerVoi>();
            // 读入小层数据字典
            List <ItemDicLayerDataStatic> listData = cIODicLayerDataStatic.readDicLayerData2struct();

            //   按小层顺序筛选,并计算voronoi,通过voronic 求取每个井层的面积

            foreach (string xcm in cProjectData.ltStrProjectXCM)
            {
                //写到每个小层文件夹内
                string       filePath = Path.Combine(cProjectManager.dirPathLayerDir, xcm, cProjectManager.fileNameGE);
                StreamWriter swGe     = new StreamWriter(filePath, false, Encoding.UTF8);
                List <ItemDicLayerDataStatic> listCurrentLayerData = listData.FindAll(p => p.sXCM == xcm);

                //如果没填得检查一遍
                //内部会排序并有对应的ID
                //尽量让排序后的sizes和Voronoi内部的size是同一个顺序,这块需要校验=Y的情况

                List <PointD> sites = new List <PointD>();

                foreach (ItemDicLayerDataStatic well in listCurrentLayerData)
                {
                    sites.Add(new PointD(well.dbX, well.dbY));
                }

                double[] xVal = new double[sites.Count];
                double[] yVal = new double[sites.Count];
                for (int i = 0; i < sites.Count; i++)
                {
                    xVal[i] = sites[i].X;
                    yVal[i] = sites[i].Y;
                    string sLine = i + " " + xVal[i] + " " + yVal[i];
                    swGe.WriteLine(sLine);
                }
                double           minX    = cProjectData.ltProjectWell.Min(p => p.dbX) - iExtentDis;
                double           maxX    = cProjectData.ltProjectWell.Max(p => p.dbX) + iExtentDis;
                double           minY    = cProjectData.ltProjectWell.Min(p => p.dbY) - iExtentDis;
                double           maxY    = cProjectData.ltProjectWell.Max(p => p.dbY) + iExtentDis;
                List <GraphEdge> list_ge = voroObject.generateVoronoi(xVal, yVal, minX, maxX, minY, maxY);

                for (int i = 0; i < list_ge.Count; i++)
                {
                    Point  p1    = new Point((int)list_ge[i].x1, (int)list_ge[i].y1);
                    Point  p2    = new Point((int)list_ge[i].x2, (int)list_ge[i].y2);
                    string sLine = " size1: " + list_ge[i].site1 + " " + list_ge[i].x1.ToString("0.0") + " " + list_ge[i].y1.ToString("0.0") + " size2: " + list_ge[i].site2 + " " + list_ge[i].x2.ToString("0.0") + " " + list_ge[i].y2.ToString("0.0");
                    swGe.WriteLine(sLine);
                }
                swGe.Close();

                //定义一个数据结构 就是返回 顶点序列,边的顺或者逆时针方向的结构列表
                //注意 这里安装sites的个数找 但是 ge里egde存的是
                List <List <PointD> > list_ClockPoints = new List <List <PointD> >();
                for (int i = 0; i < sites.Count; i++)
                {
                    List <PointD>    points      = new List <PointD>();
                    List <GraphEdge> ListEdgeCur = new List <GraphEdge>();
                    foreach (GraphEdge ge in list_ge)
                    {
                        if ((ge.site2 == i || ge.site1 == i) && (!(ge.x1 == ge.x2 && ge.y1 == ge.y2)))
                        {
                            ListEdgeCur.Add(ge);                                                                     //收集环绕顶点的所有边
                        }
                    }
                    foreach (GraphEdge ge in ListEdgeCur)
                    {
                        PointD p1 = new PointD(ge.x1, ge.y1);
                        PointD p2 = new PointD(ge.x2, ge.y2);

                        if (points.FindIndex(p => p.X == p1.X && p.Y == p1.Y) < 0)
                        {
                            points.Add(p1);
                        }
                        if (points.FindIndex(p => p.X == p2.X && p.Y == p2.Y) < 0)
                        {
                            points.Add(p2);                                            //获得顶点
                        }
                    }
                    List <PointD> PointDistinct = points.Distinct().ToList();
                    //按序号找到所有的顶点,按顺时针或者逆时针排序后输出
                    list_ClockPoints.Add(cSortPoints.sortPoints(PointDistinct, sites[i]));
                }

                //有了 listCurrentLayerData和对应的list_ClockPoints,加上对应的密度,体积系数就能按容积法求出面积,然后输出了
                for (int i = 0; i < listCurrentLayerData.Count; i++)
                {
                    itemWellLayerVoi item = new itemWellLayerVoi();
                    item.sJH        = listCurrentLayerData[i].sJH;
                    item.sXCM       = listCurrentLayerData[i].sXCM;
                    item.dbX        = listCurrentLayerData[i].dbX;
                    item.dbY        = listCurrentLayerData[i].dbY;
                    item.ltdpVertex = list_ClockPoints[i];//顶点
                    listLayerVoronoi.Add(item);
                }
            }//end of layerXCM foreach

            return(listLayerVoronoi);
        }//end of calRes
Пример #2
0
 public FormCalReservor()
 {
     InitializeComponent();
     setPanel();
     voroObject = new Voronoi(0.1);
 }