Exemple #1
0
        private void btnSplitModelPoint_Click(object sender, EventArgs e)
        {
            cbShowSrcModelPoint.Checked = false;

            if (_multiPolygon.GeometryCount == 0)
            {
                _multiPolygon.AddGeometry(fde_polygon);
            }

            _gc.SplitModelPointByPolygon2D(_multiPolygon, ModelSrc, ModelPointSrc, out modelInterior, out mpInterior, out modelExterior, out mpExterior);

            if (modelInterior != null && mpInterior != null)
            {
                this.axRenderControl1.ObjectManager.AddModel(mpInterior.ModelName, modelInterior);
                rmpInterior = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mpInterior, null, rootId);
                guidToDelList.Add(rmpInterior.Guid);
                cbHideInteriorModelPoint.Enabled = true;
                btnDelInteriorModelPoint.Enabled = true;
            }

            if (modelExterior != null && mpExterior != null)
            {
                this.axRenderControl1.ObjectManager.AddModel(mpExterior.ModelName, modelExterior);
                rmpExterior = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mpExterior, null, rootId);
                guidToDelList.Add(rmpExterior.Guid);
                cbHideExteriorModelPoint.Enabled = true;
                btnDelExteriorModelPoint.Enabled = true;
            }
        }
Exemple #2
0
        public void SearchModelPoint(IPolygon tarPolygon)
        {
            this.axRenderControl1.FeatureManager.UnhighlightAll();

            IRowBuffer row = null;

            foreach (IFeatureClass fc in fcMap.Keys)
            {
                if (!fc.Name.Equals("Building"))
                {
                    continue;
                }

                IFdeCursor cursor = null;
                try
                {
                    ISpatialFilter filter = new SpatialFilter();
                    filter.Geometry      = tarPolygon;
                    filter.SpatialRel    = gviSpatialRel.gviSpatialRelEnvelope; //用不相离查不出来
                    filter.GeometryField = "Geometry";
                    cursor = fc.Search(filter, false);
                    while ((row = cursor.NextRow()) != null)
                    {
                        int oid = (int)row.GetValue(0);
                        this.axRenderControl1.FeatureManager.SetFeatureVisibleMask(fc, oid, gviViewportMask.gviViewNone);

                        int         geoPos = row.FieldIndex("Geometry");
                        IModelPoint mp     = row.GetValue(geoPos) as IModelPoint;
                        if (geoConvertor == null)
                        {
                            geoConvertor = new GeometryConvertor();
                        }
                        if (mPolygon == null)
                        {
                            mPolygon = (new GeometryFactory()).CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon;
                        }
                        mPolygon.Clear();
                        mPolygon.AddGeometry(tarPolygon);

                        GetZToolStripTextBox();

                        IResourceManager rm            = fc.FeatureDataSet as IResourceManager;
                        IModel           model         = rm.GetModel(mp.ModelName);
                        IModel           modelInterior = null;
                        IModelPoint      mpInterior    = null;
                        IModel           modelExterior = null;
                        IModelPoint      mpExterior    = null;
                        if (minz == maxz)
                        {
                            geoConvertor.SplitModelPointByPolygon2D(mPolygon, model, mp, out modelInterior, out mpInterior, out modelExterior, out mpExterior);
                        }
                        else
                        {
                            geoConvertor.SplitModelPointByPolygon2DWithZ(mPolygon, model, mp, minz, maxz, out modelInterior, out mpInterior, out modelExterior, out mpExterior);
                        }

                        if (modelExterior != null)
                        {
                            this.axRenderControl1.ObjectManager.AddModel(fc.Name + oid + "Exterior", modelExterior);
                            mpExterior.ModelName = fc.Name + oid + "Exterior";

                            string[] imagenames = modelExterior.GetImageNames();
                            for (int j = 0; j < imagenames.Length; j++)
                            {
                                IImage image = rm.GetImage(imagenames[j]);
                                this.axRenderControl1.ObjectManager.AddImage(imagenames[j], image);
                            }
                            IRenderModelPoint rrrr = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mpExterior, null, rootId);
                            lll.Add(rrrr);
                        }
                    }
                }
                catch (COMException ex)
                {
                    System.Diagnostics.Trace.WriteLine(ex.Message);
                }
                finally
                {
                    if (cursor != null)
                    {
                        //Marshal.ReleaseComObject(cursor);
                        cursor = null;
                    }
                }
            } // end of foreach (IFeatureClass fc in fcMap.Keys)
        }