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 Well Convert(WellSpecs wellspec, WellCompatCollection wellCompSegments = null) { if (wellspec == null) { return(null); } String wellName = wellspec.WellName; int i = -1; int j = -1; int k = -1; List <WellCompat> wellSegments = null; if (wellCompSegments != null) { wellSegments = wellCompSegments.GetWellSegments(wellName); } if (wellSegments != null && wellSegments.Count > 0) { i = wellSegments[0].PosI; j = wellSegments[0].PosJ; k = wellSegments[0].K1; } else { i = wellspec.Li; j = wellspec.Lj; k = 1; //点集K始终为1. } Vertex minCord = this.gridderSource.FlipTransform * this.gridderSource.SourceActiveBounds.Min; Vertex maxCord = this.gridderSource.FlipTransform * this.gridderSource.SourceActiveBounds.Max; Rectangle3D srcRect = new Rectangle3D(minCord, maxCord); float dx = srcRect.SizeX; float dy = srcRect.SizeY; float dz = srcRect.SizeZ; //井在完井段的第一个点 Vertex pb = this.gridderSource.FlipTransform * this.gridderSource.GetPosition(i, j, k); //well head or heal coordinates Vertex boundMin = srcRect.Min; Vertex boundMax = srcRect.Max; float surfaceZ = srcRect.Max.Z; float bottomZ = srcRect.Min.Z; //井同模型边界的垂直相交点 Vertex modelTop = new Vertex(pb.X, pb.Y, surfaceZ); //模型顶部坐标,垂直于井底坐标 Vertex modelBottom = new Vertex(pb.X, pb.Y, bottomZ); //底到顶的方向 Vertex directVect = modelTop - modelBottom; //井的高度 z的正方向 Vertex direct = directVect; direct.Normalize(); float xyextend = System.Math.Max(dx, dy); //XY平面的最大边长 float extHeight; //延长线段 if (dz < 0.1f * xyextend) //z很小 { extHeight = 0.1f * xyextend; } else if (dz < 0.2f * xyextend) { extHeight = dz * 0.5f; } else if (dz < 0.3f * xyextend) { extHeight = dz * 0.25f; } else if (dz < 0.4f * xyextend) { extHeight = dz * 0.2f; } else { extHeight = 0.2f * dz; } float maxValue = Math.Max(Math.Max(dx, dy), dz); float extraL = extHeight; direct.Normalize(); Vertex head = modelTop + (direct * extraL); float wellRadius; #region decide the well radius if (dx != dy) { float min = Math.Min(dx, dy); float max = Math.Max(dx, dy); if (min > max * 0.75f) { int n = 30; wellRadius = (min / n) * 0.5f; } else if (min >= max * 0.5f) //长方形的模型 { int n = 20; wellRadius = (min / n) * 0.5f; } else if (min >= (max * 0.25)) { int n = 15; wellRadius = (min / n) * 0.5f; } else if (min >= max * 0.16) { int n = 15; wellRadius = (min / n) * 0.5f; } else { int n = 10; wellRadius = (min / n) * 0.5f; } } else { int n = 40; wellRadius = (dx / n) * 0.5f; } #endregion float diameter = Math.Min(dx, dy) * 0.01f;//井的直径 List <Vertex> wellPath = new List <Vertex>(); wellPath.Add(head); wellPath.Add(modelTop); //计算完井段的数据 if (wellSegments != null && wellSegments.Count > 0) { foreach (WellCompat seg in wellSegments) { int posI = seg.PosI; int posJ = seg.PosJ; int posK1 = seg.K1; int posK2 = seg.K2; if (posK1 == posK2) { Vertex pnt = this.gridderSource.FlipTransform * this.gridderSource.GetPosition(posI, posJ, posK1); wellPath.Add(pnt); } else { Vertex pnt = this.gridderSource.FlipTransform * this.gridderSource.GetPosition(posI, posJ, posK1); Vertex pn2 = this.gridderSource.FlipTransform * this.gridderSource.GetPosition(posI, posJ, posK2); wellPath.Add(pnt); } } } Fluid fluid = FluidConverter.Convert(wellspec.Fluid); GLColor pipeColor = this.MapFluidToColor(fluid); Well well3d = new Well(this.camera, wellPath, wellRadius, pipeColor, wellName, null, 16); well3d.ZAxisScale = 1; well3d.Transform = this.gridderSource.ScaleTranslateform; well3d.CreateVisualElements(this.camera); return(well3d); }
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 }