private void toolStripButtonCreateCutFill_Click(object sender, System.EventArgs e) { if (currentRenderGeometry != null) { this.axRenderControl1.ObjectManager.DeleteObject(currentRenderGeometry.Guid); currentRenderGeometry = null; } if (cutrmp != null) { this.axRenderControl1.ObjectManager.DeleteObject(cutrmp.Guid); cutrmp = null; } if (fillrmp != null) { this.axRenderControl1.ObjectManager.DeleteObject(fillrmp.Guid); fillrmp = null; } currentGeometry = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; currentGeometry.SpatialCRS = crs as ISpatialCRS; ISurfaceSymbol sf = new SurfaceSymbol(); sf.Color = System.Drawing.Color.FromArgb(Convert.ToInt32("0x55ffff80", 16)); ICurveSymbol cs = new CurveSymbol(); cs.Color = System.Drawing.Color.FromArgb(Convert.ToInt32("0x55ffff80", 16)); sf.BoundarySymbol = cs; currentRenderGeometry = this.axRenderControl1.ObjectManager.CreateRenderPolygon(currentGeometry as IPolygon, sf, rootId); (currentRenderGeometry as IRenderPolygon).HeightStyle = gviHeightStyle.gviHeightOnTerrain; this.axRenderControl1.InteractMode = gviInteractMode.gviInteractEdit; this.axRenderControl1.ObjectEditor.StartEditRenderGeometry(currentRenderGeometry, gviGeoEditType.gviGeoEditCreator); }
private void DoFillCut() { TerrainAnalyse ta = new TerrainAnalyse(); ta.Processing += OnProcessing; IMultiPolygon CutmPolygon = geoFactory.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon; IMultiPolygon FillmPolygon = geoFactory.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon; double CutVolume = 0; double FillVolume = 0; ta.CalculateCutFill(currentRenderGeometry.GetFdeGeometry() as IPolygon, (double)numSampling.Value, (double)numHeight.Value, ref CutmPolygon, ref FillmPolygon, ref CutVolume, ref FillVolume); if (CutVolume != 0) { ISurfaceSymbol sf = new SurfaceSymbol(); sf.Color = System.Drawing.Color.FromArgb(Convert.ToInt32("0xbbFF0000", 16)); ICurveSymbol cs = new CurveSymbol(); cs.Color = System.Drawing.Color.FromArgb(Convert.ToInt32("0xcc0000cc", 16)); sf.BoundarySymbol = cs; cutrmp = this.axRenderControl1.ObjectManager.CreateRenderMultiPolygon(CutmPolygon, sf, rootId); cutrmp.HeightStyle = gviHeightStyle.gviHeightOnTerrain; txtCutVolume.Text = Math.Round(CutVolume, 4).ToString(); } if (FillVolume != 0) { ISurfaceSymbol sf = new SurfaceSymbol(); sf.Color = System.Drawing.Color.FromArgb(Convert.ToInt32("0xbb0000FF", 16)); ICurveSymbol cs = new CurveSymbol(); cs.Color = System.Drawing.Color.FromArgb(Convert.ToInt32("0xcc0000cc", 16)); sf.BoundarySymbol = cs; fillrmp = this.axRenderControl1.ObjectManager.CreateRenderMultiPolygon(FillmPolygon, sf, rootId); fillrmp.HeightStyle = gviHeightStyle.gviHeightOnTerrain; txtFillVolume.Text = Math.Round(FillVolume, 4).ToString(); } }
private void Calc(IPolygon polygon, double referenceHeight) { if (polygon == null) { return; } polygon.Close(); IGeometryFactory geoFact = new GeometryFactoryClass(); IMultiPolygon cutPolygon = geoFact.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon; IMultiPolygon fillPolygon = geoFact.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon; double cutVolumn = 0.0; double fillVolumn = 0.0; ITerrainAnalyse ta = new TerrainAnalyse(); ta.OnProcessing = _cb; ta.CalculateCutFill(polygon, 0.0, referenceHeight, ref cutPolygon, ref fillPolygon, ref cutVolumn, ref fillVolumn); //double surfaceArea = ta.GetSurfaceArea(polygon, 0.0); //string res = "挖 方 量:" + cutVolumn.ToString("0.000") + " 立方米\r\n填 方 量:" + fillVolumn.ToString("0.000") + " 立方米\r\n" + // "投影面积:" + polygon.Area().ToString("0.000") + " 平方米\r\n地表面积:" + surfaceArea.ToString("0.000") + " 平方米\r\n"; string res = "挖方量:" + cutVolumn.ToString("0.000") + " 立方米\r\n填方量:" + fillVolumn.ToString("0.000") + " 立方米"; if (_label != null) { _label.Text = res; } this.lcInfo.Text = res; if (cutPolygon != null) { SurfaceSymbol ss = new SurfaceSymbol(); ss.Color = 0xffc04000; _rCutPolygon = d3.ObjectManager.CreateRenderMultiPolygon(cutPolygon, ss, d3.ProjectTree.RootID); _rCutPolygon.HeightStyle = gviHeightStyle.gviHeightOnTerrain; if (this.ceCutRegion.Checked) { _rCutPolygon.VisibleMask = gviViewportMask.gviViewAllNormalView; } else { _rCutPolygon.VisibleMask = gviViewportMask.gviViewNone; } } if (fillPolygon != null) { SurfaceSymbol ss = new SurfaceSymbol(); ss.Color = 0xff0000c0; _rFillPolygon = d3.ObjectManager.CreateRenderMultiPolygon(fillPolygon, ss, d3.ProjectTree.RootID); _rFillPolygon.HeightStyle = gviHeightStyle.gviHeightOnTerrain; if (this.ceFillRegion.Checked) { _rFillPolygon.VisibleMask = gviViewportMask.gviViewAllNormalView; } else { _rFillPolygon.VisibleMask = gviViewportMask.gviViewNone; } } }
/// <summary> /// 开挖 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOnProcess_Click(object sender, EventArgs e) { if (cutrmp != null) { this.axRenderControl1.ObjectManager.DeleteObject(cutrmp.Guid); cutrmp = null; } if (fillrmp != null) { this.axRenderControl1.ObjectManager.DeleteObject(fillrmp.Guid); fillrmp = null; } DoFillCut(); }
public static void TestDrawTriMesh(IModelPoint mp, IModel model) { ISurfaceSymbol symbol = (SurfaceSymbol)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("4D5F0624-50A1-43E2-A0EC-A9713CB25608"))); symbol.Color = 0xff0000ff; ICurveSymbol symbol2 = (CurveSymbol)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("E02C69C4-828D-40D5-869D-DAEB189B7F6F"))); symbol2.Color = 0xffff0000; symbol.BoundarySymbol = symbol2; IMultiPolygon multiPolygon = geoFactory.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon; if (multiPolygon != null) { IPolygon geometry = null; IPoint pointValue = null; for (int i = 0; i < model.GroupCount; i++) { IDrawGroup group = model.GetGroup(i); for (int j = 0; j < group.PrimitiveCount; j++) { IDrawPrimitive primitive = group.GetPrimitive(j); for (int k = 0; k < (primitive.IndexArray.Length / 3); k++) { geometry = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; pointValue = geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointValue.X = mp.X + primitive.VertexArray.Array[primitive.IndexArray.Array[k * 3] * 3]; pointValue.Y = mp.Y + primitive.VertexArray.Array[(primitive.IndexArray.Array[k * 3] * 3) + 1]; pointValue.Z = mp.Z + primitive.VertexArray.Array[(primitive.IndexArray.Array[k * 3] * 3) + 2]; geometry.ExteriorRing.AppendPoint(pointValue); pointValue = geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointValue.X = mp.X + primitive.VertexArray.Array[primitive.IndexArray.Array[(k * 3) + 1] * 3]; pointValue.Y = mp.Y + primitive.VertexArray.Array[(primitive.IndexArray.Array[(k * 3) + 1] * 3) + 1]; pointValue.Z = mp.Z + primitive.VertexArray.Array[(primitive.IndexArray.Array[(k * 3) + 1] * 3) + 2]; geometry.ExteriorRing.AppendPoint(pointValue); pointValue = geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointValue.X = mp.X + primitive.VertexArray.Array[primitive.IndexArray.Array[(k * 3) + 2] * 3]; pointValue.Y = mp.Y + primitive.VertexArray.Array[(primitive.IndexArray.Array[(k * 3) + 2] * 3) + 1]; pointValue.Z = mp.Z + primitive.VertexArray.Array[(primitive.IndexArray.Array[(k * 3) + 2] * 3) + 2]; geometry.ExteriorRing.AppendPoint(pointValue); geometry.Close(); multiPolygon.AddGeometry(geometry); } } } IRenderMultiPolygon item = Ocx.ObjectManager.CreateRenderMultiPolygon(multiPolygon, symbol, Ocx.ProjectTree.RootID); item.MaxVisibleDistance = 5000000.0; tmpList.Add(item); } }
private void deleteMPolygon() { this.axRenderControl1.PauseRendering(false); if (boundaryrmpList.Count != 0) { foreach (IRenderMultiPolygon mp in boundaryrmpList) { this.axRenderControl1.ObjectManager.DeleteObject(mp.Guid); } } if (boundaryrmp != null) { this.axRenderControl1.ObjectManager.DeleteObject(boundaryrmp.Guid); boundaryrmp = null; } this.axRenderControl1.ResumeRendering(); }
/// <summary> /// 开始分析 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOnProcess_Click(object sender, EventArgs e) { deleteMPolygon(); ISurfaceSymbol sf = new SurfaceSymbol(); sf.Color = System.Drawing.Color.Red; ICurveSymbol cs = new CurveSymbol(); cs.Color = System.Drawing.Color.Red; sf.BoundarySymbol = cs; boundaryrmp = this.axRenderControl1.ObjectManager.CreateRenderMultiPolygon(DoAnalyse((double)numWaterHEnd.Value), sf, rootId); if (boundaryrmp != null) { boundaryrmp.HeightStyle = gviHeightStyle.gviHeightOnTerrain; } this.txtWaterHNow.Text = this.numWaterHEnd.Value.ToString(); }
private void Clear() { if (_label != null) { d3.ObjectManager.DeleteObject(_label.Guid); _label = null; } if (_rCutPolygon != null) { d3.ObjectManager.DeleteObject(_rCutPolygon.Guid); _rCutPolygon = null; } if (_rFillPolygon != null) { d3.ObjectManager.DeleteObject(_rFillPolygon.Guid); _rFillPolygon = null; } }
public void Clear() { if (this._drawTool != null) { this._drawTool.Close(); } DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } if (this._renderBox != null) { app.Current3DMapControl.ObjectManager.DeleteObject(this._renderBox.Guid); this._renderBox = null; } if (this._renderPolygon != null) { app.Current3DMapControl.ObjectManager.DeleteObject(this._renderPolygon.Guid); this._renderPolygon = null; } }
private void toolStripButtonDeleteHole_Click(object sender, EventArgs e) { if (this.hole != null) { this.axRenderControl1.ObjectManager.DeleteObject(this.hole.Guid); this.hole = null; } if (this.rpolygon != null) { this.axRenderControl1.ObjectManager.DeleteObject(this.rpolygon.Guid); this.rpolygon = null; } if (this.rmpolygon != null) { this.axRenderControl1.ObjectManager.DeleteObject(this.rmpolygon.Guid); this.rmpolygon = null; } if (this.currentRenderGeometry != null) { this.axRenderControl1.ObjectManager.DeleteObject(currentRenderGeometry.Guid); this.currentRenderGeometry = null; } }
private void timer1_Tick(object sender, EventArgs e) { double start = (double)numWaterHStart.Value; double end = (double)numWaterHEnd.Value; double inc = (double)numWaterHInc.Value; if (waterHNow <= end) { //确定水深 if (waterHNow < start) { waterHNow = start; } else { waterHNow = waterHNow + inc; } this.txtWaterHNow.Text = waterHNow.ToString(); //画水面 ISurfaceSymbol sf = new SurfaceSymbol(); sf.Color = System.Drawing.Color.Red; ICurveSymbol cs = new CurveSymbol(); cs.Color = System.Drawing.Color.Blue; sf.BoundarySymbol = cs; boundaryrmp = this.axRenderControl1.ObjectManager.CreateRenderMultiPolygon(DoAnalyse(waterHNow), sf, rootId); if (boundaryrmp != null) { boundaryrmp.HeightStyle = gviHeightStyle.gviHeightOnTerrain; boundaryrmpList.Add(boundaryrmp); } } else { timer1.Stop(); } }
/// <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; }
private void CreateTerrainHole() { try { IGeometry geo = this._drawTool.GetGeo(); if (geo == null) { return; } IPolygon region = geo as IPolygon; region.Close(); IPolygon region2 = geo.Clone2(gviVertexAttribute.gviVertexAttributeNone) as IPolygon; double refheight = d3.Terrain.GetElevation(region2.Centroid.X, region2.Centroid.Y, gviGetElevationType.gviGetElevationFromMemory) - 30; ITerrainHole terrainHole = d3.ObjectManager.CreateTerrainHole(region, d3.ProjectTree.RootID); this._listRGuids.Add(terrainHole.Guid); IPolygon bottom = region.Clone() as IPolygon; for (int i = 0; i < bottom.ExteriorRing.PointCount; i++) { IPoint pointValue = bottom.ExteriorRing.GetPoint(i); pointValue.Z = refheight; bottom.ExteriorRing.UpdatePoint(i, pointValue); } ICurveSymbol cs = new CurveSymbol(); cs.Color = 0x00ffffff; ISurfaceSymbol bottomSS = new SurfaceSymbol(); bottomSS.ImageName = System.Windows.Forms.Application.StartupPath + "\\..\\Resource\\Images\\TerrainHole\\TextureBottom.jpg"; bottomSS.RepeatLengthU = 5; bottomSS.RepeatLengthV = 5; bottomSS.EnableLight = true; bottomSS.BoundarySymbol = cs; IRenderPolygon rBottom = d3.ObjectManager.CreateRenderPolygon(bottom, bottomSS, d3.ProjectTree.RootID); this._listRGuids.Add(rBottom.Guid); IGeometryFactory geoFact = new GeometryFactoryClass(); IMultiPolygon side = geoFact.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon; for (int i = 0; i < region.ExteriorRing.PointCount - 1; i++) { IPolygon gon = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; IPoint pt1 = region.ExteriorRing.GetPoint(i); IPoint pt1temp = pt1.Clone() as IPoint; if (pt1temp.Z < refheight) { pt1temp.Z = refheight; } IPoint pt2 = region.ExteriorRing.GetPoint(i + 1); IPoint pt2temp = pt2.Clone() as IPoint; if (pt2temp.Z < refheight) { pt2temp.Z = refheight; } IPoint pt3 = pt2.Clone() as IPoint; pt3.Z = refheight; IPoint pt4 = pt1.Clone() as IPoint; pt4.Z = refheight; gon.ExteriorRing.AppendPoint(pt1temp); gon.ExteriorRing.AppendPoint(pt2temp); gon.ExteriorRing.AppendPoint(pt3); gon.ExteriorRing.AppendPoint(pt4); gon.Close(); side.AddPolygon(gon); } ISurfaceSymbol sideSS = new SurfaceSymbol(); sideSS.ImageName = System.Windows.Forms.Application.StartupPath + "\\..\\Resource\\Images\\TerrainHole\\TextureSide.jpg"; sideSS.RepeatLengthU = 5; sideSS.RepeatLengthV = 5; sideSS.EnableLight = true; sideSS.BoundarySymbol = cs; IRenderMultiPolygon rSide = d3.ObjectManager.CreateRenderMultiPolygon(side, sideSS, d3.ProjectTree.RootID); this._listRGuids.Add(rSide.Guid); } catch (Exception ex) { } }
private void DrawBox() { try { IPolyline line = this._drawTool.GetGeo() as IPolyline; if (line == null || line.PointCount != 2) { return; } DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } if (this._renderBox != null) { app.Current3DMapControl.ObjectManager.DeleteObject(this._renderBox.Guid); this._renderBox = null; } if (this._renderPolygon != null) { app.Current3DMapControl.ObjectManager.DeleteObject(this._renderPolygon.Guid); this._renderPolygon = null; } double middleZ = (line.StartPoint.Z + line.EndPoint.Z) / 2; double minZ = middleZ + (double)this.seMinHeight.Value; double maxZ = middleZ + (double)this.seMaxHeight.Value; IPoint startPoint = line.StartPoint; IPoint endPoint = line.EndPoint; IEulerAngle ang = app.Current3DMapControl.Camera.GetAimingAngles2(startPoint, endPoint); IEulerAngle angcz = new EulerAngle(); angcz.Set(ang.Heading - 90, ang.Tilt, ang.Roll); IPoint pt1 = app.Current3DMapControl.Camera.GetAimingPoint2(startPoint, angcz, this.tbcClipDis.Value); IPoint pt2 = app.Current3DMapControl.Camera.GetAimingPoint2(endPoint, angcz, this.tbcClipDis.Value); ICRSFactory crsFact = new CRSFactory(); ISpatialCRS crs = crsFact.CreateFromWKT(app.Current3DMapControl.GetCurrentCrsWKT()) as ISpatialCRS; IGeometryFactory geoFact = new GeometryFactoryClass(); IPoint pointb1 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointb1.SpatialCRS = crs; pointb1.SetCoords(startPoint.X, startPoint.Y, minZ, 0, 0); IPoint pointb2 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointb2.SpatialCRS = crs; pointb2.SetCoords(endPoint.X, endPoint.Y, minZ, 0, 0); IPoint pointb3 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointb3.SpatialCRS = crs; pointb3.SetCoords(pt2.X, pt2.Y, minZ, 0, 0); IPoint pointb4 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointb1.SpatialCRS = crs; pointb4.SetCoords(pt1.X, pt1.Y, minZ, 0, 0); IPolygon polygonBottom = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygonBottom.SpatialCRS = crs; polygonBottom.ExteriorRing.AppendPoint(pointb1); polygonBottom.ExteriorRing.AppendPoint(pointb2); polygonBottom.ExteriorRing.AppendPoint(pointb3); polygonBottom.ExteriorRing.AppendPoint(pointb4); IPoint pointt1 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointt1.SpatialCRS = crs; pointt1.SetCoords(startPoint.X, startPoint.Y, maxZ, 0, 0); IPoint pointt2 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointt2.SpatialCRS = crs; pointt2.SetCoords(endPoint.X, endPoint.Y, maxZ, 0, 0); IPoint pointt3 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointt3.SpatialCRS = crs; pointt3.SetCoords(pt2.X, pt2.Y, maxZ, 0, 0); IPoint pointt4 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointt4.SpatialCRS = crs; pointt4.SetCoords(pt1.X, pt1.Y, maxZ, 0, 0); IPolygon polygonTop = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygonTop.SpatialCRS = crs; polygonTop.ExteriorRing.AppendPoint(pointt1); polygonTop.ExteriorRing.AppendPoint(pointt2); polygonTop.ExteriorRing.AppendPoint(pointt3); polygonTop.ExteriorRing.AppendPoint(pointt4); IPolygon polygon1 = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygon1.SpatialCRS = crs; polygon1.ExteriorRing.AppendPoint(pointb1); polygon1.ExteriorRing.AppendPoint(pointb2); polygon1.ExteriorRing.AppendPoint(pointt2); polygon1.ExteriorRing.AppendPoint(pointt1); IPolygon polygon2 = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygon2.SpatialCRS = crs; polygon2.ExteriorRing.AppendPoint(pointb1); polygon2.ExteriorRing.AppendPoint(pointb4); polygon2.ExteriorRing.AppendPoint(pointt4); polygon2.ExteriorRing.AppendPoint(pointt1); IPolygon polygon3 = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygon3.SpatialCRS = crs; polygon3.ExteriorRing.AppendPoint(pointb2); polygon3.ExteriorRing.AppendPoint(pointb3); polygon3.ExteriorRing.AppendPoint(pointt3); polygon3.ExteriorRing.AppendPoint(pointt2); IPolygon polygon4 = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygon4.SpatialCRS = crs; polygon4.ExteriorRing.AppendPoint(pointb3); polygon4.ExteriorRing.AppendPoint(pointb4); polygon4.ExteriorRing.AppendPoint(pointt4); polygon4.ExteriorRing.AppendPoint(pointt3); IMultiPolygon multiPolygon = geoFact.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon; multiPolygon.SpatialCRS = crs; multiPolygon.AddPolygon(polygonBottom); multiPolygon.AddPolygon(polygonTop); //multiPolygon.AddPolygon(polygon1); multiPolygon.AddPolygon(polygon2); multiPolygon.AddPolygon(polygon3); multiPolygon.AddPolygon(polygon4); ISurfaceSymbol ss = new SurfaceSymbolClass(); ss.Color = 0x550000AA; ICurveSymbol cs = new CurveSymbolClass(); cs.Color = 0xff0000AA; ss.BoundarySymbol = cs; this._renderPolygon = app.Current3DMapControl.ObjectManager.CreateRenderPolygon(polygon1, ss, app.Current3DMapControl.ProjectTree.RootID); ISurfaceSymbol ss1 = new SurfaceSymbolClass(); ss1.Color = 0x88FFFFFF; ICurveSymbol cs1 = new CurveSymbolClass(); cs1.Color = 0xffffffff; ss1.BoundarySymbol = cs1; this._renderBox = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolygon(multiPolygon, ss1, app.Current3DMapControl.ProjectTree.RootID); _env = null; _ang = null; _center = null; _env = new EnvelopeClass(); double xdis = Math.Sqrt((pointb1.X - pointb2.X) * (pointb1.X - pointb2.X) + (pointb1.Y - pointb2.Y) * (pointb1.Y - pointb2.Y)) / 2; double ydis = Math.Sqrt((pointb1.X - pointb4.X) * (pointb1.X - pointb4.X) + (pointb1.Y - pointb4.Y) * (pointb1.Y - pointb4.Y)) / 2; _env.MinZ = -ydis; _env.MaxZ = ydis; _env.MinX = -xdis; _env.MaxX = xdis; _env.MinY = -(maxZ - minZ) / 2.0; _env.MaxY = (maxZ - minZ) / 2.0; _center = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); _center.SpatialCRS = crs; _center.X = polygonBottom.Centroid.X; _center.Y = polygonBottom.Centroid.Y; _center.Z = polygon1.Centroid.Z; _ang = new EulerAngleClass(); _ang.Set(angcz.Heading, 0, 0); } catch (Exception ex) { } }
private void DrawControlRegion() { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null || !app.Current3DMapControl.Terrain.IsRegistered) { return; } if (this._renderBox != null) { app.Current3DMapControl.ObjectManager.DeleteObject(this._renderBox.Guid); this._renderBox = null; } IGeometry geo = this._drawTool.GetGeo(); if (geo == null || geo.GeometryType != gviGeometryType.gviGeometryPolygon) { return; } IPolygon polygon = geo as IPolygon; double terrainHeight = 0.0; if (app.Current3DMapControl.Terrain.IsRegistered) { terrainHeight = app.Current3DMapControl.Terrain.GetElevation(polygon.Centroid.X, polygon.Centroid.Y, gviGetElevationType.gviGetElevationFromDatabase); } double height = double.Parse(this.seLimitHeight.Value.ToString()) + terrainHeight; IGeometryFactory geoFact = new GeometryFactoryClass(); IMultiPolygon multiPolygon = geoFact.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon; IPolygon polygonZ = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; for (int i = 0; i < polygon.ExteriorRing.PointCount; i++) { IPoint ptTemp = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); IPoint pt1 = polygon.ExteriorRing.GetPoint(i); ptTemp.X = pt1.X; ptTemp.Y = pt1.Y; ptTemp.Z = height; polygonZ.ExteriorRing.AppendPoint(ptTemp); } multiPolygon.AddPolygon(polygonZ); for (int i = 0; i < polygon.ExteriorRing.PointCount - 1; i++) { IPoint pt0 = polygon.ExteriorRing.GetPoint(i); IPoint pt1 = polygon.ExteriorRing.GetPoint(i + 1); IPoint pt00 = polygonZ.ExteriorRing.GetPoint(i); IPoint pt11 = polygonZ.ExteriorRing.GetPoint(i + 1); IPolygon polygon1 = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygon1.ExteriorRing.AppendPoint(pt0); polygon1.ExteriorRing.AppendPoint(pt1); polygon1.ExteriorRing.AppendPoint(pt11); polygon1.ExteriorRing.AppendPoint(pt00); multiPolygon.AddPolygon(polygon1); } IPoint ptL0 = polygon.ExteriorRing.GetPoint(0); IPoint ptL1 = polygon.ExteriorRing.GetPoint(polygon.ExteriorRing.PointCount - 1); IPoint ptL00 = polygonZ.ExteriorRing.GetPoint(0); IPoint ptL11 = polygonZ.ExteriorRing.GetPoint(polygon.ExteriorRing.PointCount - 1); IPolygon polygon2 = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygon2.ExteriorRing.AppendPoint(ptL00); polygon2.ExteriorRing.AppendPoint(ptL11); polygon2.ExteriorRing.AppendPoint(ptL1); polygon2.ExteriorRing.AppendPoint(ptL0); multiPolygon.AddPolygon(polygon2); ISurfaceSymbol ss1 = new SurfaceSymbolClass(); ss1.Color = 0x88FFFFFF; ICurveSymbol cs1 = new CurveSymbolClass(); cs1.Color = 0xffffffff; ss1.BoundarySymbol = cs1; this._renderBox = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolygon(multiPolygon, ss1, app.Current3DMapControl.ProjectTree.RootID); app.Current3DMapControl.HighlightHelper.Color = 0xAAFF0000; app.Current3DMapControl.HighlightHelper.SetRegion(geo); app.Current3DMapControl.HighlightHelper.MinZ = height; app.Current3DMapControl.HighlightHelper.VisibleMask = 15; }
private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { DevExpress.XtraEditors.Controls.EditorButton btn = e.Button; switch (btn.Caption) { case "定位": DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } int focusedRowHandle = this.gridView1.FocusedRowHandle; if (focusedRowHandle == -1) { return; } DataRow dr = this.gridView1.GetDataRow(focusedRowHandle); if (dr["geo"] != null && dr["Name"] != null && dr["fcName"] != null) { ISurfaceSymbol ss = new SurfaceSymbolClass(); ss.Color = 0xcc00ff00; ICurveSymbol cs = new CurveSymbolClass(); cs.Color = 0xff00ff00; cs.Width = -5; ss.BoundarySymbol = cs; ISimplePointSymbol ps = new SimplePointSymbol(); ps.Size = SystemInfo.Instance.SymbolSize; ps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16); IGeometry objGeo = dr["geo"] as IGeometry; IPoint pt = null; if (objGeo.GeometryType == gviGeometryType.gviGeometryMultiPolyline) { double x = 0; double y = 0; double z = 0; IMultiPolyline mPolyline = objGeo as IMultiPolyline; for (int m = 0; m < mPolyline.GeometryCount; m++) { IPolyline polyline = mPolyline.GetPolyline(m); IPoint pttemp = polyline.Midpoint; x += pttemp.X; y += pttemp.Y; z += pttemp.Z; } x = x / mPolyline.GeometryCount; y = y / mPolyline.GeometryCount; z = z / mPolyline.GeometryCount; pt = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pt.X = x; pt.Y = y; pt.Z = z; IRenderMultiPolyline rMPolyline = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolyline(mPolyline, cs, app.Current3DMapControl.ProjectTree.RootID); rMPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything; rMPolyline.Glow(8000); this._listRender.Add(rMPolyline.Guid); } else if (objGeo.GeometryType == gviGeometryType.gviGeometryMultiPolygon) { double x = 0; double y = 0; double z = 0; IMultiPolygon mPolygon = objGeo as IMultiPolygon; for (int m = 0; m < mPolygon.GeometryCount; m++) { IPolygon polygon = mPolygon.GetPolygon(m); IPoint pttemp = polygon.Centroid; x += pttemp.X; y += pttemp.Y; z += pttemp.Z; } x = x / mPolygon.GeometryCount; y = y / mPolygon.GeometryCount; z = z / mPolygon.GeometryCount; pt = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pt.X = x; pt.Y = y; pt.Z = z; IRenderMultiPolygon rMPolygon = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolygon(mPolygon, ss, app.Current3DMapControl.ProjectTree.RootID); rMPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything; rMPolygon.Glow(8000); this._listRender.Add(rMPolygon.Guid); } else if (objGeo.GeometryType == gviGeometryType.gviGeometryPolyline) { IPolyline polyline = objGeo as IPolyline; pt = polyline.Midpoint; IRenderPolyline rPolyline = app.Current3DMapControl.ObjectManager.CreateRenderPolyline(polyline, cs, app.Current3DMapControl.ProjectTree.RootID); rPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything; rPolyline.Glow(8000); this._listRender.Add(rPolyline.Guid); } else if (objGeo.GeometryType == gviGeometryType.gviGeometryPoint) { IPoint point = objGeo as IPoint; pt = point; IRenderPoint rPoint = app.Current3DMapControl.ObjectManager.CreateRenderPoint(point, ps, app.Current3DMapControl.ProjectTree.RootID); rPoint.Glow(8000); this._listRender.Add(rPoint.Guid); } else if (objGeo.GeometryType == gviGeometryType.gviGeometryPolygon) { IPolygon polygon = objGeo as IPolygon; pt = polygon.Centroid; IRenderPolygon rPolygon = app.Current3DMapControl.ObjectManager.CreateRenderPolygon(polygon, ss, app.Current3DMapControl.ProjectTree.RootID); rPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything; rPolygon.Glow(8000); this._listRender.Add(rPolygon.Guid); } else { return; } ITableLabel tl = DrawTool.CreateTableLabel1(1); tl.TitleText = dr["fcName"].ToString(); tl.SetRecord(0, 0, dr["Name"].ToString()); tl.Position = pt; this._listRender.Add(tl.Guid); app.Current3DMapControl.Camera.FlyToObject(tl.Guid, gviActionCode.gviActionFlyTo); } break; } }
private void GetData() { if (this.cbLayer.SelectedItem == null) { return; } DF3DFeatureClass dffc = this.cbLayer.SelectedItem as DF3DFeatureClass; if (dffc == null) { return; } IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { return; } if (_num > _count || _count == 0) { return; } ISpatialFilter filter = this._filter; filter.ResultBeginIndex = _num - 1; filter.ResultLimit = 1; IFdeCursor cursor = null; IRowBuffer row = null; try { cursor = fc.Search(filter, false); if ((row = cursor.NextRow()) != null) { #region 定位 int geoindex = row.FieldIndex("Geometry"); DF3DApplication app = DF3DApplication.Application; if (geoindex != -1 && !row.IsNull(geoindex) && app != null && app.Current3DMapControl != null) { ISurfaceSymbol ss = new SurfaceSymbolClass(); ss.Color = 0xcc00ff00; ICurveSymbol cs = new CurveSymbolClass(); cs.Color = 0xff00ff00; cs.Width = -5; ss.BoundarySymbol = cs; ISimplePointSymbol ps = new SimplePointSymbol(); ps.Size = SystemInfo.Instance.SymbolSize; ps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16); IGeometry geo = row.GetValue(geoindex) as IGeometry; IPoint ptTL = null; if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolyline) { double x = 0; double y = 0; double z = 0; IMultiPolyline mPolyline = geo as IMultiPolyline; for (int m = 0; m < mPolyline.GeometryCount; m++) { IPolyline polyline = mPolyline.GetPolyline(m); IPoint pttemp = polyline.Midpoint; x += pttemp.X; y += pttemp.Y; z += pttemp.Z; } x = x / mPolyline.GeometryCount; y = y / mPolyline.GeometryCount; z = z / mPolyline.GeometryCount; ptTL = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); ptTL.X = x; ptTL.Y = y; ptTL.Z = z; IRenderMultiPolyline rMPolyline = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolyline(mPolyline, cs, app.Current3DMapControl.ProjectTree.RootID); rMPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything; rMPolyline.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rMPolyline.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(rMPolyline.Guid, gviActionCode.gviActionJump); } else if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolygon) { double x = 0; double y = 0; double z = 0; IMultiPolygon mPolygon = geo as IMultiPolygon; for (int m = 0; m < mPolygon.GeometryCount; m++) { IPolygon polygon = mPolygon.GetPolygon(m); IPoint pttemp = polygon.Centroid; x += pttemp.X; y += pttemp.Y; z += pttemp.Z; } x = x / mPolygon.GeometryCount; y = y / mPolygon.GeometryCount; z = z / mPolygon.GeometryCount; ptTL = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); ptTL.X = x; ptTL.Y = y; ptTL.Z = z; IRenderMultiPolygon rMPolygon = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolygon(mPolygon, ss, app.Current3DMapControl.ProjectTree.RootID); rMPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything; rMPolygon.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rMPolygon.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(rMPolygon.Guid, gviActionCode.gviActionJump); } else if (geo.GeometryType == gviGeometryType.gviGeometryPolyline) { IPolyline polyline = geo as IPolyline; ptTL = polyline.Midpoint; IRenderPolyline rPolyline = app.Current3DMapControl.ObjectManager.CreateRenderPolyline(polyline, cs, app.Current3DMapControl.ProjectTree.RootID); rPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything; rPolyline.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rPolyline.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(rPolyline.Guid, gviActionCode.gviActionJump); } else if (geo.GeometryType == gviGeometryType.gviGeometryPoint) { IPoint point = geo as IPoint; ptTL = point; IRenderPoint rPoint = app.Current3DMapControl.ObjectManager.CreateRenderPoint(point, ps, app.Current3DMapControl.ProjectTree.RootID); rPoint.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rPoint.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(rPoint.Guid, gviActionCode.gviActionJump); } else if (geo.GeometryType == gviGeometryType.gviGeometryPolygon) { IPolygon polygon = geo as IPolygon; ptTL = polygon.Centroid; IRenderPolygon rPolygon = app.Current3DMapControl.ObjectManager.CreateRenderPolygon(polygon, ss, app.Current3DMapControl.ProjectTree.RootID); rPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything; rPolygon.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rPolygon.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(rPolygon.Guid, gviActionCode.gviActionJump); } else if (geo.GeometryType == gviGeometryType.gviGeometryModelPoint) { ptTL = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); IModelPoint mp = geo as IModelPoint; ptTL.X = mp.X; ptTL.Y = mp.Y; ptTL.Z = mp.Z; IModelPointSymbol mps = new ModelPointSymbol(); mps.SetResourceDataSet(fc.FeatureDataSet); IRenderGeometry render = app.Current3DMapControl.ObjectManager.CreateRenderModelPoint(mp, mps, app.Current3DMapControl.ProjectTree.RootID); render.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(render.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(render.Guid, gviActionCode.gviActionJump); } if (ptTL != null) { ITableLabel tl = DrawTool.CreateTableLabel1(1); tl.TitleText = "属性查询"; tl.SetRecord(0, 0, dffc.ToString()); if (ptTL != null) { tl.Position = ptTL; } app.Current3DMapControl.Camera.FlyToObject(tl.Guid, gviActionCode.gviActionFlyTo); app.Current3DMapControl.ObjectManager.DelayDelete(tl.Guid, 8000); } } #endregion FacilityClass facc = dffc.GetFacilityClass(); if (facc == null) { IFieldInfoCollection fiCol = fc.GetFields(); for (int i = 0; i < fiCol.Count; i++) { IFieldInfo fi = fiCol.Get(i); object obj = row.GetValue(i); string str = ""; switch (fi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldUnknown: case gviFieldType.gviFieldGeometry: continue; case gviFieldType.gviFieldFloat: case gviFieldType.gviFieldDouble: double d; if (double.TryParse(obj.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj.ToString(); break; } DataRow dr = this._dtShow.NewRow(); dr["Property"] = string.IsNullOrEmpty(fi.Alias) ? fi.Name : fi.Alias; dr["Value"] = str; this._dtShow.Rows.Add(dr); } } else { List <DFDataConfig.Class.FieldInfo> facFields = facc.FieldInfoCollection; if (facFields != null) { foreach (DFDataConfig.Class.FieldInfo facField in facFields) { if (!facField.CanQuery) { continue; } int index = row.FieldIndex(facField.Name); if (index != -1 && !row.IsNull(index)) { object obj = row.GetValue(index); string str = ""; IFieldInfo fiFC = row.Fields.Get(index); switch (fiFC.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldUnknown: case gviFieldType.gviFieldGeometry: continue; case gviFieldType.gviFieldFloat: case gviFieldType.gviFieldDouble: double d; if (double.TryParse(obj.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj.ToString(); break; } DataRow dr = this._dtShow.NewRow(); dr["Property"] = facField.ToString(); dr["Value"] = str; this._dtShow.Rows.Add(dr); } } } } } } catch (Exception ex) { } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }