Beispiel #1
0
        protected override Well Convert(WellSpecs wellspec, WellCompatCollection wellCompSegments = null)
        {
            int locI = wellspec.Li;
            int locJ = wellspec.Lj;


            //if compat has position ,use compat
            List <WellCompat> segments = null;

            if (wellCompSegments != null)
            {
                segments = wellCompSegments.GetWellSegments(wellspec.WellName);
            }
            if (segments != null && segments.Count > 0)
            {
                locI = segments[0].PosI;
                locJ = segments[0].PosJ;
            }

            Vertex      minCord = this.gridder.FlipTransform * this.gridder.SourceActiveBounds.Min;
            Vertex      maxCord = this.gridder.FlipTransform * this.gridder.SourceActiveBounds.Max;
            Rectangle3D rectSrc = new Rectangle3D(minCord, maxCord);

            if (!this.gridder.IsSliceBlock(locI, locJ))
            {
                return(null);
            }



            Vertex h1 = this.gridder.FlipTransform * this.gridder.PointFLT(locI, locJ, 1);
            Vertex h2 = this.gridder.FlipTransform * this.gridder.PointBRT(locI, locJ, 1);
            Vertex d0 = h2 - h1;
            float  L  = (float)d0.Magnitude();

            d0.Normalize();
            Vertex vec   = d0 * (L * 0.5f);
            Vertex comp1 = CenterOfLine(h1, h2);;  //地层完井段的起始点


            Vertex modelTop = new Vertex(comp1.X, comp1.Y, rectSrc.Max.Z);


            float mdx = rectSrc.SizeX;
            float mdy = rectSrc.SizeY;
            float mdz = rectSrc.SizeZ;

            float xyextend = System.Math.Max(mdx, mdy); //XY平面的最大边长
            float extHeight;                            //延长线段

            if (mdz < 0.1f * xyextend)                  //z很小
            {
                extHeight = 0.1f * xyextend;
            }
            else if (mdz < 0.2f * xyextend)
            {
                extHeight = mdz * 0.5f;
            }
            else if (mdz < 0.3f * xyextend)
            {
                extHeight = mdz * 0.25f;
            }
            else if (mdz < 0.4f * xyextend)
            {
                extHeight = mdz * 0.2f;
            }
            else
            {
                extHeight = 0.2f * mdz;
            }

            //地表坐标


            Vertex direction = new Vertex(0, 0, 1.0f);
            Vertex head      = modelTop + direction * extHeight;

            //确定井的半径
            float wellRadius;

            #region decide the well radius
            if (mdx < mdy)
            {
                if (mdy * 0.5f >= mdx) //长方形的模型
                {
                    int n = gridder.NX;
                    if (n >= 10)
                    {
                        wellRadius = (mdx / n) * 0.5f;
                    }
                    else
                    {
                        wellRadius = (mdx / n) * 0.35f;
                    }
                }
                else
                {
                    int n = gridder.NX;
                    if (n >= 10)
                    {
                        n          = 10;
                        wellRadius = (mdx / n) * 0.5f;
                    }
                    else
                    {
                        wellRadius = (mdx / n) * 0.35f;
                    }
                }
            }
            else if (mdx == mdy)
            {
                int n = Math.Min(gridder.NX, gridder.NY);
                if (n >= 10)
                {
                    n          = 10;
                    wellRadius = (mdx / n) * 0.85f;
                }
                else
                {
                    wellRadius = (mdx / n) * 0.5f;
                }
            }
            else
            {
                if (mdx * 0.5f >= mdy)
                {
                    int n = gridder.NY;
                    if (n > 10)
                    {
                        n          = 10;
                        wellRadius = (mdy / n) * 0.5f;
                    }
                    else
                    {
                        wellRadius = (mdy / n) * 0.35f;
                    }
                }
                else
                {
                    int n = gridder.NY;
                    if (n > 10)
                    {
                        n          = 10;
                        wellRadius = (mdx / n) * 0.5f;
                    }
                    else
                    {
                        wellRadius = (mdx / n) * 0.35f;
                    }
                }
            }
            #endregion

            Fluid   fluid     = FluidConverter.Convert(wellspec.Fluid);
            GLColor pipeColor = MapFluidToColor(fluid);
            GLColor textColor = new GLColor(1.0f, 1.0f, 1.0f, 1.0f);
            string  wellName  = wellspec.WellName;


            List <Vertex> wellPath = new List <Vertex>();
            wellPath.Add(head);
            wellPath.Add(modelTop);

            #region start decide the trajery of the well
            {
                int    lastI      = locI;
                int    lastJ      = locJ;
                int    lastK      = -1;
                Vertex lastVertex = comp1;
                int    segCount   = segments.Count;
                for (int i = 0; i < segCount; i++)
                {
                    WellCompat compseg = segments[i];
                    int        compI   = compseg.PosI;
                    int        compJ   = compseg.PosJ;
                    int        compK1  = compseg.K1;
                    int        compK2  = compseg.K2;
                    if (compK1 == compK2)//同一网格上
                    {
                        if ((lastI != compI) || (lastJ != compJ) || (lastK != compK1))
                        {
                            Vertex s1    = gridder.FlipTransform * gridder.PointFLT(compI, compJ, compK1);
                            Vertex s2    = gridder.FlipTransform * gridder.PointBRT(compI, compJ, compK1);
                            Vertex point = CenterOfLine(s1, s2);
                            wellPath.Add(point);
                            lastI = compI;
                            lastJ = compJ;
                            lastK = compK1;
                        }
                    }
                    else //compK1 != compK2
                    {
                        //k1 coord
                        if ((lastI != compI) || (lastJ != compJ) || (lastK != compK1))
                        {
                            Vertex s1    = gridder.FlipTransform * gridder.PointFLT(compI, compJ, compK1);
                            Vertex s2    = gridder.FlipTransform * gridder.PointBRT(compI, compJ, compK1);
                            Vertex point = CenterOfLine(s1, s2);
                            wellPath.Add(point);
                        }
                        lastI = compI;
                        lastJ = compJ;
                        lastK = compK1;

                        if ((lastI != compI) || (lastJ != compJ) || (lastK != compK2))
                        {
                            Vertex s1    = gridder.FlipTransform * gridder.PointFLT(compI, compJ, compK2);
                            Vertex s2    = gridder.FlipTransform * gridder.PointBRT(compI, compJ, compK2);
                            Vertex point = CenterOfLine(s1, s2);
                            wellPath.Add(point);
                        }
                        lastI = compI;
                        lastJ = compJ;
                        lastK = compK2;
                    }
                }//end for

                Well well3d = new Well(this.camera, wellPath, wellRadius, pipeColor, wellName, textColor, 12, wellName.Length * 10);
                well3d.ZAxisScale = 1;
                well3d.Transform  = this.gridder.ScaleTranslateform;
                well3d.CreateVisualElements(this.camera);
                return(well3d);
            }
            #endregion
        }
        protected override CSharpGL.Tuple <WellRenderer, LabelRenderer> Convert(vec3 originalWorldPosition, TracyEnergy.Simba.Data.Keywords.impl.WellSpecs wellspec, TracyEnergy.Simba.Data.Keywords.impl.WellCompatCollection wellCompatList)
        {
            int locI = wellspec.Li;
            int locJ = wellspec.Lj;

            //if compat has position ,use compat
            List <WellCompat> segments = null;

            if (wellCompatList != null)
            {
                segments = wellCompatList.GetWellSegments(wellspec.WellName);
            }
            if (segments != null && segments.Count > 0)
            {
                locI = segments[0].PosI;
                locJ = segments[0].PosJ;
            }

            if (!this.grid.DataSource.IsSliceBlock(locI, locJ))
            {
                return(null);
            }

            vec3  h1 = this.grid.DataSource.PointFLT(locI, locJ, 1);
            vec3  h2 = this.grid.DataSource.PointBRT(locI, locJ, 1);
            vec3  d0 = h2 - h1;
            float L  = (float)d0.length();

            d0 = d0.normalize();
            vec3 vec   = d0 * (L * 0.5f);
            vec3 comp1 = CenterOfLine(h1, h2);;  //地层完井段的起始点

            //vec3 minCord = this.grid.FlipTransform * this.grid.SourceActiveBounds.Min;
            vec3        minCord  = this.grid.DataSource.SourceActiveBounds.Min;
            vec3        maxCord  = this.grid.DataSource.SourceActiveBounds.Max;
            Rectangle3D rectSrc  = new Rectangle3D(minCord, maxCord);
            vec3        modelTop = new vec3(comp1.x, comp1.y, rectSrc.Max.z);

            float mdx = rectSrc.SizeX;
            float mdy = rectSrc.SizeY;
            float mdz = rectSrc.SizeZ;

            float xyextend = System.Math.Max(mdx, mdy); //XY平面的最大边长
            float extHeight;                            //延长线段

            if (mdz < 0.1f * xyextend)                  //z很小
            {
                extHeight = 0.1f * xyextend;
            }
            else if (mdz < 0.2f * xyextend)
            {
                extHeight = mdz * 0.5f;
            }
            else if (mdz < 0.3f * xyextend)
            {
                extHeight = mdz * 0.25f;
            }
            else if (mdz < 0.4f * xyextend)
            {
                extHeight = mdz * 0.2f;
            }
            else
            {
                extHeight = 0.2f * mdz;
            }

            //地表坐标

            vec3 direction = new vec3(0, 0, 1.0f);
            vec3 head      = modelTop + direction * extHeight;

            //确定井的半径
            float wellRadius;

            #region decide the well radius
            if (mdx < mdy)
            {
                if (mdy * 0.5f >= mdx) //长方形的模型
                {
                    int n = this.grid.DataSource.NX;
                    if (n >= 10)
                    {
                        wellRadius = (mdx / n) * 0.5f;
                    }
                    else
                    {
                        wellRadius = (mdx / n) * 0.35f;
                    }
                }
                else
                {
                    int n = this.grid.DataSource.NX;
                    if (n >= 10)
                    {
                        n          = 10;
                        wellRadius = (mdx / n) * 0.5f;
                    }
                    else
                    {
                        wellRadius = (mdx / n) * 0.35f;
                    }
                }
            }
            else if (mdx == mdy)
            {
                int n = Math.Min(this.grid.DataSource.NX, this.grid.DataSource.NY);
                if (n >= 10)
                {
                    n          = 10;
                    wellRadius = (mdx / n) * 0.85f;
                }
                else
                {
                    wellRadius = (mdx / n) * 0.5f;
                }
            }
            else
            {
                if (mdx * 0.5f >= mdy)
                {
                    int n = this.grid.DataSource.NY;
                    if (n > 10)
                    {
                        n          = 10;
                        wellRadius = (mdy / n) * 0.5f;
                    }
                    else
                    {
                        wellRadius = (mdy / n) * 0.35f;
                    }
                }
                else
                {
                    int n = this.grid.DataSource.NY;
                    if (n > 10)
                    {
                        n          = 10;
                        wellRadius = (mdx / n) * 0.5f;
                    }
                    else
                    {
                        wellRadius = (mdx / n) * 0.35f;
                    }
                }
            }
            #endregion

            Fluid fluid     = FluidConverter.Convert(wellspec.Fluid);
            Color pipeColor = MapFluidToColor(fluid);
            Color textColor = Color.White;

            List <vec3> wellPath = new List <vec3>();
            wellPath.Add(head);
            wellPath.Add(modelTop);

            #region start decide the trajery of the well
            {
                int  lastI    = locI;
                int  lastJ    = locJ;
                int  lastK    = -1;
                vec3 lastvec3 = comp1;
                int  segCount = segments.Count;
                for (int i = 0; i < segCount; i++)
                {
                    WellCompat compseg = segments[i];
                    int        compI   = compseg.PosI;
                    int        compJ   = compseg.PosJ;
                    int        compK1  = compseg.K1;
                    int        compK2  = compseg.K2;
                    if (compK1 == compK2)//同一网格上
                    {
                        if ((lastI != compI) || (lastJ != compJ) || (lastK != compK1))
                        {
                            vec3 s1    = this.grid.DataSource.PointFLT(compI, compJ, compK1);
                            vec3 s2    = this.grid.DataSource.PointBRT(compI, compJ, compK1);
                            vec3 point = CenterOfLine(s1, s2);
                            wellPath.Add(point);
                            lastI = compI;
                            lastJ = compJ;
                            lastK = compK1;
                        }
                    }
                    else //compK1 != compK2
                    {
                        //k1 coord
                        if ((lastI != compI) || (lastJ != compJ) || (lastK != compK1))
                        {
                            vec3 s1    = this.grid.DataSource.PointFLT(compI, compJ, compK1);
                            vec3 s2    = this.grid.DataSource.PointBRT(compI, compJ, compK1);
                            vec3 point = CenterOfLine(s1, s2);
                            wellPath.Add(point);
                        }
                        lastI = compI;
                        lastJ = compJ;
                        lastK = compK1;

                        if ((lastI != compI) || (lastJ != compJ) || (lastK != compK2))
                        {
                            vec3 s1    = this.grid.DataSource.PointFLT(compI, compJ, compK2);
                            vec3 s2    = this.grid.DataSource.PointBRT(compI, compJ, compK2);
                            vec3 point = CenterOfLine(s1, s2);
                            wellPath.Add(point);
                        }
                        lastI = compI;
                        lastJ = compJ;
                        lastK = compK2;
                    }
                }//end for

                var model = new WellModel(wellPath, wellRadius);
                //NamedWellRenderer renderer = NamedWellRenderer.Create(model, pipeColor, wellspec.WellName, 12);
                WellRenderer wellRenderer = WellRenderer.Create(model);
                wellRenderer.WellColor = pipeColor;
                LabelRenderer labelRenderer = new LabelRenderer(64, 64);
                labelRenderer.Text = wellspec.WellName;
                var result = new CSharpGL.Tuple <WellRenderer, LabelRenderer>(wellRenderer, labelRenderer);
                return(result);
            }
            #endregion
        }