Ejemplo n.º 1
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.º 2
0
        private void Calc(IPolygon polygon, double referenceHeight)
        {
            if (polygon == null)
            {
                return;
            }
            polygon.Close();
            IGeometryFactory geoFact     = new GeometryFactoryClass();
            IMultiPolygon    cutPolygon  = geoFact.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon;
            IMultiPolygon    fillPolygon = geoFact.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon;
            double           cutVolumn   = 0.0;
            double           fillVolumn  = 0.0;
            ITerrainAnalyse  ta          = new TerrainAnalyse();

            ta.OnProcessing = _cb;
            ta.CalculateCutFill(polygon, 0.0, referenceHeight, ref cutPolygon, ref fillPolygon, ref cutVolumn, ref fillVolumn);

            //double surfaceArea = ta.GetSurfaceArea(polygon, 0.0);
            //string res = "挖  方  量:" + cutVolumn.ToString("0.000") + " 立方米\r\n填  方  量:" + fillVolumn.ToString("0.000") + " 立方米\r\n" +
            //    "投影面积:" + polygon.Area().ToString("0.000") + " 平方米\r\n地表面积:" + surfaceArea.ToString("0.000") + " 平方米\r\n";
            string res = "挖方量:" + cutVolumn.ToString("0.000") + " 立方米\r\n填方量:" + fillVolumn.ToString("0.000") + " 立方米";

            if (_label != null)
            {
                _label.Text = res;
            }
            this.lcInfo.Text = res;

            if (cutPolygon != null)
            {
                SurfaceSymbol ss = new SurfaceSymbol();
                ss.Color                 = 0xffc04000;
                _rCutPolygon             = d3.ObjectManager.CreateRenderMultiPolygon(cutPolygon, ss, d3.ProjectTree.RootID);
                _rCutPolygon.HeightStyle = gviHeightStyle.gviHeightOnTerrain;
                if (this.ceCutRegion.Checked)
                {
                    _rCutPolygon.VisibleMask = gviViewportMask.gviViewAllNormalView;
                }
                else
                {
                    _rCutPolygon.VisibleMask = gviViewportMask.gviViewNone;
                }
            }
            if (fillPolygon != null)
            {
                SurfaceSymbol ss = new SurfaceSymbol();
                ss.Color                  = 0xff0000c0;
                _rFillPolygon             = d3.ObjectManager.CreateRenderMultiPolygon(fillPolygon, ss, d3.ProjectTree.RootID);
                _rFillPolygon.HeightStyle = gviHeightStyle.gviHeightOnTerrain;
                if (this.ceFillRegion.Checked)
                {
                    _rFillPolygon.VisibleMask = gviViewportMask.gviViewAllNormalView;
                }
                else
                {
                    _rFillPolygon.VisibleMask = gviViewportMask.gviViewNone;
                }
            }
        }