/// <summary> /// 挖洞 /// </summary> /// <param name="polygon"></param> /// <param name="deep"></param> public void DrawTerrainHole(IPolygon polygon, double deep) { if (polygon == null) { return; } IRing ring = polygon.ExteriorRing; if (!ring.IsClosed) { return; } IPoint point0 = ring.GetPoint(0); double lowestPoint = this.axRenderControl1.Terrain.GetElevation(point0.X, point0.Y, gviGetElevationType.gviGetElevationFromDatabase); IPolygon pBottom = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; pBottom.SpatialCRS = crs as ISpatialCRS; for (int i = 0; i < ring.PointCount; i++) { IPoint point = ring.GetPoint(i); point.Z = this.axRenderControl1.Terrain.GetElevation(point.X, point.Y, gviGetElevationType.gviGetElevationFromDatabase); if (point.Z < lowestPoint) { lowestPoint = point.Z; } ring.UpdatePoint(i, point); point = point.Clone2(gviVertexAttribute.gviVertexAttributeZ) as IPoint; pBottom.ExteriorRing.AppendPoint(point); } //b、计算底面 lowestPoint -= deep; for (int jj = 0; jj < pBottom.ExteriorRing.PointCount; jj++) { IPoint point1 = pBottom.ExteriorRing.GetPoint(jj); point1.Z = lowestPoint; pBottom.ExteriorRing.UpdatePoint(jj, point1); } ICurveSymbol cvSymbol = new CurveSymbol(); cvSymbol.Color = System.Drawing.Color.Yellow; ISurfaceSymbol sfside = new SurfaceSymbol(); sfside.BoundarySymbol = cvSymbol; sfside.Color = System.Drawing.Color.BurlyWood; ISurfaceSymbol sfbottom = new SurfaceSymbol(); sfbottom.BoundarySymbol = cvSymbol; sfbottom.Color = System.Drawing.Color.Green; rpolygon = this.axRenderControl1.ObjectManager.CreateRenderPolygon(pBottom, sfbottom, rootId); rpolygon.MaxVisibleDistance = 9999999; IMultiPolygon mpolygon = geoFactory.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon; mpolygon.SpatialCRS = crs as ISpatialCRS; for (int i = 0; i < ring.PointCount - 1; i++) { IPolygon pSide = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; pSide.SpatialCRS = crs as ISpatialCRS; pSide.ExteriorRing.AppendPoint(polygon.ExteriorRing.GetPoint(i)); pSide.ExteriorRing.AppendPoint(pBottom.ExteriorRing.GetPoint(i)); pSide.ExteriorRing.AppendPoint(pBottom.ExteriorRing.GetPoint(i + 1)); pSide.ExteriorRing.AppendPoint(polygon.ExteriorRing.GetPoint(i + 1)); pSide.Close(); mpolygon.AddPolygon(pSide); //renderControl.ObjectManager.CreateRenderPolygon(pSide, sfside); } rmpolygon = this.axRenderControl1.ObjectManager.CreateRenderMultiPolygon(mpolygon, sfside, rootId); rmpolygon.MaxVisibleDistance = 99999999; hole = this.axRenderControl1.ObjectManager.CreateTerrainHole(polygon, rootId); currentRenderGeometry.VisibleMask = gviViewportMask.gviViewNone; }