Example #1
0
        private void 生成地形挖洞ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            myListNode selectNode = this.listView1.SelectedItems[0] as myListNode;

            if (selectNode != null)
            {
                IRenderPolygon rgeo    = selectNode.obj as IRenderPolygon;
                IPolygon       polygon = rgeo.GetFdeGeometry() as IPolygon;

                // 生成带洞polygon,可注释掉
                IEnvelope env    = rgeo.Envelope;
                IRing     ring   = (new GeometryFactory()).CreateGeometry(gviGeometryType.gviGeometryRing, gviVertexAttribute.gviVertexAttributeZ) as IRing;
                IPoint    center = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                center.Position   = env.Center;
                center.SpatialCRS = crs as ISpatialCRS;
                ring.AppendPoint(center);
                center.Y = env.Center.Y - 50;
                ring.AppendPoint(center);
                center.X = env.Center.X + 50;
                ring.AppendPoint(center);
                center.Y = env.Center.Y;
                ring.AppendPoint(center);
                polygon.AddInteriorRing(ring);
                // To here

                ISurfaceSymbol sfbottom = new SurfaceSymbol();
                sfbottom.Color = System.Drawing.Color.Red;
                IRenderPolygon rgeoNew = this.axRenderControl1.ObjectManager.CreateRenderPolygon(polygon, sfbottom, rootId);

                TerrainHoleSettingForm form = new TerrainHoleSettingForm();
                if (form.ShowDialog() == DialogResult.OK)
                {
                    order = form.Order;

                    ITerrainHole hole = this.axRenderControl1.ObjectManager.CreateTerrainHole(polygon, rootId);
                    if (hole != null)
                    {
                        hole.DrawOrder = order;

                        // 添加节点到界面控件上
                        myListNode item = new myListNode(string.Format("TerrainHole_{0}", hole.Guid), TreeNodeType.NT_TerrainHole, hole);
                        item.Checked = true;
                        listView1.Items.Add(item);

                        // 添加节点到界面控件上
                        item         = new myListNode(string.Format("RenderPolygon_{0}", hole.Guid), TreeNodeType.NT_RenderGeomtry, rgeoNew);
                        item.Checked = true;
                        listView1.Items.Add(item);
                    }
                }
            }
        }
Example #2
0
        private void 生成地形编辑ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            myListNode selectNode = this.listView1.SelectedItems[0] as myListNode;

            if (selectNode != null)
            {
                IRenderPolygon rgeo    = selectNode.obj as IRenderPolygon;
                IPolygon       polygon = rgeo.GetFdeGeometry() as IPolygon;

                // 生成带洞polygon,可注释掉
                IEnvelope env    = rgeo.Envelope;
                IRing     ring   = (new GeometryFactory()).CreateGeometry(gviGeometryType.gviGeometryRing, gviVertexAttribute.gviVertexAttributeZ) as IRing;
                IPoint    center = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                center.Position   = env.Center;
                center.SpatialCRS = crs as ISpatialCRS;
                ring.AppendPoint(center);
                center.Y = env.Center.Y - 10;
                ring.AppendPoint(center);
                center.X = env.Center.X + 10;
                ring.AppendPoint(center);
                center.Y = env.Center.Y;
                ring.AppendPoint(center);
                polygon.AddInteriorRing(ring);
                // To here

                ISurfaceSymbol sfbottom = new SurfaceSymbol();
                sfbottom.Color = System.Drawing.Color.Red;
                IRenderPolygon rgeoNew = this.axRenderControl1.ObjectManager.CreateRenderPolygon(polygon, sfbottom, rootId);

                TerrainModifierSettingForm form = new TerrainModifierSettingForm();
                if (form.ShowDialog() == DialogResult.OK)
                {
                    order = form.Order;
                    switch (form.Strtype)
                    {
                    case "用定义了高程的多边形替代相应地形区域中大于多边形高程部分的高程值":
                        mode = gviElevationBehaviorMode.gviElevationBehaviorAbove;
                        break;

                    case "用定义了高程的多边形替代相应地形区域中小于多边形高程部分的高程值":
                        mode = gviElevationBehaviorMode.gviElevationBehaviorBelow;
                        break;

                    case "用定义了高程的多边形替代相应的地形区域的高程值":
                        mode = gviElevationBehaviorMode.gviElevationBehaviorReplace;
                        break;
                    }

                    ITerrainModifier modifier = this.axRenderControl1.ObjectManager.CreateTerrainModifier(polygon, rootId);
                    if (modifier != null)
                    {
                        modifier.DrawOrder         = order;
                        modifier.ElevationBehavior = mode;

                        // 添加节点到界面控件上
                        myListNode item = new myListNode(string.Format("TerrainModifier_{0}", modifier.Guid), TreeNodeType.NT_TerrainModifier, modifier);
                        item.Checked = true;
                        listView1.Items.Add(item);

                        // 添加节点到界面控件上
                        item         = new myListNode(string.Format("RenderPolygon_{0}", modifier.Guid), TreeNodeType.NT_RenderGeomtry, rgeoNew);
                        item.Checked = true;
                        listView1.Items.Add(item);
                    }
                }
            }
        }
Example #3
0
        private void btnConstructMultiPolygon_Click(object sender, EventArgs e)
        {
            if (gfactory == null)
                gfactory = new GeometryFactory();
            multiPolygon = gfactory.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon;
            if (multiPolygon == null)
                return;

            //添加第一个polygon
            IPolygon polygonFirst = gfactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon;
            if (polygonFirst == null)
                return;
            /// 外环顺时针:1-4-3-2-1
            ///  4-------3
            ///  |       |
            ///  |       |
            ///  1-------2
            IRing exteriorRing = polygonFirst.ExteriorRing;
            point = gfactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
            point.SetCoords(0, 0, 0, 0, 1);
            exteriorRing.AppendPoint(point);
            point.SetCoords(0, 200, 0, 0, 2);
            exteriorRing.AppendPoint(point);
            point.SetCoords(100, 200, 0, 0, 3);
            exteriorRing.AppendPoint(point);           
            point.SetCoords(100, 0, 0, 0, 4);
            exteriorRing.AppendPoint(point);
            point.SetCoords(0, 0, 0, 0, 5);
            exteriorRing.AppendPoint(point);  //闭合
            /// 内环逆时针:1-2-3-4-1
            ///  4-------3
            ///  |       |
            ///  |       |
            ///  1-------2
            IRing interiorRing = gfactory.CreateGeometry(gviGeometryType.gviGeometryRing, gviVertexAttribute.gviVertexAttributeZ) as IRing;
            point.SetCoords(25, 25, 0, 0, 1);
            interiorRing.AppendPoint(point);
            point.SetCoords(75, 25, 0, 0, 2);
            interiorRing.AppendPoint(point);
            point.SetCoords(75, 75, 0, 0, 3);
            interiorRing.AppendPoint(point);
            point.SetCoords(25, 75, 0, 0, 4);
            interiorRing.AppendPoint(point);
            point.SetCoords(25, 25, 0, 0, 5);
            interiorRing.AppendPoint(point);  //闭合
            polygonFirst.AddInteriorRing(interiorRing);

            //Clone一个新的内环
            IRing pInteriorRingNew = interiorRing.Clone() as IRing;
            polygonFirst.AddInteriorRing(pInteriorRingNew);
            multiPolygon.AddPolygon(polygonFirst);

            //Clone一个新的polygon
            IPolygon pPolygonNew = polygonFirst.Clone() as IPolygon;
            multiPolygon.AddPolygon(pPolygonNew);

            MultiSurface geo = new MultiSurface();
            // Geometry属性
            geo.Dimension = multiPolygon.Dimension;
            if (multiPolygon.Envelope != null)
            {
                geo.MaxX = multiPolygon.Envelope.MaxX;
                geo.MaxY = multiPolygon.Envelope.MaxY;
                geo.MaxZ = multiPolygon.Envelope.MaxZ;
                geo.MinX = multiPolygon.Envelope.MinX;
                geo.MinY = multiPolygon.Envelope.MinY;
                geo.MinZ = multiPolygon.Envelope.MinZ;
            }
            geo.GeometryType = multiPolygon.GeometryType;
            geo.IsEmpty = multiPolygon.IsEmpty;
            geo.IsValid = multiPolygon.IsValid;
            geo.VertexAttribute = multiPolygon.VertexAttribute;
            geo.HasId = multiPolygon.HasId();
            geo.HasM = multiPolygon.HasM();
            geo.HasZ = multiPolygon.HasZ();
            // GeometryCollection属性
            geo.GeometryCount = multiPolygon.GeometryCount;
            geo.IsOverlap = multiPolygon.IsOverlap;
            // MultiSurface属性
            geo.Area = multiPolygon.GetArea();

            this.propertyGrid1.SelectedObject = geo;
        }
Example #4
0
        private void btnConstructPolygon_Click(object sender, EventArgs e)
        {
            if (gfactory == null)
                gfactory = new GeometryFactory();
            polygon = gfactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZM) as IPolygon;
            if (polygon == null)
                return;

            /// 外环顺时针:1-4-3-2-1
            ///  4-------3
            ///  |       |
            ///  |       |
            ///  1-------2
            IRing exteriorRing = polygon.ExteriorRing;
            point = gfactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZM);
            point.SetCoords(0, 0, 0, 0, 1);
            exteriorRing.AppendPoint(point);
            point.SetCoords(0, 200, 0, 0, 2);
            exteriorRing.AppendPoint(point);
            point.SetCoords(100, 200, 0, 0, 3);
            exteriorRing.AppendPoint(point);
            point.SetCoords(100, 0, 0, 0, 4);
            exteriorRing.AppendPoint(point);
            point.SetCoords(0, 0, 0, 0, 5);
            exteriorRing.AppendPoint(point);  //闭合

            /// 内环逆时针:1-2-3-4-1
            ///  4-------3
            ///  |       |
            ///  |       |
            ///  1-------2
            IRing interiorRing1 = gfactory.CreateGeometry(gviGeometryType.gviGeometryRing, gviVertexAttribute.gviVertexAttributeZM) as IRing;
            IRing interiorRing2 = gfactory.CreateGeometry(gviGeometryType.gviGeometryRing, gviVertexAttribute.gviVertexAttributeZM) as IRing;
            point.SetCoords(25, 25, 0, 0, 1);
            interiorRing1.AppendPoint(point);
            point.SetCoords(75, 25, 0, 0, 2);
            interiorRing1.AppendPoint(point);
            point.SetCoords(75, 75, 0, 0, 3);
            interiorRing1.AppendPoint(point);
            point.SetCoords(25, 75, 0, 0, 4);
            interiorRing1.AppendPoint(point);
            point.SetCoords(25, 25, 0, 0, 5);
            interiorRing1.AppendPoint(point);  //闭合

            point.SetCoords(5, 6, 0, 8, 6);
            interiorRing2.AppendPoint(point);
            point.SetCoords(2, 3, 0, 5, 7);
            interiorRing2.AppendPoint(point);
            point.SetCoords(1, 1, 0, 1, 8);
            interiorRing2.AppendPoint(point);
            point.SetCoords(5, 6, 0, 8, 9);
            interiorRing2.AppendPoint(point);

            polygon.AddInteriorRing(interiorRing1);
            polygon.AddInteriorRing(interiorRing2);

            Polygon geo = new Polygon();
            // Geometry属性
            geo.Dimension = polygon.Dimension;
            if (polygon.Envelope != null)
            {
                geo.MaxX = polygon.Envelope.MaxX;
                geo.MaxY = polygon.Envelope.MaxY;
                geo.MaxZ = polygon.Envelope.MaxZ;
                geo.MinX = polygon.Envelope.MinX;
                geo.MinY = polygon.Envelope.MinY;
                geo.MinZ = polygon.Envelope.MinZ;
            }
            geo.GeometryType = polygon.GeometryType;
            geo.IsEmpty = polygon.IsEmpty;
            geo.IsValid = polygon.IsValid;
            geo.VertexAttribute = polygon.VertexAttribute;
            geo.HasId = polygon.HasId();
            geo.HasM = polygon.HasM();
            geo.HasZ = polygon.HasZ();
            // Surface属性
            geo.Area = polygon.Area();
            if (polygon.Centroid != null)
            {
                geo.CentroidX = polygon.Centroid.X;
                geo.CentroidY = polygon.Centroid.Y;
                geo.CentroidZ = polygon.Centroid.Z;
            }
            geo.IsClosed = polygon.IsClosed;
            if (polygon.PointOnSurface != null)
            {
                geo.PointOnSurfaceX = polygon.PointOnSurface.X;
                geo.PointOnSurfaceY = polygon.PointOnSurface.Y;
                geo.PointOnSurfaceZ = polygon.PointOnSurface.Z;
            }
            // SurfacePatch属性
            geo.SurfaceInterpolationType = polygon.SurfaceInterpolationType;
            // Polygon属性
            geo.InteriorRingCount = polygon.InteriorRingCount;
            geo.IsCoplanar = polygon.IsCoplanar;

            this.propertyGrid1.SelectedObject = geo;
        }