Ejemplo n.º 1
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            //获取水源点
            waterPoint = IntersectPoint;
            //设置参数
            this.numWaterHStart.Value = (decimal)IntersectPoint.Z;
            this.numWaterHEnd.Value   = (decimal)(IntersectPoint.Z + 30);
            //获取缓冲区bufPolygon\renderBufPolygon
            radius = (double)numBufferRadius.Value;
            ITopologicalOperator2D to = waterPoint as ITopologicalOperator2D;

            bufPolygon = to.Buffer2D(radius, gviBufferStyle.gviBufferCapround) as IPolygon;
            ISurfaceSymbol sf = new SurfaceSymbol();

            sf.Color = System.Drawing.Color.Yellow;
            ICurveSymbol cs = new CurveSymbol();

            cs.Color                     = System.Drawing.Color.Yellow;
            sf.BoundarySymbol            = cs;
            renderBufPolygon             = this.axRenderControl1.ObjectManager.CreateRenderPolygon(bufPolygon, sf, rootId);
            renderBufPolygon.HeightStyle = gviHeightStyle.gviHeightOnTerrain;

            this.axRenderControl1.InteractMode        = gviInteractMode.gviInteractNormal;
            this.axRenderControl1.RcMouseClickSelect -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect);

            this.btnOnProcess.Enabled = true;
            this.btnSimulate.Enabled  = true;
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            newRender = new SimpleGeometryRender();
            newRender.RenderGroupField = this.comboBox1.Text;

            ICurveSymbol newSymbol = new CurveSymbol();

            if (this.dataGridView2.Rows[0].Cells[1].Value.ToString() != "")
            {
                string colstr = this.dataGridView2.Rows[0].Cells[1].Value.ToString();
                Color  col    = Utils.HexNumberToColor(colstr);
                newSymbol.Color = col;
            }
            if (this.dataGridView2.Rows[1].Cells[1].Value.ToString() != "")
            {
                newSymbol.RepeatLength = float.Parse(this.dataGridView2.Rows[1].Cells[1].Value.ToString());
            }
            if (this.dataGridView2.Rows[2].Cells[1].Value.ToString() != "")
            {
                newSymbol.Width = float.Parse(this.dataGridView2.Rows[2].Cells[1].Value.ToString());
            }

            if (this.checkBox1.Checked)
            {
                newSymbol.ImageName = this.textBoxPicturePath.Text;
            }
            else
            {
                newSymbol.ImageName = this.textBoxPictureName.Text;
            }

            newRender.Symbol = newSymbol;
        }
Ejemplo n.º 4
0
        private void drawTempLine(INetworkRoute route)
        {
            // 画出停靠点到映射点的虚线
            int segmentCount                   = route.SegmentCount;
            INetworkRouteSegment segment       = null;
            INetworkLocation     startLocation = null;
            INetworkLocation     endLocation   = null;
            IPoint       pointOnNetwork        = null;
            ICurveSymbol tmpLineSym            = new CurveSymbol();

            tmpLineSym.Color = System.Drawing.Color.Yellow;
            tmpLineSym.Width = -2;
            for (int i = 0; i < segmentCount; i++)
            {
                segment        = route.GetSegment(i);
                startLocation  = segment.StartLocation;
                pointOnNetwork = startLocation.NetworkPosition;
                fdepoint       = startLocation.Position;
                IPolyline tmpLine = geoFac.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;
                tmpLine.AppendPoint(fdepoint);
                tmpLine.AppendPoint(pointOnNetwork);
                tmpRenderLineArray.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(tmpLine, tmpLineSym, rootId));
                if (i == segmentCount - 1)
                {
                    endLocation    = segment.EndLocation;
                    pointOnNetwork = endLocation.NetworkPosition;
                    fdepoint       = endLocation.Position;
                    tmpLine        = geoFac.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;
                    tmpLine.AppendPoint(fdepoint);
                    tmpLine.AppendPoint(pointOnNetwork);
                    tmpRenderLineArray.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(tmpLine, tmpLineSym, rootId));
                }
            }
        }
Ejemplo n.º 5
0
        private void btnBuildRoute_Click(object sender, System.EventArgs e)
        {
            clear();
            this.axRenderControl1.RcMouseClickSelect -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect);

            this.axRenderControl1.InteractMode = gviInteractMode.gviInteractNormal;

            switch (cbOrderPolicy.SelectedIndex)
            {
            case 0:
                routeSolver.LocationOrderPolicy = gviNetworkLocationOrderPolicy.gviSequence;
                break;

            case 1:
                routeSolver.LocationOrderPolicy = gviNetworkLocationOrderPolicy.gviFixStart;
                break;

            case 2:
                routeSolver.LocationOrderPolicy = gviNetworkLocationOrderPolicy.gviFixStartAndReturn;
                break;

            case 3:
                routeSolver.LocationOrderPolicy = gviNetworkLocationOrderPolicy.gviFixStartEnd;
                break;

            case 4:
                routeSolver.LocationOrderPolicy = gviNetworkLocationOrderPolicy.gviFree;
                break;
            }
            if (routeSolver.Solve())
            {
                INetworkRoute route = routeSolver.GetRoute();
                if (route != null)
                {
                    ICurveSymbol lineSym = new CurveSymbol();
                    lineSym.Color = System.Drawing.Color.Yellow;
                    lineSym.Width = -2;
                    IGeometry geo = route.GetRouteGeometry();
                    if (geo.GeometryType == gviGeometryType.gviGeometryPolyline)
                    {
                        IPolyline line = geo as IPolyline;
                        renderLine = this.axRenderControl1.ObjectManager.CreateRenderPolyline(line, lineSym, rootId);
                        renderLine.MaxVisibleDistance = 10000;
                    }
                    else if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolyline)
                    {
                        IMultiPolyline line = geo as IMultiPolyline;
                        multiRenderLine = this.axRenderControl1.ObjectManager.CreateRenderMultiPolyline(line, lineSym, rootId);
                        multiRenderLine.MaxVisibleDistance = 10000;
                    }
                    btnNavigate.Enabled = true;

                    drawTempLine(route);
                }
            }
            else
            {
                MessageBox.Show("查找路径失败");
            }
        }
Ejemplo n.º 6
0
        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();
            }
        }
Ejemplo n.º 7
0
        public PolylineRenderForm(IGeometryRender geoRender, object[] fieldNamesItems)
        {
            InitializeComponent();

            {
                this.comboBox1.Items.AddRange(fieldNamesItems);
                this.comboBox1.Text = "";

                if (geoRender != null)
                {
                    int index = Utils.getIndexFromItems(fieldNamesItems, geoRender.RenderGroupField);
                    this.comboBox1.SelectedIndex = index;
                }
            }

            ISimpleGeometryRender render = geoRender as ISimpleGeometryRender;

            if (render == null || render.Symbol == null)
            {
                ICurveSymbol tmpSymbol = new CurveSymbol();
                string[]     row1      = new string[] { "Color", tmpSymbol.Color.ToString() };
                string[]     row2      = new string[] { "RepeatLength", tmpSymbol.RepeatLength.ToString() };
                string[]     row3      = new string[] { "Width", tmpSymbol.Width.ToString() };
                object[]     rows      = new object[] { row1, row2, row3 };
                foreach (string[] rowArray in rows)
                {
                    this.dataGridView2.Rows.Add(rowArray);
                }
                this.textBoxPictureName.Text = "";
                return;
            }

            if (render.Symbol == null)
            {
                this.textBoxPictureName.Text = "";
                return;
            }

            {
                ICurveSymbol symbol = render.Symbol as ICurveSymbol;
                string[]     row1   = new string[] { "Color", symbol.Color.ToString() };
                string[]     row2   = new string[] { "RepeatLength", symbol.RepeatLength.ToString() };
                string[]     row3   = new string[] { "Width", symbol.Width.ToString() };
                object[]     rows   = new object[] { row1, row2, row3 };
                foreach (string[] rowArray in rows)
                {
                    this.dataGridView2.Rows.Add(rowArray);
                }

                this.textBoxPicturePath.Text = symbol.ImageName;
                this.textBoxPictureName.Text = symbol.ImageName;
            }
        }
Ejemplo n.º 8
0
        private void toolStripButtonCreateRenderArrow_Click(object sender, System.EventArgs e)
        {
            currentGeometry            = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;
            currentGeometry.SpatialCRS = crs as ISpatialCRS;

            ICurveSymbol curveSym = new CurveSymbol();

            curveSym.Width        = -2;
            curveSym.Color        = System.Drawing.Color.Red;
            currentRenderGeometry = this.axRenderControl1.ObjectManager.CreateRenderPolyline(currentGeometry as IPolyline, curveSym, rootId);
            (currentRenderGeometry as IRenderPolyline).HeightStyle = gviHeightStyle.gviHeightOnTerrain;
            this.axRenderControl1.InteractMode = gviInteractMode.gviInteractEdit;
            this.axRenderControl1.ObjectEditor.StartEditRenderGeometry(currentRenderGeometry, gviGeoEditType.gviGeoEditCreator);
        }
Ejemplo n.º 9
0
        private void LoadDynamicObjectAndLineFromFile()
        {
            ICameraTour tour     = null;
            string      tourPath = (strMediaPath + @"\xml\CameraTour_2.xml");

            if (File.Exists(tourPath))
            {
                StreamReader sr        = new StreamReader(tourPath);
                string       xmlstring = sr.ReadToEnd();
                sr.Close();
                tour = this.axRenderControl1.ObjectManager.CreateCameraTour(rootId);
                tour.FromXml(xmlstring);
            }
            if (tour == null)
            {
                MessageBox.Show("xml文件读取失败");
            }

            dynamicObject.CrsWKT = tour.CrsWKT;
            point.SpatialCRS     = new CRSFactory().CreateFromWKT(tour.CrsWKT) as ISpatialCRS;
            line.SpatialCRS      = new CRSFactory().CreateFromWKT(tour.CrsWKT) as ISpatialCRS;

            for (int i = 0; i < tour.WaypointsNumber; i++)
            {
                double            duration;
                gviCameraTourMode mode;
                tour.GetWaypoint(i, out position, out angle, out duration, out mode);
                dynamicObject.AddWaypoint(position, 10);

                point.Position = position;
                if (line.PointCount == 0)
                {
                    line.StartPoint = point;
                }
                else
                {
                    line.AddPointAfter(i - 1, point);
                }
            }

            ICurveSymbol cur = new CurveSymbol();

            cur.Color = System.Drawing.Color.Yellow;
            cur.Width = -2;
            rline     = this.axRenderControl1.ObjectManager.CreateRenderPolyline(line, cur, rootId);
        }
Ejemplo n.º 10
0
        private void LoadMotionPathAndLineFromFile()
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(Application.StartupPath + @"MotionPath.xml");
            wkt = xmlDoc.SelectSingleNode("root/WKT").InnerText;
            // 指定坐标系与xml里的相同
            motionPath.CrsWKT = xmlDoc.SelectSingleNode("root/WKT").InnerText;
            point.SpatialCRS  = new CRSFactory().CreateFromWKT(motionPath.CrsWKT) as ISpatialCRS;
            line.SpatialCRS   = new CRSFactory().CreateFromWKT(motionPath.CrsWKT) as ISpatialCRS;

            XmlNodeList nodes = xmlDoc.SelectNodes("root/Waypoint");
            int         i     = 0;

            foreach (XmlNode node in nodes)
            {
                double x       = double.Parse(node.SelectSingleNode("X").InnerText);
                double y       = double.Parse(node.SelectSingleNode("Y").InnerText);
                double z       = double.Parse(node.SelectSingleNode("Z").InnerText);
                double heading = double.Parse(node.SelectSingleNode("Heading").InnerText);
                double tilt    = double.Parse(node.SelectSingleNode("Tilt").InnerText);
                double roll    = double.Parse(node.SelectSingleNode("Roll").InnerText);
                double when    = double.Parse(node.SelectSingleNode("When").InnerText);
                position.Set(x, y, z);
                point.Position = position;
                if (line.PointCount == 0)
                {
                    line.StartPoint = point;
                }
                else
                {
                    line.AddPointAfter(i - 1, point);
                }
                i++;
                angle.Set(heading, tilt, roll);
                scale.Set(1, 1, 1);
                motionPath.AddWaypoint2(point, angle, scale, when);
                this.axRenderControl1.ObjectManager.CreateRenderPoint(point, null, rootId);
            }

            ICurveSymbol cur = new CurveSymbol();

            cur.Color = System.Drawing.Color.Red;
            cur.Width = -2;
            rline     = this.axRenderControl1.ObjectManager.CreateRenderPolyline(line, cur, rootId);
        }
Ejemplo n.º 11
0
        /// <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();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 鼠标点击 拾取线段点
        /// </summary>
        /// <param name="PickResult"></param>
        /// <param name="IntersectPoint"></param>
        /// <param name="Mask"></param>
        /// <param name="EventSender"></param>
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            if (IntersectPoint == null)
            {
                return;
            }

            if (renderPolyline == null)
            {
                ICurveSymbol cs = new CurveSymbol();
                cs.Color       = System.Drawing.Color.Yellow;
                cs.Width       = -5;
                renderPolyline = this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cs, rootId);
            }

            if (polyline.PointCount < 2)
            {
                polyline.AppendPoint(IntersectPoint);
            }
            if (polyline.PointCount == 2)
            {
                this.axRenderControl1.InteractMode          = gviInteractMode.gviInteractNormal;
                this.axRenderControl1.MouseSelectObjectMask = gviMouseSelectObjectMask.gviSelectNone;
                this.axRenderControl1.MouseSelectMode       = gviMouseSelectMode.gviMouseSelectClick;
                this.axRenderControl1.RcMouseClickSelect   -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect);

                IPoint p = polyline.StartPoint;
                this.startX.Text = p.X.ToString();
                this.startY.Text = p.Y.ToString();
                this.startZ.Text = p.Z.ToString();
                p = polyline.EndPoint;
                this.endX.Text   = p.X.ToString();
                this.endY.Text   = p.Y.ToString();
                this.endZ.Text   = p.Z.ToString();
                flagx            = false;
                this.label7.Text = "线构造成功!请点击“通视分析”按钮";
                this.btnFlyToSourcePoint.Enabled = true;
                this.btnFlyToTargetPoint.Enabled = true;
            }
            renderPolyline.SetFdeGeometry(polyline);
        }
Ejemplo n.º 13
0
        private void toolStripButtonCreatePolygon_Click(object sender, System.EventArgs e)
        {
            //创建日志文件
            Logger.Create(Application.StartupPath);

            if (renderpolygonDraw != null)
            {
                this.axRenderControl1.ObjectManager.DeleteObject(renderpolygonDraw.Guid);
                renderpolygonDraw = null;
            }

            polygonDraw            = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon;
            polygonDraw.SpatialCRS = crs as ISpatialCRS;
            ISurfaceSymbol sf = new SurfaceSymbol();

            sf.Color = Color.FromArgb(Convert.ToInt32("0x55ffff80", 16));
            ICurveSymbol cs = new CurveSymbol();

            cs.Color          = Color.FromArgb(Convert.ToInt32("0x55ffff80", 16));
            sf.BoundarySymbol = cs;
            renderpolygonDraw = this.axRenderControl1.ObjectManager.CreateRenderPolygon(polygonDraw as IPolygon, sf, rootId);
            this.axRenderControl1.InteractMode = gviInteractMode.gviInteractEdit;
            this.axRenderControl1.ObjectEditor.StartEditRenderGeometry(renderpolygonDraw, gviGeoEditType.gviGeoEditCreator);
        }
Ejemplo n.º 14
0
        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();
            }
        }
Ejemplo n.º 15
0
        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)
            {
            }
        }
Ejemplo n.º 16
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            newRender = new SimpleGeometryRender();
            newRender.RenderGroupField = this.comboBox1.Text;

            ISurfaceSymbol newSurfaceSymbol  = new SurfaceSymbol();
            ICurveSymbol   newBoundarySymbol = new CurveSymbol();

            if (this.dataGridView2.Rows[0].Cells[1].Value.ToString() != "")
            {
                string colstr = this.dataGridView2.Rows[0].Cells[1].Value.ToString();
                Color  col    = Utils.HexNumberToColor(colstr);
                newSurfaceSymbol.Color = col;
            }
            if (this.dataGridView2.Rows[1].Cells[1].Value.ToString() != "")
            {
                newSurfaceSymbol.EnableLight = this.dataGridView2.Rows[1].Cells[1].Value.ToString().ToLower() == "true" ? true : false;
            }
            if (this.dataGridView2.Rows[2].Cells[1].Value.ToString() != "")
            {
                newSurfaceSymbol.RepeatLengthU = float.Parse(this.dataGridView2.Rows[2].Cells[1].Value.ToString());
            }
            if (this.dataGridView2.Rows[3].Cells[1].Value.ToString() != "")
            {
                newSurfaceSymbol.RepeatLengthV = float.Parse(this.dataGridView2.Rows[3].Cells[1].Value.ToString());
            }
            if (this.dataGridView2.Rows[4].Cells[1].Value.ToString() != "")
            {
                newSurfaceSymbol.Rotation = float.Parse(this.dataGridView2.Rows[4].Cells[1].Value.ToString());
            }
            if (this.dataGridView2.Rows[5].Cells[1].Value.ToString() != "")
            {
                string colstr = this.dataGridView2.Rows[5].Cells[1].Value.ToString();
                Color  col    = Utils.HexNumberToColor(colstr);
                newBoundarySymbol.Color = col;
            }
            if (this.dataGridView2.Rows[6].Cells[1].Value.ToString() != "")
            {
                newBoundarySymbol.RepeatLength = float.Parse(this.dataGridView2.Rows[6].Cells[1].Value.ToString());
            }
            if (this.dataGridView2.Rows[7].Cells[1].Value.ToString() != "")
            {
                newBoundarySymbol.Width = float.Parse(this.dataGridView2.Rows[7].Cells[1].Value.ToString());
            }

            if (this.checkBoxSurface.Checked)
            {
                newSurfaceSymbol.ImageName = this.textBoxSurfacePicturePath.Text;
            }
            else
            {
                newSurfaceSymbol.ImageName = this.textBoxSurfacePictureName.Text;
            }

            if (this.checkBoxCurve.Checked)
            {
                newBoundarySymbol.ImageName = this.textBoxCurvePicturePath.Text;
            }
            else
            {
                newBoundarySymbol.ImageName = this.textBoxCurvePictureName.Text;
            }

            newSurfaceSymbol.BoundarySymbol = newBoundarySymbol;
            newRender.Symbol = newSurfaceSymbol;
        }
Ejemplo n.º 17
0
        public PolygonRenderForm(IGeometryRender geoRender, object[] fieldNamesItems)
        {
            InitializeComponent();

            {
                this.comboBox1.Items.AddRange(fieldNamesItems);
                this.comboBox1.Text = "";

                if (geoRender != null)
                {
                    int index = Utils.getIndexFromItems(fieldNamesItems, geoRender.RenderGroupField);
                    this.comboBox1.SelectedIndex = index;
                }
            }

            ISimpleGeometryRender render = geoRender as ISimpleGeometryRender;

            if (render == null || render.Symbol == null)
            {
                ISurfaceSymbol tmpSurfaceSymbol = new SurfaceSymbol();
                string[]       row1             = new string[] { "Color", tmpSurfaceSymbol.Color.ToString() };
                string[]       row2             = new string[] { "EnableLight", tmpSurfaceSymbol.EnableLight.ToString() };
                string[]       row3             = new string[] { "RepeatLengthU", tmpSurfaceSymbol.RepeatLengthU.ToString() };
                string[]       row4             = new string[] { "RepeatLengthV", tmpSurfaceSymbol.RepeatLengthV.ToString() };
                string[]       row5             = new string[] { "Rotation", tmpSurfaceSymbol.Rotation.ToString() };
                ICurveSymbol   tmpCurveSymbol   = new CurveSymbol();
                string[]       row6             = new string[] { "BoundaryColor", tmpCurveSymbol.Color.ToString() };
                string[]       row7             = new string[] { "RepeatLength", tmpCurveSymbol.RepeatLength.ToString() };
                string[]       row8             = new string[] { "Width", tmpCurveSymbol.Width.ToString() };
                object[]       rows             = new object[] { row1, row2, row3, row4, row5, row6, row7, row8 };
                foreach (string[] rowArray in rows)
                {
                    this.dataGridView2.Rows.Add(rowArray);
                }
                return;
            }

            if (render.Symbol == null)
            {
                this.textBoxSurfacePictureName.Text = "";
                return;
            }

            {
                ISurfaceSymbol surfaceSymbol  = render.Symbol as ISurfaceSymbol;
                ICurveSymbol   boundarySymbol = surfaceSymbol.BoundarySymbol as ICurveSymbol;
                if (boundarySymbol != null)
                {
                    string[] row1  = new string[] { "Color", surfaceSymbol.Color.ToString() };
                    string[] row2  = new string[] { "EnableLight", surfaceSymbol.EnableLight.ToString() };
                    string[] row3  = new string[] { "RepeatLengthU", surfaceSymbol.RepeatLengthU.ToString() };
                    string[] row4  = new string[] { "RepeatLengthV", surfaceSymbol.RepeatLengthV.ToString() };
                    string[] row5  = new string[] { "Rotation", surfaceSymbol.Rotation.ToString() };
                    string[] row6  = new string[] { "BoundaryColor", boundarySymbol.Color.ToString() };
                    string[] row7  = new string[] { "RepeatLength", boundarySymbol.RepeatLength.ToString() };
                    string[] row8  = new string[] { "Width", boundarySymbol.Width.ToString() };
                    object[] rows2 = new object[] { row1, row2, row3, row4, row5, row6, row7, row8 };
                    foreach (string[] rowArray in rows2)
                    {
                        this.dataGridView2.Rows.Add(rowArray);
                    }
                    this.textBoxCurvePictureName.Text = boundarySymbol.ImageName;
                    this.textBoxCurvePicturePath.Text = boundarySymbol.ImageName;
                }
                else
                {
                    ICurveSymbol boundarySymbolNew = new CurveSymbol();
                    string[]     row1  = new string[] { "Color", surfaceSymbol.Color.ToString() };
                    string[]     row2  = new string[] { "EnableLight", surfaceSymbol.EnableLight.ToString() };
                    string[]     row3  = new string[] { "RepeatLengthU", surfaceSymbol.RepeatLengthU.ToString() };
                    string[]     row4  = new string[] { "RepeatLengthV", surfaceSymbol.RepeatLengthV.ToString() };
                    string[]     row5  = new string[] { "Rotation", surfaceSymbol.Rotation.ToString() };
                    string[]     row6  = new string[] { "BoundaryColor", boundarySymbolNew.Color.ToString() };
                    string[]     row7  = new string[] { "RepeatLength", boundarySymbolNew.RepeatLength.ToString() };
                    string[]     row8  = new string[] { "Width", boundarySymbolNew.Width.ToString() };
                    object[]     rows2 = new object[] { row1, row2, row3, row4, row5, row6, row7, row8 };
                    foreach (string[] rowArray in rows2)
                    {
                        this.dataGridView2.Rows.Add(rowArray);
                    }
                    this.textBoxCurvePictureName.Text = "";
                    this.textBoxCurvePicturePath.Text = "";
                }

                this.textBoxSurfacePictureName.Text = surfaceSymbol.ImageName;
                this.textBoxSurfacePicturePath.Text = surfaceSymbol.ImageName;
            }
        }
Ejemplo n.º 18
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            try
            {
                if (PickResult != null)
                {
                    if (PickResult.Type == gviObjectType.gviObjectFeatureLayer)
                    {
                        IFeatureLayerPickResult flpr = PickResult as IFeatureLayerPickResult;
                        int fid = flpr.FeatureId;
                        this.axRenderControl1.FeatureManager.HighlightFeature(_featureClass, fid, System.Drawing.Color.Yellow);

                        //////////////////////////////////////////////////////////////////////////
                        //
                        //  GeometryConvert的代码添加在这里
                        //
                        //////////////////////////////////////////////////////////////////////////
                        fidList.Clear();
                        fidList.Add(fid);
                        IRowBuffer rowGC = _featureClass.GetRow(fidList[0]);

                        int nPose = rowGC.FieldIndex("Geometry");
                        if (nPose == -1)
                        {
                            MessageBox.Show("不存在Geometry列");
                            return;
                        }

                        // 获取polygon
                        IPolygon polygonGC = null;
                        if (rowGC != null)
                        {
                            nPose = rowGC.FieldIndex("Geometry");
                            IGeometry geo = rowGC.GetValue(nPose) as IGeometry;
                            if (geo.GeometryType == gviGeometryType.gviGeometryPolygon)
                            {
                                polygonGC = geo as IPolygon;
                            }
                        }

                        this.Text = "拾取成功";

                        //第一个Tab页:ExtrudePolygonToModel
                        if (this.tabControl1.SelectedIndex == 0)
                        {
                            // 1.调接口构造模型
                            IGeometryConvertor gc       = new GeometryConvertor();
                            gviRoofType        rooftype = gviRoofType.gviRoofFlat;
                            switch (this.comboxRoofType.Text)
                            {
                            case "Flat":
                                rooftype = gviRoofType.gviRoofFlat;
                                break;

                            case "Gable":
                                rooftype = gviRoofType.gviRoofGable;
                                break;

                            case "Hip":
                                rooftype = gviRoofType.gviRoofHip;
                                break;
                            }
                            string      imgPath = (strMediaPath + @"\dds");
                            string      roof    = this.comboBoxRoofTexture.Text;
                            string      facade  = this.comboBoxFacadeTexture.Text;
                            IModelPoint mp      = null;
                            IModel      model   = null;
                            if (!gc.ExtrudePolygonToModel(polygonGC, int.Parse(this.numFloorNumber.Value.ToString()), double.Parse(this.numFloorHeight.Value.ToString()), double.Parse(this.numSlopeAngle.Value.ToString()),
                                                          rooftype, facade, roof, out mp, out model))
                            {
                                MessageBox.Show("拉体块出错!");
                                return;
                            }

                            //2、将模型及贴图写入osg文件
                            string           modelName  = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".osg");//输出osg文件路径
                            IResourceFactory resFactory = new ResourceFactory();
                            string[]         imageNames = model.GetImageNames();
                            IPropertySet     ps         = new PropertySet();
                            for (int i = 0; i < imageNames.Length; i++)
                            {
                                string imgName = imageNames[i];
                                IImage img     = resFactory.CreateImageFromFile(string.Format(@"{0}\{1}", imgPath + @"\facade", imgName));
                                if (img == null)
                                {
                                    img = resFactory.CreateImageFromFile(string.Format(@"{0}\{1}", imgPath + @"\roof", imgName));
                                }
                                ps.SetProperty(imgName, img);
                            }
                            model.WriteFile(modelName, ps);

                            //3、测试显示模型
                            mp.ModelName = modelName;
                            IRenderModelPoint rmp = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mp, null, rootId);
                            rmp.MouseSelectMask    = gviViewportMask.gviViewNone;
                            rmp.MaxVisibleDistance = 100000;
                            this.axRenderControl1.Camera.LookAtEnvelope(mp.Envelope);//飞入
                            mpList.Add(rmp);
                        }
                        //第二个tab页:ExtrudePolygonToTriMesh
                        else
                        {
                            // 1.调接口构造模型
                            IGeometryConvertor gc = new GeometryConvertor();
                            ITriMesh           tm = gc.ExtrudePolygonToTriMesh(polygonGC, double.Parse(this.numHeight.Value.ToString()), true);
                            if (tm == null)
                            {
                                MessageBox.Show("拉体块出错!");
                                return;
                            }

                            //2、显示三角面
                            //---- 渲染样式不是必须的 -----
                            ISurfaceSymbol surfaceSym = new SurfaceSymbol();
                            surfaceSym.Color       = System.Drawing.Color.Red;
                            surfaceSym.EnableLight = true;
                            ICurveSymbol curveSym = new CurveSymbol();
                            curveSym.Color            = System.Drawing.Color.Yellow;
                            curveSym.Width            = 10;
                            surfaceSym.BoundarySymbol = curveSym;
                            //---- ------------------ -----
                            IRenderTriMesh rmp = this.axRenderControl1.ObjectManager.CreateRenderTriMesh(tm, surfaceSym, rootId);
                            rmp.MouseSelectMask    = gviViewportMask.gviViewNone;
                            rmp.MaxVisibleDistance = 100000;
                            this.axRenderControl1.Camera.LookAtEnvelope(rmp.Envelope);//飞入
                            tmList.Add(rmp);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                if (ex.GetType().Name.Equals("UnauthorizedAccessException"))
                {
                    MessageBox.Show("需要标准runtime授权");
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Ejemplo n.º 19
0
        void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
        {
            //删除包围框
            for (int i = 0; i < rPolylinelist.Count; i++)
            {
                this.axRenderControl1.ObjectManager.DeleteObject((rPolylinelist[i] as IRenderPolyline).Guid);
            }
            rPolylinelist.Clear();
            for (int i = 0; i < rPolylinelistWhole.Count; i++)
            {
                this.axRenderControl1.ObjectManager.DeleteObject((rPolylinelistWhole[i] as IRenderPolyline).Guid);
            }
            rPolylinelistWhole.Clear();

            for (int i = 0; i < tableLabelList.Count; i++)
            {
                this.axRenderControl1.ObjectManager.DeleteObject((tableLabelList[i] as ITableLabel).Guid);
            }
            tableLabelList.Clear();

            for (int i = 0; i < modelpointList.Count; i++)
            {
                this.axRenderControl1.ObjectManager.DeleteObject((modelpointList[i] as IRenderModelPoint).Guid);
            }
            modelpointList.Clear();

            if (rpl1 != null)
            {
                this.axRenderControl1.ObjectManager.DeleteObject(rpl1.Guid);
            }
            if (rpl2 != null)
            {
                this.axRenderControl1.ObjectManager.DeleteObject(rpl2.Guid);
            }

            this.axRenderControl1.HighlightHelper.SetRegion(null);

            if (EventSender == gviMouseSelectMode.gviMouseSelectClick)
            {
                IPickResult pr = PickResult;
                if (pr == null)
                {
                    return;
                }
                if (pr.Type == gviObjectType.gviObject3DTileLayer)
                {
                    if (Mode == 1)
                    {
                        IPoint intersectPoint          = IntersectPoint;
                        IRelationalOperator2D relation = intersectPoint as IRelationalOperator2D;

                        foreach (IFeatureClass fc in fcMap.Keys)
                        {
                            List <string> geoNames = fcMap[fc] as List <string>;
                            if (geoNames.Count == 0)
                            {
                                continue;
                            }

                            IFdeCursor        cursor = null;
                            IRowBuffer        row    = null;
                            List <IRowBuffer> list   = new List <IRowBuffer>();
                            try
                            {
                                ISpatialFilter filter = new SpatialFilter();
                                filter.Geometry      = intersectPoint;
                                filter.SpatialRel    = gviSpatialRel.gviSpatialRelEnvelope;
                                filter.GeometryField = "Geometry";
                                cursor = fc.Search(filter, false);
                                while ((row = cursor.NextRow()) != null)
                                {
                                    list.Add(row);
                                }
                                //开始遍历
                                foreach (IRowBuffer r in list)
                                {
                                    int geometryIndex = -1;
                                    geometryIndex = r.FieldIndex(geoNames[0].ToString());
                                    if (geometryIndex != -1)
                                    {
                                        IGeometry polygon = r.GetValue(geometryIndex) as IGeometry;
                                        if (relation.Within2D(polygon))
                                        {
                                            this.axRenderControl1.HighlightHelper.SetRegion(polygon);
                                        }
                                    }
                                }
                            }
                            catch (System.Exception ex)
                            {
                                if (ex.GetType().Name.Equals("UnauthorizedAccessException"))
                                {
                                    MessageBox.Show("需要标准runtime授权");
                                }
                                else
                                {
                                    MessageBox.Show(ex.Message);
                                }
                            }
                            finally
                            {
                                if (cursor != null)
                                {
                                    //System.Runtime.InteropServices.//Marshal.ReleaseComObject(cursor);
                                    cursor = null;
                                }
                            }

                            if (Mask != gviModKeyMask.gviModKeyCtrl && Mask != gviModKeyMask.gviModKeyShift)
                            {
                                if (list.Count > 0)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else if (Mode == 2)
                    {
                        this.axRenderControl1.Camera.GetCamera2(out cameraPoint, out cameraAngle);
                        IProximityOperator disOperator = cameraPoint as IProximityOperator;
                        double             length      = disOperator.Distance3D(IntersectPoint);
                        //向相机方向延伸n米:n跟眼睛到交点距离有关,当距离远时n大,当距离近时n小。
                        factor = length * 0.001;

                        IPoint    aimingPoint      = this.axRenderControl1.Camera.GetAimingPoint2(IntersectPoint, cameraAngle, factor);
                        IPoint    sourcePoint      = this.axRenderControl1.Camera.GetAimingPoint2(IntersectPoint, cameraAngle, -factor);
                        IPolyline intersetPolyline = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;
                        intersetPolyline.SpatialCRS = _currentCRS;
                        intersetPolyline.AppendPoint(sourcePoint);
                        //瓦片焦点可能在ModelPoint内部,导致拾取不上。因此要向intersectPoint内外各拉一定距离。
                        //intersetPolyline.AppendPoint(IntersectPoint);
                        intersetPolyline.AppendPoint(aimingPoint);

                        ICurveSymbol cs = new CurveSymbol();
                        cs.Color = System.Drawing.Color.Yellow;
                        cs.Width = -5;
                        rpl1     = this.axRenderControl1.ObjectManager.CreateRenderPolyline(intersetPolyline, cs, rootId);
                        rpl1.Glow(-1);

                        //IPolyline intersetPolyline2 = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;
                        //intersetPolyline2.AppendPoint(cameraPoint);
                        //intersetPolyline2.AppendPoint(IntersectPoint);
                        //cs.Color = System.Drawing.Color.Yellow;
                        //rpl2 = this.axRenderControl1.ObjectManager.CreateRenderPolyline(intersetPolyline2, cs, rootId);
                        //rpl2.Glow(-1);


                        foreach (IFeatureClass fc in fcMap.Keys)
                        {
                            ISpatialFilter sp = new SpatialFilter();
                            sp.Geometry      = intersetPolyline;
                            sp.SpatialRel    = gviSpatialRel.gviSpatialRelIntersects;
                            sp.GeometryField = "Geometry";
                            IFdeCursor cursor = null;
                            try
                            {
                                cursor = fc.Search(sp, false);
                                IRowBuffer row = null;
                                while ((row = cursor.NextRow()) != null)
                                {
                                    int         index = row.FieldIndex("Geometry");
                                    IModelPoint mp    = row.GetValue(index) as IModelPoint;
                                    //DrawEnvelope(mp.Envelope, mp.SpatialCRS, out rPolylinelist);
                                    //rPolylinelistWhole.AddRange(rPolylinelist);

                                    //创建RenderModelPoint,显示轮廓线
                                    //IModelPointSymbol mps = new ModelPointSymbol();
                                    //mps.Color = 0; //防止与瓦片同时显示时打架
                                    //mps.EnableColor = true;
                                    //mps.SetResourceDataSet(fc.FeatureDataSet);
                                    //IRenderModelPoint rmp = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mp, mps, rootId);
                                    //rmp.ShowOutline = true;
                                    //modelpointList.Add(rmp);

                                    //创建RenderModelPoint,禁止深度检测
                                    IModelPointSymbol mps = new ModelPointSymbol();
                                    mps.Color         = System.Drawing.Color.Red;
                                    mps.EnableColor   = true;
                                    mps.EnableTexture = false;
                                    mps.SetResourceDataSet(fc.FeatureDataSet);
                                    IRenderModelPoint rmp = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mp, mps, rootId);
                                    rmp.DepthTestMode = gviDepthTestMode.gviDepthTestDisable; //防止与瓦片同时显示时打架
                                    modelpointList.Add(rmp);

                                    //创建TableLabel
                                    if (fde_point == null)
                                    {
                                        fde_point = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                                    }
                                    fde_point.Position   = mp.Position;
                                    fde_point.SpatialCRS = mp.SpatialCRS;
                                    tableLabelList.Add(DrawTableLabel(row, fde_point));
                                }
                            }
                            catch (COMException ex)
                            {
                                System.Diagnostics.Trace.WriteLine(ex.Message);
                            }
                            finally
                            {
                                if (cursor != null)
                                {
                                    //System.Runtime.InteropServices.//Marshal.ReleaseComObject(cursor);
                                    cursor = null;
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 20
0
        private void PolygonExpand(int count, int span)
        {
            if (_alpha == 0)
            {
                return;
            }
            int num = 25;

            for (int i = 0; i < count; i++)
            {
                double[] numArray = _elipse.drawElipse();
                _elipse.timeSpan += span;
                if (numArray != null && numArray.Length > 0)
                {
                    List <IPoint> list = new List <IPoint>();
                    for (int j = 0; j < ((numArray.Length / 2) - 1); j++)
                    {
                        if (numArray[j * 2] == double.NaN)
                        {
                            break;
                        }
                        IPoint item = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                        item.X = numArray[j * 2];
                        item.Y = numArray[(j * 2) + 1];
                        item.Z = num; //0.0 25
                        list.Add(item);
                        if (j == ((numArray.Length / 2) - 2))
                        {
                            list.Add(list[0]);
                        }
                    }
                    if (list.Count > 0)
                    {
                        IPolygon geometry = (new GeometryFactory()).CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon;
                        for (int k = 0; k < list.Count; k++)
                        {
                            geometry.ExteriorRing.AppendPoint(list[k]);
                        }
                        IPolygon fdeValue = null;
                        IPolygon polygon3 = null;
                        if (i == 0)
                        {
                            polygon3 = geometry;
                        }
                        else if (_oldGeo != null)
                        {
                            polygon3 = (geometry as ITopologicalOperator2D).SymmetricDifference2D(_oldGeo) as IPolygon;
                            if (polygon3 != null)
                            {
                                fdeValue = (new GeometryFactory()).CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon;
                                for (int m = 0; m < polygon3.ExteriorRing.PointCount; m++)
                                {
                                    IPoint point      = polygon3.ExteriorRing.GetPoint(m);
                                    IPoint pointValue = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                                    pointValue.X = point.X;
                                    pointValue.Y = point.Y;
                                    pointValue.Z = num;
                                    fdeValue.ExteriorRing.AppendPoint(pointValue);
                                }
                            }
                        }
                        else if (polygon3 == null)
                        {
                            _oldGeo = geometry;
                            continue;
                        }
                        if ((polygon3 != null) && (fdeValue != null))
                        {
                            ISurfaceSymbol ss = new SurfaceSymbol();
                            ss.Color = colorFromARGB(_alpha, 255, 0, 0);
                            ICurveSymbol bs = new CurveSymbol();
                            bs.Color          = colorFromARGB(_alpha, 175, 0, 0);
                            ss.BoundarySymbol = bs;
                            IRenderPolygon rPolygon = d3.ObjectManager.CreateRenderPolygon(fdeValue, ss, d3.ProjectTree.RootID);
                            rPolygon.HeightStyle = gviHeightStyle.gviHeightOnTerrain;
                            if (this.ceFlyToRes.Checked)
                            {
                                d3.Camera.FlyToObject(rPolygon.Guid, gviActionCode.gviActionFlyTo);
                            }
                            _renderObjs.Add(rPolygon.Guid);
                            if (_alpha > 0)
                            {
                                _alpha = _alpha - 3;
                            }
                            if (_alpha < 0)
                            {
                                _alpha = 0;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 21
0
        private void DrawEnvelope(int fid, IFeatureClass fc, out ArrayList rPolylineList)
        {
            rPolylineList = new ArrayList();

            string       filterString = string.Format("oid={0}", fid);
            IQueryFilter filter       = new QueryFilter();

            filter.WhereClause = filterString;
            IFdeCursor cursor = null;

            try
            {
                cursor = fc.Search(filter, true);
                if (cursor != null)
                {
                    IRowBuffer fdeRow = null;
                    while ((fdeRow = cursor.NextRow()) != null)
                    {
                        IFieldInfoCollection col = fdeRow.Fields;
                        for (int i = 0; i < col.Count; ++i)
                        {
                            IFieldInfo info = col.Get(i);
                            if (info.GeometryDef != null &&
                                info.GeometryDef.GeometryColumnType == gviGeometryColumnType.gviGeometryColumnModelPoint)
                            {
                                int         nPos = fdeRow.FieldIndex(info.Name);
                                IModelPoint mp   = fdeRow.GetValue(nPos) as IModelPoint;
                                IEnvelope   env  = mp.Envelope;

                                IPolyline polyline = new GeometryFactory().CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;
                                polyline.SpatialCRS = fc.FeatureDataSet.SpatialReference;
                                IPoint point = new GeometryFactory().CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                                point.SpatialCRS = fc.FeatureDataSet.SpatialReference;

                                ISimplePointSymbol psy = new SimplePointSymbol();
                                psy.FillColor = System.Drawing.Color.Yellow;
                                psy.Size      = 10;
                                ICurveSymbol cSymbol = new CurveSymbol();
                                cSymbol.Color = System.Drawing.Color.Yellow;
                                cSymbol.Width = 2;

                                point.SetCoords(env.MinX, env.MinY, env.MinZ, 0, 0);  //0
                                //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
                                polyline.AppendPoint(point);

                                point.SetCoords(env.MaxX, env.MinY, env.MinZ, 0, 1);  //1
                                //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
                                polyline.AppendPoint(point);

                                point.SetCoords(env.MaxX, env.MaxY, env.MinZ, 0, 2);   //2
                                //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
                                polyline.AppendPoint(point);

                                point.SetCoords(env.MinX, env.MaxY, env.MinZ, 0, 3);   //3
                                //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
                                polyline.AppendPoint(point);

                                point.SetCoords(env.MinX, env.MinY, env.MinZ, 0, 4); //0
                                polyline.AppendPoint(point);                         //close
                                rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId));

                                polyline.SetEmpty();
                                point.SetCoords(env.MinX, env.MaxY, env.MaxZ, 0, 0);  //4
                                //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
                                polyline.AppendPoint(point);

                                point.SetCoords(env.MaxX, env.MaxY, env.MaxZ, 0, 0);  //5
                                //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
                                polyline.AppendPoint(point);

                                point.SetCoords(env.MaxX, env.MinY, env.MaxZ, 0, 0);  //6
                                //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
                                polyline.AppendPoint(point);

                                point.SetCoords(env.MinX, env.MinY, env.MaxZ, 0, 0);  //7
                                //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
                                polyline.AppendPoint(point);

                                point.SetCoords(env.MinX, env.MaxY, env.MaxZ, 0, 0); //4
                                polyline.AppendPoint(point);                         //close
                                rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId));

                                polyline.SetEmpty();
                                point.SetCoords(env.MinX, env.MinY, env.MinZ, 0, 0);  //0
                                polyline.AppendPoint(point);
                                point.SetCoords(env.MinX, env.MinY, env.MaxZ, 0, 0);  //7
                                polyline.AppendPoint(point);
                                rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId));

                                polyline.SetEmpty();
                                point.SetCoords(env.MaxX, env.MinY, env.MinZ, 0, 0);  //1
                                polyline.AppendPoint(point);
                                point.SetCoords(env.MaxX, env.MinY, env.MaxZ, 0, 0);  //6
                                polyline.AppendPoint(point);
                                rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId));

                                polyline.SetEmpty();
                                point.SetCoords(env.MaxX, env.MaxY, env.MinZ, 0, 0);  //2
                                polyline.AppendPoint(point);
                                point.SetCoords(env.MaxX, env.MaxY, env.MaxZ, 0, 0);  //5
                                polyline.AppendPoint(point);
                                rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId));

                                polyline.SetEmpty();
                                point.SetCoords(env.MinX, env.MaxY, env.MinZ, 0, 0);  //3
                                polyline.AppendPoint(point);
                                point.SetCoords(env.MinX, env.MaxY, env.MaxZ, 0, 0);  //4
                                polyline.AppendPoint(point);
                                rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId));
                            }
                        }
                    }
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            finally
            {
                if (cursor != null)
                {
                    //Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
            }
        }
Ejemplo n.º 22
0
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            // 初始化RenderControl控件
            IPropertySet ps = new PropertySet();

            ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL);
            this.axRenderControl1.Initialize(true, ps);
            this.axRenderControl1.Camera.FlyTime = 1;

            ICRSFactory crsfac = new CRSFactory();

            _currentCRS = (crsfac.CreateFromWKT(this.axRenderControl1.GetCurrentCrsWKT())) as ISpatialCRS;

            rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID;

            // 设置天空盒

            if (System.IO.Directory.Exists(strMediaPath))
            {
                string  tmpSkyboxPath = strMediaPath + @"\skybox";
                ISkyBox skybox        = this.axRenderControl1.ObjectManager.GetSkyBox(0);
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\1_BK.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\1_DN.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\1_FR.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\1_LF.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\1_RT.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\1_UP.jpg");
            }
            else
            {
                MessageBox.Show("请不要随意更改SDK目录名");
                return;
            }

            this.axRenderControl1.Camera.FlyTime = 0;

            // 加载瓦片图层
            string       tilelayerString = (strMediaPath + @"\sdk.tdb");
            I3DTileLayer layer           = this.axRenderControl1.ObjectManager.Create3DTileLayer(tilelayerString, "", rootId);

            this.axRenderControl1.Camera.FlyToObject(layer.Guid, gviActionCode.gviActionFlyTo);
            // 添加节点到界面控件上
            myListNode item = new myListNode("tilelayer", TreeNodeType.NT_TiltedLAYER, layer);

            item.Checked = true;
            listView1.Items.Add(item);

            #region 加载FDB
            try
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\SDKDEMO.FDB");
                ci.Database = tmpFDBPath;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                IDataSource        ds        = dsFactory.OpenDataSource(ci);
                string[]           setnames  = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]);
                _datasetCRS = dataset.SpatialReference;

                //遍历FeatureClass
                string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                fcMap    = new Hashtable(fcnames.Length);
                fcuidMap = new Hashtable(fcnames.Length);
                foreach (string name in fcnames)
                {
                    IFeatureClass fc = dataset.OpenFeatureClass(name);
                    // 找到空间列字段
                    List <string>        geoNames   = new List <string>();
                    IFieldInfoCollection fieldinfos = fc.GetFields();
                    for (int i = 0; i < fieldinfos.Count; i++)
                    {
                        IFieldInfo fieldinfo = fieldinfos.Get(i);
                        if (null == fieldinfo)
                        {
                            continue;
                        }
                        IGeometryDef geometryDef = fieldinfo.GeometryDef;
                        if (null == geometryDef)
                        {
                            continue;
                        }
                        if (geometryDef.GeometryColumnType == gviGeometryColumnType.gviGeometryColumnPolygon)
                        {
                            geoNames.Add(fieldinfo.Name);
                        }
                    }
                    fcMap.Add(fc, geoNames);
                    fcuidMap.Add(fc.Guid, fc);
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return;
            }
            #endregion

            //CreateFeautureLayer for 矢量贴地
            foreach (IFeatureClass fc in fcMap.Keys)
            {
                List <string> geoNames = (List <string>)fcMap[fc];
                if (geoNames.Count == 0)
                {
                    continue;
                }

                #region 定义几何物体渲染风格
                ICurveSymbol cs = new CurveSymbol();
                cs.Color = System.Drawing.Color.Empty;  //防止贴瓦片时出现绿色竖边
                IValueMapGeometryRender geoRender = new ValueMapGeometryRender();
                {
                    IRangeRenderRule rangeRule = new RangeRenderRule();
                    rangeRule.LookUpField = "oid";
                    rangeRule.MaxValue    = 1100;
                    rangeRule.MinValue    = 1000;
                    rangeRule.IncludeMin  = false;

                    ISurfaceSymbol geoSymbol = new SurfaceSymbol();
                    geoSymbol.Color          = System.Drawing.Color.Yellow;
                    geoSymbol.BoundarySymbol = cs;

                    IGeometryRenderScheme grs = new GeometryRenderScheme();
                    grs.AddRule(rangeRule);
                    grs.Symbol = geoSymbol;
                    geoRender.AddScheme(grs);
                }
                {
                    IRangeRenderRule rangeRule = new RangeRenderRule();
                    rangeRule.LookUpField = "oid";
                    rangeRule.MaxValue    = 1200;
                    rangeRule.MinValue    = 1100;
                    rangeRule.IncludeMin  = false;

                    ISurfaceSymbol geoSymbol = new SurfaceSymbol();
                    geoSymbol.Color          = System.Drawing.Color.Blue;
                    geoSymbol.BoundarySymbol = cs;

                    IGeometryRenderScheme grs = new GeometryRenderScheme();
                    grs.AddRule(rangeRule);
                    grs.Symbol = geoSymbol;
                    geoRender.AddScheme(grs);
                }
                {
                    IRangeRenderRule rangeRule = new RangeRenderRule();
                    rangeRule.LookUpField = "oid";
                    rangeRule.MaxValue    = 1300;
                    rangeRule.MinValue    = 1200;
                    rangeRule.IncludeMin  = false;

                    ISurfaceSymbol geoSymbol = new SurfaceSymbol();
                    geoSymbol.Color          = System.Drawing.Color.Green;
                    geoSymbol.BoundarySymbol = cs;

                    IGeometryRenderScheme grs = new GeometryRenderScheme();
                    grs.AddRule(rangeRule);
                    grs.Symbol = geoSymbol;
                    geoRender.AddScheme(grs);
                }
                {
                    IRangeRenderRule rangeRule = new RangeRenderRule();
                    rangeRule.LookUpField = "oid";
                    rangeRule.MaxValue    = 1400;
                    rangeRule.MinValue    = 1300;
                    rangeRule.IncludeMin  = false;

                    ISurfaceSymbol geoSymbol = new SurfaceSymbol();
                    geoSymbol.Color          = System.Drawing.Color.Goldenrod;
                    geoSymbol.BoundarySymbol = cs;

                    IGeometryRenderScheme grs = new GeometryRenderScheme();
                    grs.AddRule(rangeRule);
                    grs.Symbol = geoSymbol;
                    geoRender.AddScheme(grs);
                }
                {
                    ISurfaceSymbol geoSymbol = new SurfaceSymbol();
                    geoSymbol.Color          = System.Drawing.Color.Fuchsia;
                    geoSymbol.BoundarySymbol = cs;

                    IGeometryRenderScheme geoSchemeOther = new GeometryRenderScheme();
                    geoSchemeOther.Symbol = geoSymbol;
                    geoRender.AddScheme(geoSchemeOther);
                }
                #endregion
                geoRender.HeightStyle = gviHeightStyle.gviHeightOnEverything;

                IFeatureLayer fcLayer = this.axRenderControl1.ObjectManager.CreateFeatureLayer(fc, geoNames[0], null, geoRender, rootId);
                if (fcLayer != null)
                {
                    fcLayer.VisibleMask = gviViewportMask.gviViewNone;

                    // 添加节点到界面控件上
                    myListNode item2 = new myListNode(fc.Name + "_" + geoNames[0], TreeNodeType.NT_FeatureLayer, fcLayer);
                    item.Checked = false;
                    listView1.Items.Add(item2);
                }
                else
                {
                    MessageBox.Show("Create FeatureLayer Failed! " + this.axRenderControl1.GetLastError().ToString());
                }
            }

            // 注册事件
            this.axRenderControl1.RcMouseClickSelect += new Gvitech.CityMaker.Controls._IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect);


            //设置highlight可用
            this.axRenderControl1.HighlightHelper.VisibleMask = 1;



            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "TileHole.html";
            }
        }
Ejemplo n.º 23
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // 初始化RenderControl控件
            IPropertySet ps = new PropertySet();

            ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL);
            this.axRenderControl1.Initialize(false, ps);

            rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID;
            this.axRenderControl1.Camera.FlyTime = 0;

            // 设置天空盒

            if (System.IO.Directory.Exists(strMediaPath))
            {
                string  tmpSkyboxPath = strMediaPath + @"\skybox";
                ISkyBox skybox        = this.axRenderControl1.ObjectManager.GetSkyBox(0);
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\1_BK.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\1_DN.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\1_FR.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\1_LF.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\1_RT.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\1_UP.jpg");
            }
            else
            {
                MessageBox.Show("请不要随意更改SDK目录名");
                return;
            }

            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "ToolTipShow.html";
            }

            layerEnvelopeMap = new Hashtable();
            layerFcMap       = new Hashtable();

            // 可视化Point类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\point.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                IToolTipTextRender textRender = new ToolTipTextRender();
                textRender.Expression = "''..$(oid)";

                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                IImagePointSymbol     geoSymbol = new ImagePointSymbol(); //将点以图片的形式显示出来
                geoSymbol.ImageName = "huang.png";                        //使用素材库里存在的图片
                geoSymbol.Size      = 25;
                geoRender.Symbol    = geoSymbol;

                FeatureLayerVisualize(ci, true, "Point", textRender, geoRender);
            }
            // 可视化Polyline类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\polyline.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                IToolTipTextRender textRender = new ToolTipTextRender();
                textRender.Expression = "''..$(oid)";

                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                ICurveSymbol          geoSymbol = new CurveSymbol();
                geoSymbol.Color  = System.Drawing.Color.Purple; //线颜色为Purple
                geoSymbol.Width  = 5;
                geoRender.Symbol = geoSymbol;

                FeatureLayerVisualize(ci, false, "Polyline", textRender, geoRender);
            }

            // 可视化Polygon类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\polygon.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                IToolTipTextRender textRender = new ToolTipTextRender();
                textRender.Expression = "''..$(oid)";

                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                ISurfaceSymbol        geoSymbol = new SurfaceSymbol();
                geoSymbol.Color  = System.Drawing.Color.Yellow; //面填充色为Yellow
                geoRender.Symbol = geoSymbol;

                FeatureLayerVisualize(ci, false, "Polygon", textRender, geoRender);
            }

            // 可视化ModelPoint类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\community.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                IToolTipTextRender textRender = new ToolTipTextRender();
                textRender.Expression = "''..$(oid)";

                FeatureLayerVisualize(ci, false, "ModelPoint", textRender, null);
            }
        }
Ejemplo n.º 24
0
        void axRenderControl1_RcObjectEditFinish()
        {
            this.axRenderControl1.InteractMode = gviInteractMode.gviInteractNormal;
            polygonDraw = currentGeometry as IPolygon;
            //抬高一点
            for (int i = 0; i < polygonDraw.ExteriorRing.PointCount; i++)
            {
                IPoint pointOnExr = polygonDraw.ExteriorRing.GetPoint(i).Clone() as IPoint;
                pointOnExr.Z += 1;
                polygonDraw.ExteriorRing.UpdatePoint(i, pointOnExr);
            }

            renderpolygonDraw.SetFdeGeometry(polygonDraw);
            renderpolygonDraw.VisibleMask = gviViewportMask.gviViewNone;

            double height = 0.0;

            try
            {
                height = double.Parse(this.numHeight.Value.ToString());
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("请检查挖洞高度");
                return;
            }

            //构造底面polygon
            IPolygon polygonBottom = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon;

            for (int i = 0; i < polygonDraw.ExteriorRing.PointCount; i++)
            {
                IPoint pointOnExr = polygonDraw.ExteriorRing.GetPoint(i).Clone() as IPoint;
                maxZ          = pointOnExr.Z;
                pointOnExr.Z -= height;
                minZ          = pointOnExr.Z;
                polygonBottom.ExteriorRing.AppendPoint(pointOnExr);
            }
            polygonBottom.Close();
            PolygonList.Add(polygonBottom);
            //CreateRenderPolygon(polygonBottom);


            //构造侧面polygon
            for (int i = 0; i < polygonDraw.ExteriorRing.PointCount; i++)
            {
                IPoint pointOnExr = polygonDraw.ExteriorRing.GetPoint(i).Clone() as IPoint;
                pointOnExr.Z -= height;

                IPoint pointOnExr2 = null;
                if (i == polygonDraw.ExteriorRing.PointCount - 1)
                {
                    pointOnExr2 = polygonDraw.ExteriorRing.GetPoint(0).Clone() as IPoint;
                }
                else
                {
                    pointOnExr2 = polygonDraw.ExteriorRing.GetPoint(i + 1).Clone() as IPoint;
                }
                pointOnExr2.Z -= height;

                IPolygon polygonTemp = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon;
                polygonTemp.ExteriorRing.AppendPoint(polygonDraw.ExteriorRing.GetPoint(i));
                polygonTemp.ExteriorRing.AppendPoint(pointOnExr);
                polygonTemp.ExteriorRing.AppendPoint(pointOnExr2);
                if (i == polygonDraw.ExteriorRing.PointCount - 1)
                {
                    polygonTemp.ExteriorRing.AppendPoint(polygonDraw.ExteriorRing.GetPoint(0));
                }
                else
                {
                    polygonTemp.ExteriorRing.AppendPoint(polygonDraw.ExteriorRing.GetPoint(i + 1));
                }
                polygonTemp.Close();
                PolygonList.Add(polygonTemp);
                //CreateRenderPolygon(polygonTemp);
            }


            List <IRowBuffer> list   = new List <IRowBuffer>();
            ISpatialFilter    filter = new SpatialFilter();

            filter.Geometry      = polygonDraw;
            filter.SpatialRel    = gviSpatialRel.gviSpatialRelEnvelope;
            filter.GeometryField = "Geometry";
            IRowBuffer row    = null;
            IFdeCursor cursor = __fc.Search(filter, false);

            while ((row = cursor.NextRow()) != null)
            {
                list.Add(row);
            }

            foreach (IRowBuffer r in list)
            {
                __fid = (Int32)r.GetValue(0);
                int geometryIndex = -1;
                geometryIndex = r.FieldIndex("Geometry");
                int nameIndex = -1;
                nameIndex = r.FieldIndex("Name");
                if (geometryIndex != -1)
                {
                    // 获取ModelPoint
                    IModelPoint mp = r.GetValue(geometryIndex) as IModelPoint;

                    // 获取Model
                    string modelName = mp.ModelName;
                    IModel m         = (__fc.FeatureDataSet as IResourceManager).GetModel(modelName);

                    Logger.WriteMsg(LogLevel.Message, "---------开始ModelPointToTriMesh----------", DateTime.Now);
                    // 获取MultiTriMesh
                    IMultiTriMesh multiTM = gc.ModelPointToTriMesh(m, mp, false);
                    Logger.WriteMsg(LogLevel.Message, string.Format("---------完成ModelPointToTriMesh:{0}----------", multiTM.GeometryCount), DateTime.Now);

                    // 获取Name
                    string strName = r.GetValue(nameIndex).ToString();
                    for (int i = 0; i < multiTM.GeometryCount; i++)
                    {
                        ITriMesh tm = multiTM.GetGeometry(i) as ITriMesh;
                        //if (!tm.IsClosed)
                        //    continue;

                        // 生成剖面
                        for (int p = 0; p < PolygonList.Count; p++)
                        {
                            IPolygon curPolygon = PolygonList[p];
                            Logger.WriteMsg(LogLevel.Message, string.Format("TM:{0} PG:{1}", i, p), DateTime.Now);
                            if (gc.GetSolidProfile(tm, curPolygon, out multiPolygon))
                            {
                                Logger.WriteMsg(LogLevel.Message, string.Format("TM:{0} PG:{1} TRUE", i, p), DateTime.Now);
                                if (multiPolygon != null && multiPolygon.GeometryCount > 0)
                                {
                                    for (int j = 0; j < multiPolygon.GeometryCount; j++)
                                    {
                                        IPolygon tm2 = multiPolygon.GetGeometry(j) as IPolygon;
                                        //RenderPolygonList.Add(CreateRenderPolygon(tm2));

                                        ICurveSymbol cs = new CurveSymbol();
                                        cs.Color = Color.FromArgb(0, Color.White);
                                        ISurfaceSymbol ss = new SurfaceSymbol();
                                        ss.BoundarySymbol = cs;
                                        ss.Color          = m.GetGroup(0).GetPrimitive(0).Material.DiffuseColor;
                                        IRenderPolygon tmPolygon = this.axRenderControl1.ObjectManager.CreateRenderPolygon(tm2, ss, rootId);
                                        tmPolygon.SetClientData("Name", strName);
                                        RenderPolygonList.Add(tmPolygon);

                                        #region 用当前选中的模型材质,生成截面模型

                                        /*
                                         * IModel outModel = null;
                                         * IModelPoint outMP = null;
                                         * gc.PolygonToModelPoint(tm2, out outModel, out outMP);
                                         *
                                         * if (outModel != null && outMP != null)
                                         * {
                                         *
                                         *  IDrawGroup dgroup = outModel.GetGroup(0);
                                         *  IDrawPrimitive dpri = dgroup.GetPrimitive(0);
                                         *  IDrawMaterial dmar = dpri.Material;
                                         *  dmar.CullMode = gviCullFaceMode.gviCullNone;
                                         *
                                         *  //处理贴图
                                         *  //IPropertySet psOut = new PropertySet();
                                         *  string imgName = m.GetGroup(0).GetPrimitive(0).Material.TextureName;
                                         *  if (imgName != "")
                                         *  {
                                         *      dmar.WrapModeS = gviTextureWrapMode.gviTextureWrapRepeat;
                                         *      dmar.WrapModeT = gviTextureWrapMode.gviTextureWrapRepeat;
                                         *
                                         *      //string tmpImgPath = (strMediaPath + @"\1\") + imgName + ".dds";
                                         *      //IImage imageOut = (__fc.FeatureDataSet as IResourceManager).GetImage(imgName);
                                         *      //imageOut.WriteFile(tmpImgPath);
                                         *      //psOut.SetProperty(imgName, imageOut);
                                         *      //dmar.TextureName = imgName;
                                         *
                                         *      IImage image = (__fc.FeatureDataSet as IResourceManager).GetImage(imgName);
                                         *      this.axRenderControl1.ObjectManager.AddImage(imgName, image);
                                         *      dmar.TextureName = imgName;
                                         *
                                         *      if (dpri.VertexArray.Length == 12)
                                         *      {
                                         *          IFloatArray texcoords = new FloatArray();
                                         *          texcoords.Append(0);
                                         *          texcoords.Append(0);
                                         *          texcoords.Append(1.0f);
                                         *          texcoords.Append(0);
                                         *          texcoords.Append(1.0f);
                                         *          texcoords.Append(1.0f);
                                         *          texcoords.Append(0);
                                         *          texcoords.Append(1.0f);
                                         *          dpri.TexcoordArray = texcoords;
                                         *      }
                                         *      else
                                         *      {
                                         *          IFloatArray texcoords = new FloatArray();
                                         *          texcoords.Append(0);
                                         *          texcoords.Append(0);
                                         *          for (int v = 3; v < dpri.VertexArray.Length - 2; )
                                         *          {
                                         *              texcoords.Append(Math.Abs(dpri.VertexArray.Get(v) - dpri.VertexArray.Get(0)));
                                         *              texcoords.Append(Math.Abs(dpri.VertexArray.Get(v+2) - dpri.VertexArray.Get(2)));
                                         *              v += 3;
                                         *          }
                                         *          dpri.TexcoordArray = texcoords;
                                         *      }
                                         *  }
                                         *  else
                                         *  {
                                         *      dmar.DepthBias = m.GetGroup(0).GetPrimitive(0).Material.DepthBias;
                                         *      dmar.DiffuseColor = m.GetGroup(0).GetPrimitive(0).Material.DiffuseColor;
                                         *      dmar.EnableBlend = m.GetGroup(0).GetPrimitive(0).Material.EnableBlend;
                                         *      dmar.EnableLight = m.GetGroup(0).GetPrimitive(0).Material.EnableLight;
                                         *      dmar.SpecularColor = m.GetGroup(0).GetPrimitive(0).Material.SpecularColor;
                                         *      dmar.WrapModeS = m.GetGroup(0).GetPrimitive(0).Material.WrapModeS;
                                         *      dmar.WrapModeT = m.GetGroup(0).GetPrimitive(0).Material.WrapModeT;
                                         *  }
                                         *
                                         *  dpri.Material = dmar;
                                         *  dgroup.SetPrimitive(0, dpri);
                                         *  outModel.SetGroup(0, dgroup);
                                         *
                                         *  //处理模型
                                         *  //string osgNameOut = __fid + "_" + p + "_" + j;
                                         *  //string tmpOSGPath = (strMediaPath + @"\1\" + osgNameOut + ".osg");
                                         *  //outModel.WriteFile(tmpOSGPath, psOut);
                                         *  //outMP.ModelName = tmpOSGPath;
                                         *
                                         *
                                         *  string osgName = __fid + "_" + p + "_" + j;
                                         *  this.axRenderControl1.ObjectManager.AddModel(osgName, outModel);
                                         *  outMP.ModelName = osgName;
                                         *
                                         *  //可视化
                                         *  outMP.ModelEnvelope = outModel.Envelope;
                                         *  IRenderModelPoint outRenderMP = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(outMP, null, rootId);
                                         *  //this.axRenderControl1.RefreshModel(null, tmpOSGPath);
                                         *  outRenderMP.ShowOutline = true;
                                         *  //outRenderMP.VisibleMask = gviViewportMask.gviViewNone;
                                         *  RenderMPProfileList.Add(outRenderMP);
                                         * }
                                         */
                                        #endregion
                                    }
                                }
                            }
                        } //遍历PolygonList结束
                    }     //遍历multiTM结束



                    //去掉内环模型
                    __fl.VisibleMask = gviViewportMask.gviViewNone;
                    IModel            modelInterior = null;
                    IModelPoint       mpInterior    = null;
                    IRenderModelPoint rmpInterior   = null;
                    IModel            modelExterior = null;
                    IModelPoint       mpExterior    = null;
                    IRenderModelPoint rmpExterior   = null;
                    IMultiPolygon     mltiPolygon   = geoFactory.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon;
                    mltiPolygon.AddGeometry(polygonDraw);
                    Logger.WriteMsg(LogLevel.Message, "---------开始SplitModelPointByPolygon2DWithZ----------", DateTime.Now);
                    if (gc.SplitModelPointByPolygon2DWithZ(mltiPolygon, m, mp, minZ, maxZ, out modelInterior, out mpInterior, out modelExterior, out mpExterior))
                    {
                        Logger.WriteMsg(LogLevel.Message, "SplitModelPointByPolygon2DWithZ返回值为TRUE", DateTime.Now);
                        if (modelExterior != null && mpExterior != null)
                        {
                            this.axRenderControl1.ObjectManager.AddModel(mpExterior.ModelName, modelExterior);
                            string[] imagenames = modelExterior.GetImageNames();
                            for (int q = 0; q < imagenames.Length; q++)
                            {
                                IImage image = (__fc.FeatureDataSet as IResourceManager).GetImage(imagenames[q]);
                                this.axRenderControl1.ObjectManager.AddImage(imagenames[q], image);
                            }
                            rmpExterior = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mpExterior, null, rootId);
                            RenderMPExteriorList.Add(rmpExterior);
                        }
                        if (modelInterior != null && mpInterior != null)
                        {
                            this.axRenderControl1.ObjectManager.AddModel(mpInterior.ModelName, modelInterior);
                            string[] imagenames = modelInterior.GetImageNames();
                            for (int q = 0; q < imagenames.Length; q++)
                            {
                                IImage image = (__fc.FeatureDataSet as IResourceManager).GetImage(imagenames[q]);
                                this.axRenderControl1.ObjectManager.AddImage(imagenames[q], image);
                            }
                            rmpInterior             = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mpInterior, null, rootId);
                            rmpInterior.VisibleMask = gviViewportMask.gviViewNone;
                            RenderMPInteriorList.Add(rmpInterior);
                        }
                    }
                }
            }//遍历RowBufferList结束
             //MessageBox.Show("执行成功");
        }
Ejemplo n.º 25
0
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            // 初始化RenderControl控件
            IPropertySet ps = new PropertySet();

            ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL);
            this.axRenderControl1.Initialize(true, ps);
            this.axRenderControl1.Camera.FlyTime = 1;

            rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID;

            // 设置天空盒

            if (System.IO.Directory.Exists(strMediaPath))
            {
                string  tmpSkyboxPath = strMediaPath + @"\skybox";
                ISkyBox skybox        = this.axRenderControl1.ObjectManager.GetSkyBox(0);
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\7_BK.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\7_DN.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\7_FR.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\7_LF.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\7_RT.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\7_UP.jpg");
            }
            else
            {
                MessageBox.Show("请不要随意更改SDK目录名");
                return;
            }

            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "GeometrySymbolScript.html";
            }

            layerEnvelopeMap = new Hashtable();

            // 可视化Point类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\point.FDB");
                ci.Database = tmpFDBPath;

                // *****定义几何物体渲染风格*****
                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                //-- 配置为简单点 --
                ISimplePointSymbol geoSymbol = new SimplePointSymbol();
                geoSymbol.Script = "<Size>$(Groupid)*10</Size><FillColor>$(OBJECTID)</FillColor>";
                //-- 配置为图片点 --
                //IImagePointSymbol geoSymbol = new ImagePointSymbol();
                //geoSymbol.Script = "<Size>$(Groupid)*10</Size><ImageName>$(ImageName)</ImageName>";
                geoRender.Symbol = geoSymbol;

                type = LayerType.Point;
                FeatureLayerVisualize(ci, true, "Point", null, geoRender, type);
            }

            // 可视化Polyline类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\polyline.FDB");
                ci.Database = tmpFDBPath;

                // *****定义几何物体渲染风格*****
                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                ICurveSymbol          geoSymbol = new CurveSymbol();
                geoSymbol.Script = "<Color>System.Drawing.Color.Yellow</Color><Width>$(Groupid)*10</Width><ImageName>$(ImageName)</ImageName><RepeatLength>100</RepeatLength>";
                geoRender.Symbol = geoSymbol;

                type = LayerType.Polyline;
                FeatureLayerVisualize(ci, false, "Polyline", null, geoRender, type);
            }

            // 可视化Polygon类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\polygon.FDB");
                ci.Database = tmpFDBPath;

                // *****定义几何物体渲染风格*****
                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                //-- 配置为简单面 --
                //ISurfaceSymbol geoSymbol = new SurfaceSymbol();
                //geoSymbol.Script = "<Color>$(CommunitID)</Color>";
                //-- 配置为立体矩形 --
                IPolygon3DSymbol geoSymbol = new Polygon3DSymbol();
                geoSymbol.Script = "<Color>$(CommunitID)</Color><Height>$(oid)</Height>";
                ICurveSymbol curveSymbol = new CurveSymbol();
                curveSymbol.Script       = "<Color>$(CommunitID)</Color>";
                geoSymbol.BoundarySymbol = curveSymbol;
                geoRender.Symbol         = geoSymbol;

                type = LayerType.Polygon;
                FeatureLayerVisualize(ci, false, "Polygon", null, geoRender, type);
            }

            // 可视化ModelPoint类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\SDKDEMO.FDB");
                ci.Database = tmpFDBPath;

                // *****定义几何物体渲染风格*****
                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                IModelPointSymbol     geoSymbol = new ModelPointSymbol();
                geoSymbol.Script      = "<Color>System.Drawing.Color.Yellow</Color>";
                geoSymbol.EnableColor = true;  // 记得要开启!
                geoRender.Symbol      = geoSymbol;

                type = LayerType.ModelPoint;
                FeatureLayerVisualize(ci, false, "ModelPoint", null, geoRender, type);
            }
        }
Ejemplo n.º 26
0
        private void DrawEnvelope(IEnvelope env, ISpatialCRS crs, out ArrayList rPolylineList)
        {
            rPolylineList = new ArrayList();

            IPolyline polyline = new GeometryFactory().CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;

            polyline.SpatialCRS = crs;
            IPoint point = new GeometryFactory().CreatePoint(gviVertexAttribute.gviVertexAttributeZ);

            point.SpatialCRS = crs;

            ISimplePointSymbol psy = new SimplePointSymbol();

            psy.FillColor = System.Drawing.Color.Yellow;
            psy.Size      = 10;
            ICurveSymbol cSymbol = new CurveSymbol();

            cSymbol.Color = System.Drawing.Color.Yellow;
            cSymbol.Width = 2;

            point.SetCoords(env.MinX, env.MinY, env.MinZ, 0, 0);  //0
            //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
            polyline.AppendPoint(point);

            point.SetCoords(env.MaxX, env.MinY, env.MinZ, 0, 1);  //1
            //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
            polyline.AppendPoint(point);

            point.SetCoords(env.MaxX, env.MaxY, env.MinZ, 0, 2);   //2
            //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
            polyline.AppendPoint(point);

            point.SetCoords(env.MinX, env.MaxY, env.MinZ, 0, 3);   //3
            //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
            polyline.AppendPoint(point);

            point.SetCoords(env.MinX, env.MinY, env.MinZ, 0, 4); //0
            polyline.AppendPoint(point);                         //close
            rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId));

            polyline.SetEmpty();
            point.SetCoords(env.MinX, env.MaxY, env.MaxZ, 0, 0);  //4
            //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
            polyline.AppendPoint(point);

            point.SetCoords(env.MaxX, env.MaxY, env.MaxZ, 0, 0);  //5
            //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
            polyline.AppendPoint(point);

            point.SetCoords(env.MaxX, env.MinY, env.MaxZ, 0, 0);  //6
            //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
            polyline.AppendPoint(point);

            point.SetCoords(env.MinX, env.MinY, env.MaxZ, 0, 0);  //7
            //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy);
            polyline.AppendPoint(point);

            point.SetCoords(env.MinX, env.MaxY, env.MaxZ, 0, 0); //4
            polyline.AppendPoint(point);                         //close
            rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId));

            polyline.SetEmpty();
            point.SetCoords(env.MinX, env.MinY, env.MinZ, 0, 0);  //0
            polyline.AppendPoint(point);
            point.SetCoords(env.MinX, env.MinY, env.MaxZ, 0, 0);  //7
            polyline.AppendPoint(point);
            rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId));

            polyline.SetEmpty();
            point.SetCoords(env.MaxX, env.MinY, env.MinZ, 0, 0);  //1
            polyline.AppendPoint(point);
            point.SetCoords(env.MaxX, env.MinY, env.MaxZ, 0, 0);  //6
            polyline.AppendPoint(point);
            rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId));

            polyline.SetEmpty();
            point.SetCoords(env.MaxX, env.MaxY, env.MinZ, 0, 0);  //2
            polyline.AppendPoint(point);
            point.SetCoords(env.MaxX, env.MaxY, env.MaxZ, 0, 0);  //5
            polyline.AppendPoint(point);
            rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId));

            polyline.SetEmpty();
            point.SetCoords(env.MinX, env.MaxY, env.MinZ, 0, 0);  //3
            polyline.AppendPoint(point);
            point.SetCoords(env.MinX, env.MaxY, env.MaxZ, 0, 0);  //4
            polyline.AppendPoint(point);
            rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId));
        }
Ejemplo n.º 27
0
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            // 初始化RenderControl控件
            IPropertySet ps = new PropertySet();

            ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL);
            this.axRenderControl1.Initialize(true, ps);
            this.axRenderControl1.Camera.FlyTime = 1;

            rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID;

            // 设置天空盒

            if (System.IO.Directory.Exists(strMediaPath))
            {
                string  tmpSkyboxPath = strMediaPath + @"\skybox";
                ISkyBox skybox        = this.axRenderControl1.ObjectManager.GetSkyBox(0);
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\1_BK.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\1_DN.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\1_FR.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\1_LF.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\1_RT.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\1_UP.jpg");
            }
            else
            {
                MessageBox.Show("请不要随意更改SDK目录名");
                return;
            }

            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "FeatureLayerSimpleRender.html";
            }

            layerEnvelopeMap = new Hashtable();
            layerFcMap       = new Hashtable();

            // 可视化Point类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\point.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                ISimpleTextRender textRender = new SimpleTextRender();
                textRender.Expression = "''..$(oid)";
                ITextSymbol   textSymbol    = new TextSymbol();
                TextAttribute textAttribute = new TextAttribute();
                textAttribute.TextColor   = System.Drawing.Color.Red;
                textSymbol.TextAttribute  = textAttribute;
                textSymbol.PivotAlignment = gviPivotAlignment.gviPivotAlignBottomCenter;
                textSymbol.VerticalOffset = 10;
                // 注意:必须设置symbol,默认文字不显示
                textRender.Symbol = textSymbol;

                // *****定义几何物体渲染风格*****
                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                // 特别注意:此处设置了逻辑组字段,则需要在CreateFeatureLayer后设置组的可见性。否则,默认FeatureLayer将不可见。
                // 注意:必须用已注册RenderIndex的字段,否则CreateFeatureLayer创建不成功返回null
                geoRender.RenderGroupField = "Groupid";
                IImagePointSymbol geoSymbol = new ImagePointSymbol(); //将点以图片的形式显示出来
                geoSymbol.ImageName = "huang.png";                    //使用素材库里存在的图片
                geoSymbol.Size      = 25;
                geoRender.Symbol    = geoSymbol;

                FeatureLayerVisualize(ci, true, "Point", textRender, geoRender);
            }
            // 可视化Polyline类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\polyline.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                ISimpleTextRender textRender = new SimpleTextRender();
                textRender.Expression = "''..$(oid)";

                // *****定义几何物体渲染风格*****
                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                // 特别注意:此处设置了逻辑组字段,则需要在CreateFeatureLayer后设置组的可见性。否则,默认FeatureLayer将不可见。
                geoRender.RenderGroupField = "Groupid";
                ICurveSymbol geoSymbol = new CurveSymbol();
                geoSymbol.Color  = System.Drawing.Color.Red; //线颜色为Purple
                geoRender.Symbol = geoSymbol;

                FeatureLayerVisualize(ci, false, "Polyline", textRender, geoRender);
            }

            // 可视化Polygon类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\polygon.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                ISimpleTextRender textRender = new SimpleTextRender();
                textRender.Expression = "''..$(oid)";

                // *****定义几何物体渲染风格*****
                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                // 特别注意:此处设置了逻辑组字段,则需要在CreateFeatureLayer后设置组的可见性。否则,默认FeatureLayer将不可见。
                geoRender.RenderGroupField = "Groupid";
                ISurfaceSymbol geoSymbol = new SurfaceSymbol();
                geoSymbol.Color  = System.Drawing.Color.Yellow; //面填充色为Yellow
                geoRender.Symbol = geoSymbol;

                FeatureLayerVisualize(ci, false, "Polygon", textRender, geoRender);
            }

            // 可视化ModelPoint类型FeatureLayer
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\community.FDB");
                ci.Database = tmpFDBPath;

                // *******定义文字渲染风格*******
                ISimpleTextRender textRender = new SimpleTextRender();
                textRender.Expression = "''..$(oid)";

                // *****定义几何物体渲染风格*****
                ISimpleGeometryRender geoRender = new SimpleGeometryRender();
                //特别注意:此处设置了逻辑组字段,则需要在CreateFeatureLayer后设置组的可见性。否则,默认FeatureLayer将不可见。
                geoRender.RenderGroupField = "Groupid";
                IModelPointSymbol geoSymbol = new ModelPointSymbol();
                geoSymbol.Color       = System.Drawing.Color.Yellow; //模型颜色为Red
                geoSymbol.EnableColor = true;                        //需开启,否则颜色设置无效
                geoRender.Symbol      = geoSymbol;

                FeatureLayerVisualize(ci, false, "ModelPoint", textRender, geoRender);
            }
        }
Ejemplo n.º 28
0
        private void ClickQuery()
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }
            try
            {
                IFeatureLayer fl = this._drawTool.GetSelectFeatureLayerPickResult().FeatureLayer;
                if (fl == null)
                {
                    return;
                }
                int           featureId = this._drawTool.GetSelectFeatureLayerPickResult().FeatureId;
                FacilityClass facc      = Dictionary3DTable.Instance.GetFacilityClassByDFFeatureClassID(fl.FeatureClassId.ToString());
                if (facc == null || facc.Name != "PipeNode")
                {
                    XtraMessageBox.Show("您选中的不是管点设施,请选择管点设施。", "提示");
                    return;
                }
                DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fl.FeatureClassId.ToString());
                if (dffc == null || dffc.GetFeatureClass() == null)
                {
                    return;
                }
                IFeatureClass fc = dffc.GetFeatureClass();
                if (this._bFinished)
                {
                    Clear();
                    this._startFCGuid = fc.Guid.ToString();
                    this._startOid    = featureId;
                    this._bFinished   = false;

                    ILabel label = app.Current3DMapControl.ObjectManager.CreateLabel(app.Current3DMapControl.ProjectTree.RootID);
                    label.Text = "起点";
                    ITextSymbol ts = new TextSymbol();
                    ts.TextAttribute.TextSize  = SystemInfo.Instance.TextSize;
                    ts.TextAttribute.TextColor = Convert.ToUInt32(SystemInfo.Instance.TextColor, 16);
                    label.TextSymbol           = ts;
                    label.Position             = this._drawTool.GetSelectPoint();
                    this._listRGuid.Add(label.Guid);
                }
                else
                {
                    if (this._startFCGuid == fc.Guid.ToString() && this._startOid == featureId)
                    {
                        XtraMessageBox.Show("您选中的是同一个管点设施。", "提示");
                        return;
                    }
                    this._bFinished = true;
                    ILabel label = app.Current3DMapControl.ObjectManager.CreateLabel(app.Current3DMapControl.ProjectTree.RootID);
                    label.Text = "终点";
                    ITextSymbol ts = new TextSymbol();
                    ts.TextAttribute.TextSize  = SystemInfo.Instance.TextSize;
                    ts.TextAttribute.TextColor = Convert.ToUInt32(SystemInfo.Instance.TextColor, 16);
                    label.TextSymbol           = ts;
                    label.Position             = this._drawTool.GetSelectPoint();
                    this._listRGuid.Add(label.Guid);
                    if (this._startFCGuid != fc.Guid.ToString())
                    {
                        XtraMessageBox.Show("您选中的不是同一类管点设施。", "提示");
                        return;
                    }
                    else
                    {
                        WaitForm.Start("正在分析...", "请稍后");
                        FacClassReg reg = FacilityInfoService.GetFacClassRegByFeatureClassID(fc.Guid.ToString());
                        if (reg == null)
                        {
                            return;
                        }
                        TopoClass tc = FacilityInfoService.GetTopoClassByFacClassCode(reg.FacClassCode);
                        if (tc == null)
                        {
                            return;
                        }
                        TopoNetwork net = tc.GetNetwork();
                        if (net == null)
                        {
                            XtraMessageBox.Show("构建拓扑网络失败!", "提示");
                            return;
                        }
                        else
                        {
                            string        startId = this._startFCGuid + "_" + this._startOid.ToString();
                            string        endId   = fc.Guid.ToString() + "_" + featureId.ToString();
                            List <string> path;
                            double        shortestLength = net.SPFA(startId, endId, out path);
                            if ((shortestLength > 0.0 && shortestLength != double.MaxValue) || (path != null && path.Count > 0))
                            {
                                List <IPoint> listPt = new List <IPoint>();
                                foreach (string nodeId in path)
                                {
                                    int              index    = nodeId.LastIndexOf("_");
                                    string           fcguid   = nodeId.Substring(0, index);
                                    string           oid      = nodeId.Substring(index + 1, nodeId.Length - index - 1);
                                    DF3DFeatureClass dffcTemp = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fcguid);
                                    if (dffcTemp == null || dffcTemp.GetFeatureClass() == null)
                                    {
                                        continue;
                                    }
                                    if (dffcTemp.GetFacilityClassName() != "PipeNode")
                                    {
                                        continue;
                                    }
                                    IQueryFilter filter = new QueryFilter();
                                    filter.WhereClause = "oid = " + oid;
                                    filter.SubFields   = "oid,Shape";
                                    IRowBuffer row    = null;
                                    IFdeCursor cursor = null;
                                    try
                                    {
                                        cursor = dffcTemp.GetFeatureClass().Search(filter, false);
                                        while ((row = cursor.NextRow()) != null)
                                        {
                                            if (!row.IsNull(1) && (row.GetValue(1) is IGeometry))
                                            {
                                                IGeometry geo = row.GetValue(1) as IGeometry;
                                                switch (geo.GeometryType)
                                                {
                                                case gviGeometryType.gviGeometryPoint:
                                                    IPoint pt = geo as IPoint;
                                                    pt.Z = pt.Z + 1;
                                                    listPt.Add(pt);
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    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;
                                        }
                                    }
                                }
                                IPolyline polyline = (new GeometryFactory()).CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;
                                foreach (IPoint pt in listPt)
                                {
                                    ISimplePointSymbol ps = new SimplePointSymbol();
                                    ps.Size      = 5;
                                    ps.Style     = gviSimplePointStyle.gviSimplePointCircle;
                                    ps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16);
                                    IRenderPoint rp = app.Current3DMapControl.ObjectManager.CreateRenderPoint(pt, ps, app.Current3DMapControl.ProjectTree.RootID);
                                    rp.Glow(5000);
                                    polyline.AppendPoint(pt);
                                    this._listRGuid.Add(rp.Guid);
                                }
                                ICurveSymbol cs = new CurveSymbol();
                                cs.Color = Convert.ToUInt32(SystemInfo.Instance.LineColor, 16);
                                cs.Width = -5;
                                IRenderPolyline rpl = app.Current3DMapControl.ObjectManager.CreateRenderPolyline(polyline, cs, app.Current3DMapControl.ProjectTree.RootID);
                                rpl.Glow(5000);
                                this._listRGuid.Add(rpl.Guid);
                            }
                            else
                            {
                                XtraMessageBox.Show("两点不连通!", "提示");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("分析出错!", "提示");
            }
            finally
            {
                WaitForm.Stop();
            }
        }
Ejemplo n.º 29
0
        /// <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;
        }
Ejemplo n.º 30
0
        private void btnApply_Click(object sender, System.EventArgs e)
        {
            string script = this.txtScript.Text.Trim();

            if (script != "")
            {
                IGeometryRender render = selectedLayer.GetGeometryRender();
                if (render != null)
                {
                    if (render.RenderType == gviRenderType.gviRenderSimple)
                    {
                        ISimpleGeometryRender simpleRender = render as ISimpleGeometryRender;
                        IGeometrySymbol       geoSymbol    = simpleRender.Symbol;
                        geoSymbol.Script    = script;
                        simpleRender.Symbol = geoSymbol;
                        if (!selectedLayer.SetGeometryRender(simpleRender))
                        {
                            MessageBox.Show("错误码为:" + this.axRenderControl1.GetLastError());
                        }
                    }
                }
                else
                {
                    ISimpleGeometryRender simpleRender = new SimpleGeometryRender();
                    switch (type)
                    {
                    case LayerType.ModelPoint:
                    {
                        IModelPointSymbol mps = new ModelPointSymbol();
                        mps.Script          = script;
                        simpleRender.Symbol = mps;
                    }
                    break;

                    case LayerType.Polyline:
                    {
                        ICurveSymbol cs = new CurveSymbol();
                        cs.Script           = script;
                        simpleRender.Symbol = cs;
                    }
                    break;

                    case LayerType.Point:
                    {
                        if (script.Contains("<ImageName>"))
                        {
                            IImagePointSymbol ips = new ImagePointSymbol();
                            ips.Script          = script;
                            simpleRender.Symbol = ips;
                        }
                        else
                        {
                            ISimplePointSymbol sps = new SimplePointSymbol();
                            sps.Script          = script;
                            simpleRender.Symbol = sps;
                        }
                    }
                    break;

                    case LayerType.Polygon:
                    {
                        if (script.Contains("<Height>"))
                        {
                            IPolygon3DSymbol p3s = new Polygon3DSymbol();
                            p3s.Script          = script;
                            simpleRender.Symbol = p3s;
                        }
                        else
                        {
                            ISurfaceSymbol ss = new SurfaceSymbol();
                            ss.Script           = script;
                            simpleRender.Symbol = ss;
                        }
                    }
                    break;
                    }
                    if (!selectedLayer.SetGeometryRender(simpleRender))
                    {
                        MessageBox.Show("错误码为:" + this.axRenderControl1.GetLastError());
                    }
                }
            }
            else
            {
                selectedLayer.SetGeometryRender(null);
            }
        }