private void Btn_ApplyRasterBaseSurface_Click(object sender, EventArgs e) { ILayer pBaseLayer = m_pTarScene.Layer[CbBoxBaseLayer.SelectedIndex]; ILayer pDisplayLayer = m_pTarLayer; IRasterSurface pBaseSurfaceRaster = new RasterSurface(); IRasterLayer pBaseRasterLayer = pBaseLayer as IRasterLayer; IRaster pBaseRaster = (IRaster)pBaseRasterLayer.Raster; IRasterBandCollection pBaseRasterBandCollection = pBaseRaster as IRasterBandCollection; IRasterBand pBaseRasterBand = pBaseRasterBandCollection.Item(0); pBaseSurfaceRaster.RasterBand = pBaseRasterBand; ISurface pBaseSurface = pBaseSurfaceRaster as ISurface; ILayerExtensions pLayerExtensions = pDisplayLayer as ILayerExtensions; I3DProperties p3DProperties = null; for (int i = 0; i < pLayerExtensions.ExtensionCount; i++) { object pCurExtension = pLayerExtensions.get_Extension(i); if (pCurExtension != null) { p3DProperties = (I3DProperties)pCurExtension; break; } } p3DProperties.BaseOption = esriBaseOption.esriBaseSurface; p3DProperties.BaseSurface = pBaseSurface; p3DProperties.Apply3DProperties(pDisplayLayer); p3DProperties.ZFactor = 1; m_pTarScene.SceneGraph.RefreshViewers(); }
private void ExtrusionPropertyPage_Load(object sender, EventArgs e) { ILayerExtensions extensions = this.ilayer_0 as ILayerExtensions; this.cboExtrusionType.SelectedIndex = 0; for (int i = 0; i <= (extensions.ExtensionCount - 1); i++) { if (extensions.get_Extension(i) is I3DProperties) { I3DProperties properties = extensions.get_Extension(i) as I3DProperties; this.i3DProperties_0 = properties; if (this.i3DProperties_0.ExtrusionType == esriExtrusionType.esriExtrusionNone) { this.chkExtrusion.Checked = false; this.cboExtrusionType.Enabled = false; } else { this.chkExtrusion.Checked = true; this.cboExtrusionType.SelectedIndex = ((int)this.i3DProperties_0.ExtrusionType) - 1; } this.txtExtrusionValue.Text = this.i3DProperties_0.ExtrusionExpressionString; break; } } this.bool_0 = true; }
private void 影像叠加ToolStripMenuItem_Click(object sender, System.EventArgs e) { ISceneGraph pSceneGraph = this.axSceneControl1.SceneGraph; IScene pScene = pSceneGraph.Scene; ILayer layer = pScene.get_Layer(0); ITinLayer tinLayer = layer as ITinLayer; layer = pScene.get_Layer(1); IRasterLayer rasterLayer = layer as IRasterLayer; ITinAdvanced tinAdvanced; ISurface surface; tinAdvanced = tinLayer.Dataset as ITinAdvanced; surface = tinAdvanced.Surface; ILayerExtensions layerExtensions = (ILayerExtensions)rasterLayer; I3DProperties i3dProperties = null; for (int i = 0; i < layerExtensions.ExtensionCount; i++) { if (layerExtensions.get_Extension(i) is I3DProperties) { i3dProperties = (I3DProperties)layerExtensions.get_Extension(i); } }//get 3d properties from extension i3dProperties.BaseOption = esriBaseOption.esriBaseSurface; i3dProperties.BaseSurface = surface; i3dProperties.Apply3DProperties(rasterLayer); pSceneGraph.RefreshViewers(); }
public void SetTinLayerHeight(ITinLayer pTinLayer, double tinHeight) { I3DProperties p3DProps = get3DProps(pTinLayer); if (p3DProps != null) { p3DProps.BaseOption = esriBaseOption.esriBaseExpression; p3DProps.BaseExpressionString = tinHeight.ToString(); p3DProps.Apply3DProperties(pTinLayer); } }
private void SetTinAsBase(ITinLayer tinLayer) { I3DProperties _3DProps = get3DProps(tinLayer); if (_3DProps != null) { _3DProps.BaseOption = esriBaseOption.esriBaseSurface; _3DProps.BaseSurface = tinLayer as IFunctionalSurface; _3DProps.Apply3DProperties(tinLayer); } }
private I3DProperties get3DProps(ITinLayer tinLayer) { I3DProperties _3DProps = null; ILayerExtensions lyrExt = tinLayer as ILayerExtensions; for (int i = 0; i < lyrExt.ExtensionCount; i++) { if (lyrExt.get_Extension(i) is I3DProperties) { _3DProps = lyrExt.get_Extension(i) as I3DProperties; } } return(_3DProps); }
public void RunCommand() { try { IFeatureCursor ifeatureCursor_ = null; I3DProperties i3DProperties = null; if (this.cmbBuildingLayer.SelectedItem is LayerObject) { IFeatureLayer featureLayer = (this.cmbBuildingLayer.SelectedItem as LayerObject).Layer as IFeatureLayer; if (this.chkSelFeatures.Checked) { IFeatureSelection featureSelection = featureLayer as IFeatureSelection; ICursor cursor; featureSelection.SelectionSet.Search(null, true, out cursor); ifeatureCursor_ = (cursor as IFeatureCursor); } else { ifeatureCursor_ = featureLayer.Search(null, true); } i3DProperties = frmFeaturesToBuildings.Get3DPropsFromLayer(featureLayer); } else if (this.cmbBuildingLayer.SelectedItem is ObjectWrap) { IFeatureClass featureClass = (this.cmbBuildingLayer.SelectedItem as ObjectWrap).Object as IFeatureClass; ifeatureCursor_ = featureClass.Search(null, true); } int int_ = -1; if (this.chkConst.Checked) { if (i3DProperties != null && i3DProperties.ExtrusionExpressionString.Length == 0) { int_ = int.Parse(BuildingProperty.BuildingHieght); } else { int_ = -1; } modFacades.CreateFacades(BuildingProperty.TargetLayer, ifeatureCursor_, i3DProperties as IFeature3DProperties, "", int_, null, BuildingProperty.TextureGroups, true); } else { modFacades.CreateFacades(BuildingProperty.TargetLayer, ifeatureCursor_, i3DProperties as IFeature3DProperties, this.cmbHeight.Text, int_, null, BuildingProperty.TextureGroups, true); } } catch { } }
public I3DProperties Get3DPropsFromLayer(ILayer pLyr) { ILayerExtensions pLyrExts = (ILayerExtensions)pLyr; I3DProperties p3DProp = null; for (int i = 0; i < pLyrExts.ExtensionCount; i++) { if (pLyrExts.get_Extension(i) is I3DProperties) { p3DProp = (I3DProperties)pLyrExts.get_Extension(i); } }//get 3d properties from extension return(p3DProp); }
public IRasterSurface GetSurfFormLayer(IRasterLayer pRLayer) { I3DProperties p3DProp = Get3DPropsFromLayer((pRLayer)); //获取图层的基准面 IRasterSurface pRSurf = (IRasterSurface)p3DProp.BaseSurface; //如果空 则取栅格的第一个波段 if (pRSurf == null) { //MessageBox.Show("null"); pRSurf = new RasterSurfaceClass(); IRasterBandCollection bands = (IRasterBandCollection)pRLayer.Raster; pRSurf.RasterBand = bands.Item(0); } return(pRSurf); }
private void FrmSceneLayerOffest_Load(object sender, EventArgs e) { // 读取偏移高程 if (m_pSceneCtrl != null) { IScene pScene = m_pSceneCtrl.Scene; ILayerExtensions layerextensions = pLayer as ILayerExtensions; //I3DProperties properties = null; if (pLayer is IRasterLayer) { properties = new Raster3DPropertiesClass(); } if (pLayer is IFeatureLayer) { properties = new Feature3DPropertiesClass(); } if (pLayer is ITinLayer) { properties = new Tin3DPropertiesClass(); } object p3d; for (int j = 0; j < layerextensions.ExtensionCount; j++) { p3d = layerextensions.get_Extension(j); if (p3d != null) { properties = p3d as I3DProperties; if (properties != null) { break; } } } try { numericUpDownOffset.Value = Convert.ToDecimal(properties.OffsetExpressionString); } catch { } // properties.OffsetExpressionString = doubleInputOffset.Value.ToString(); //IActiveView iv = m_pSceneCtrl.Scene as IActiveView; //iv.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null); } }
public static ISurface GetBaseSurface(ILayer ilayer_0) { ISurface result = null; ILayerExtensions layerExtensions = ilayer_0 as ILayerExtensions; for (int i = 0; i <= layerExtensions.ExtensionCount - 1; i++) { if (layerExtensions.get_Extension(i) is I3DProperties) { I3DProperties i3DProperties = layerExtensions.get_Extension(i) as I3DProperties; if (i3DProperties.BaseOption == esriBaseOption.esriBaseSurface && i3DProperties.BaseSurface != null) { result = (i3DProperties.BaseSurface as ISurface); } return(result); } } return(result); }
public void SetlayerSurface(IRasterLayer pRlayer, int ZFactor) { //获取3DProp I3DProperties p3DProp = Get3DPropsFromLayer((ILayer)pRlayer); p3DProp.BaseOption = esriBaseOption.esriBaseSurface; //设置基准高 IRasterSurface pRSurf = GetSurfFormLayer(pRlayer); p3DProp.BaseSurface = (IFunctionalSurface)pRSurf; //设置Z因子 p3DProp.ZFactor = ZFactor; //图层渲染优先级,越小优先级越大; p3DProp.DepthPriorityValue = 0; p3DProp.Apply3DProperties(pRlayer);//I3DProperties中唯一的一个方法,用来执行变更后的属性。 }
private void SceneRenderPropertyPage_Load(object sender, EventArgs e) { ILayerExtensions extensions = this.ilayer_0 as ILayerExtensions; for (int i = 0; i <= (extensions.ExtensionCount - 1); i++) { if (extensions.get_Extension(i) is I3DProperties) { I3DProperties properties = extensions.get_Extension(i) as I3DProperties; this.i3DProperties_0 = properties; if (this.i3DProperties_0.RenderMode == esriRenderMode.esriRenderCache) { this.rdordoRenderCache.Checked = true; } else if (this.i3DProperties_0.RenderMode == esriRenderMode.esriRenderImmediate) { this.rdoRenderImmediate.Checked = true; } if (this.i3DProperties_0.RenderVisibility == esriRenderVisibility.esriRenderAlways) { this.rdoRenderAlways.Checked = true; } else if (this.i3DProperties_0.RenderVisibility == esriRenderVisibility.esriRenderWhenNavigating) { this.rdoRenderWhenNavigating.Checked = true; } else if (this.i3DProperties_0.RenderVisibility == esriRenderVisibility.esriRenderWhenStopped) { this.rdoRenderWhenStopped.Checked = true; } this.txtRenderRefreshRate.Value = (decimal)this.i3DProperties_0.RenderRefreshRate; this.chkIlluminate.Checked = this.i3DProperties_0.Illuminate; this.chkSmoothShading.Checked = this.i3DProperties_0.SmoothShading; this.cboDepthPriorityValue.SelectedIndex = this.i3DProperties_0.DepthPriorityValue - 1; break; } } this.bool_1 = true; }
public static I3DProperties Get3DPropsFromLayer(ILayer ilayer_0) { I3DProperties result; try { ILayerExtensions layerExtensions = ilayer_0 as ILayerExtensions; for (int i = 0; i <= layerExtensions.ExtensionCount - 1; i++) { I3DProperties i3DProperties = layerExtensions.get_Extension(i) as I3DProperties; if (i3DProperties != null) { result = i3DProperties; return(result); } } } catch { } result = null; return(result); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { try { if (m_application == null) { return; } IDocument document = m_application.Document; ISxDocument sxDocument = (ISxDocument)(document); if (sxDocument != null) { m_scene = sxDocument.Scene; } if (m_scene == null) { return; } activeView = m_scene as IActiveView; //有图层选图层 if (m_scene.LayerCount == 0) { return; } //选择基准面 if (Common.SelectLayer(m_scene.Layers, out SelectedLyrIndex, true, "选择自定义表面") == false) { return; } //QI IRasterLayer baseRasterLayer = m_scene.Layer[SelectedLyrIndex[0]] as IRasterLayer; //不管选多少个只选第一个 if (baseRasterLayer == null) { throw new ArgumentNullException("自定义表面RasterLayer转换失败,为空。"); } IRaster raster = baseRasterLayer.Raster; if (raster == null) { throw new ArgumentNullException("自定义表面Raster转换失败,为空。"); } IRasterSurface rasterSurface = new RasterSurfaceClass(); rasterSurface.PutRaster(raster, 0); ISurface surface = rasterSurface as ISurface; //选择图层 if (Common.SelectLayer(m_scene.Layers, out SelectedLyrIndex, false, "选择要进行偏移的图层") == false) { return; } //选择倍数 NumSelect MultiNS = new NumSelect("输入夸大倍数", true); if (MultiNS.ShowDialog() != DialogResult.OK) { return; } double Multiplier = MultiNS.Result; //选择偏移量 NumSelect NS = new NumSelect(); if (NS.ShowDialog() != DialogResult.OK) { return; } double Offset = NS.Result; bool DisableCache = NS.DisableCache; //Create a CancelTracker. ITrackCancel pTrackCancel = new CancelTrackerClass(); //Create the ProgressDialog. This automatically displays the dialog IProgressDialogFactory pProgDlgFactory = new ProgressDialogFactoryClass(); IProgressDialog2 pProDlg = pProgDlgFactory.Create(pTrackCancel, m_application.hWnd) as IProgressDialog2; pProDlg.CancelEnabled = true; pProDlg.Title = "正在进行自定义表面设置及偏移调整"; pProDlg.Description = "设置中,请稍候..."; pProDlg.Animation = esriProgressAnimationTypes.esriProgressSpiral; IStepProgressor pStepPro = pProDlg as IStepProgressor; pStepPro.MinRange = 0; pStepPro.MaxRange = SelectedLyrIndex.Count; pStepPro.StepValue = 1; pStepPro.Message = "初始化中..."; bool bCont = true; //对每一个选中的图层进行操作 for (int i = 0; i < SelectedLyrIndex.Count; i++) { //m_application.StatusBar.set_Message(0, i.ToString()); pStepPro.Message = "已完成(" + i.ToString() + "/" + SelectedLyrIndex.Count.ToString() + ")"; bCont = pTrackCancel.Continue(); if (!bCont) { break; } //选中一个栅格图层 IRasterLayer rasterLayer = m_scene.Layer[SelectedLyrIndex[i]] as IRasterLayer; if (rasterLayer == null) { pStepPro.Message = "选中的图层非栅格图层..."; continue; } I3DProperties p3DProperties = null; ILayerExtensions layerExtensions = rasterLayer as ILayerExtensions; //遍历LayerExtensions找到I3DProperties for (int j = 0; j < layerExtensions.ExtensionCount; j++) { if (layerExtensions.get_Extension(j) is I3DProperties) { p3DProperties = layerExtensions.get_Extension(j) as I3DProperties; } } //设置I3DProperties p3DProperties.ZFactor = Multiplier; //系数 p3DProperties.BaseOption = esriBaseOption.esriBaseSurface; //基准面浮动 p3DProperties.BaseSurface = surface; //基准面 p3DProperties.OffsetExpressionString = Offset.ToString(); //偏移常量 if (DisableCache) { p3DProperties.RenderMode = esriRenderMode.esriRenderImmediate; //直接从文件渲染 p3DProperties.RenderVisibility = esriRenderVisibility.esriRenderWhenStopped; //停止导航时渲染 } p3DProperties.Apply3DProperties(rasterLayer); } pProDlg.HideDialog(); //========================================== //刷新,不起作用 if (activeView == null) { throw new Exception("活动视图为空! "); } if (m_sceneHookHelper.ActiveViewer == null) { throw new Exception("无活动视图!"); } activeView.Refresh(); m_sceneHookHelper.ActiveViewer.Redraw(true); //========================================== } catch (Exception err) { MessageBox.Show(err.ToString()); } }
private void buttonOK_Click(object sender, EventArgs e) { //高程底面 ILayer pBaseLayer = null; ISurface pSurface = null; if (m_pSceneCtrl != null) { try { // m_pSceneCtrl.LoadSxFile(ClsGDBDataCommon.GetParentPathofExe() +@"Resource\DefaultData\Default.sxd"); } catch { } //IScene pScene = new SceneClass(); //pScene.Name = "Scene"; //m_pSceneCtrl.Scene = pScene; IScene pScene = m_pSceneCtrl.Scene; pScene.Name = "Scene"; //ILayer pglayer = new GraphicsLayer3DClass(); //pScene.AddLayer(pglayer); //pScene.ActiveGraphicsLayer = new CompositeGraphicsLayerClass(); pScene.ExaggerationFactor = Convert.ToDouble(doubleInputExaFactor.Value.ToString()); while (pScene.LayerCount > 0) { pScene.DeleteLayer(pScene.get_Layer(0)); } // pScene.ClearLayers(); pScene.AddLayer(pScene.ActiveGraphicsLayer); GC.Collect(); for (int i = 0; i < m_pMapCtrl.Map.LayerCount; i++) { ILayer pMapLayer = m_pMapCtrl.Map.get_Layer(i); ILayer pLayer = pMapLayer; if (comboBoxExBaseHeightLayer.Items.Count > 0) { if (pLayer.Name == comboBoxExBaseHeightLayer.SelectedItem.ToString()) { pBaseLayer = pLayer; } } } if (pBaseLayer is IRasterLayer) { IRaster pRaster = ((IRasterLayer)pBaseLayer).Raster; IRasterBand pBand = ((IRasterBandCollection)pRaster).Item(0); IRasterSurface rsurface = new RasterSurface(); rsurface.RasterBand = pBand; //将dem的数据指定为surface pSurface = rsurface as ISurface; } if (pBaseLayer is ITinLayer) { ITin pTin = ((ITinLayer)pBaseLayer).Dataset; ITinSurface pTinSurface = pTin as ITinSurface; pSurface = pTinSurface as ISurface; } for (int i = 0; i < m_pMapCtrl.Map.LayerCount; i++) { ILayer pMapLayer = m_pMapCtrl.Map.get_Layer(i); ILayer pLayer = pMapLayer; string filepath = ""; string filename = ""; string sourcepath = GetDataLayerPath(pMapLayer as IDataLayer, ref filepath, ref filename); //if (pMapLayer is IRasterLayer) //{ // IRasterLayer prl = new RasterLayerClass(); // prl.CreateFromRaster(((IRasterLayer)pMapLayer).Raster); // pLayer = prl as ILayer; //} if (pMapLayer is IFeatureLayer) { // if (((IFeatureLayer)pMapLayer).FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultiPatch) // { IFeatureLayer pfl = new FeatureLayerClass(); IFeatureClass pFc = ((IFeatureLayer)pMapLayer).FeatureClass; if (pFc != null) { pfl.FeatureClass = ((IFeatureLayer)pMapLayer).FeatureClass; pLayer = pfl as ILayer; pLayer.Name = pMapLayer.Name; ///////////////////////////////////////////////////////////////////// //后期添加,用于带进涂层渲染 ///////////////////////////////////////////////////////////////////// IGeoFeatureLayer pGeoFLayer = pfl as IGeoFeatureLayer; IGeoFeatureLayer pGFMapLayer = pMapLayer as IGeoFeatureLayer; if (pGFMapLayer != null) //注记图层为空 { pGeoFLayer.Renderer = pGFMapLayer.Renderer; ILegendInfo pLegend3D = (ILegendInfo)pGeoFLayer; for (int k = 0; k < pLegend3D.LegendGroupCount; k++) { ILegendGroup pLgroup = pLegend3D.LegendGroup[k]; for (int p = 0; p < pLgroup.ClassCount; p++) { ILegendClass pLClass = pLgroup.Class[p]; if (pLClass.Symbol is IMarkerSymbol) { IMarkerSymbol pSMSymbol = pLClass.Symbol as IMarkerSymbol; pSMSymbol.Size /= 20; } } } if (pFc.ShapeType == esriGeometryType.esriGeometryMultipoint || pFc.ShapeType == esriGeometryType.esriGeometryPoint) { if (pGFMapLayer.Renderer is IUniqueValueRenderer) { } } } } // } } #region 这段代码家的有点重复,如果不加有时候会弹出设置数据源的对话框 if (pLayer is IRasterLayer) { I3DProperties properties = null; properties = new Raster3DPropertiesClass(); ILayerExtensions layerextensions = pLayer as ILayerExtensions; object p3d; for (int j = 0; j < layerextensions.ExtensionCount; j++) { p3d = layerextensions.get_Extension(j); if (p3d != null) { properties = p3d as I3DProperties; if (properties != null) { break; } } } properties.BaseOption = esriBaseOption.esriBaseSurface; properties.BaseSurface = pSurface; //I、更改分辨率后,如何让分辨率设置发挥作用。主要是刷新的问题(使用IActiveView刷新、而不能使用Iscene及IScenegraph刷新) //II、分辨率数值在( 262144-268435456)范围之内,越大越清晰。使用3DProperties.MaxTextureMemory 方法 properties.MaxTextureMemory = 268435456; } #endregion pScene.AddLayer(pLayer); //if (((CheckBoxItem)itemPanelSetVisible.Items[i]).Checked == false) //{ // pLayer.Visible = false; //} //else //{ // pLayer.Visible = true; //} if (comboBoxExBaseHeightLayer.Items.Count > 0) { if (pLayer.Name == comboBoxExBaseHeightLayer.SelectedItem.ToString()) { pBaseLayer = pLayer; } } } } if (pSurface != null) { for (int i = 0; i < m_pSceneCtrl.Scene.LayerCount; i++) { ILayer pLayer = m_pSceneCtrl.Scene.get_Layer(i); ILayerExtensions layerextensions = m_pSceneCtrl.Scene.get_Layer(i) as ILayerExtensions; I3DProperties properties = null; if (pLayer is IRasterLayer) { properties = new Raster3DPropertiesClass(); } if (pLayer is IFeatureLayer) { properties = new Feature3DPropertiesClass(); } if (pLayer is ITinLayer) { properties = new Tin3DPropertiesClass(); } object p3d; for (int j = 0; j < layerextensions.ExtensionCount; j++) { p3d = layerextensions.get_Extension(j); if (p3d != null) { properties = p3d as I3DProperties; if (properties != null) { break; } } } if (!(pLayer is IFeatureLayer)) { properties.BaseOption = esriBaseOption.esriBaseSurface; properties.BaseSurface = pSurface; //I、更改分辨率后,如何让分辨率设置发挥作用。主要是刷新的问题(使用IActiveView刷新、而不能使用Iscene及IScenegraph刷新) //II、分辨率数值在( 262144-268435456)范围之内,越大越清晰。使用3DProperties.MaxTextureMemory 方法 properties.MaxTextureMemory = 268435456; } else { IFeatureLayer pFlayer = pLayer as IFeatureLayer; //multipatch的本身有高度信息 if (pFlayer.FeatureClass != null && pFlayer.FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultiPatch) { bool needConstantHeight = false; /* * try * { * //把导航点转向角,视场角等信息都设置成不贴在表面而需要根据生产该信息的文件设置高度 * IFeatureClass fc = pFlayer.FeatureClass; * IFeatureCursor pFcursor = fc.Search(null, false); * int OriginalFeatureidx = fc.FindField("OriginalFeatureClass"); * int OriginalFeatureOIDidx = fc.FindField("OID"); * IFeature pF = pFcursor.NextFeature(); * IFeatureLayer pOFeatureLayer = null; * if (OriginalFeatureidx == -1|| OriginalFeatureOIDidx == -1) * { * pF = null; * } * else * { * if (pF != null) * { * //获取路径点图层名称 * string orignalname = pF.get_Value(OriginalFeatureidx).ToString(); * IMap pMap = m_pMapCtrl.Map; * for (int k = 0; k < pMap.LayerCount; k++) * { * if (pMap.get_Layer(k).Name.Equals(orignalname)) * { * pOFeatureLayer = pMap.get_Layer(k) as IFeatureLayer; * break; * } * } * if (pOFeatureLayer == null) * { * pF = null; * } * } * } * * while (pF != null) * { * //IFeatureClass pFClass = pOFeatureLayer.FeatureClass; * //pFClass.FindField(OriginalFeatureOIDidx); * * * pF = pFcursor.NextFeature(); * } * } * catch * { * ; * } */ if (needConstantHeight == false) { properties.BaseOption = esriBaseOption.esriBaseSurface; //I3DProperties2 pr = properties as I3DProperties2; //if (pr != null) //{ // pr.OffsetExpressionString = "0.005"; //} // properties.BaseOption = esriBaseOption.esriBaseExpression; properties.BaseSurface = pSurface; //I、更改分辨率后,如何让分辨率设置发挥作用。主要是刷新的问题(使用IActiveView刷新、而不能使用Iscene及IScenegraph刷新) //II、分辨率数值在( 262144-268435456)范围之内,越大越清晰。使用3DProperties.MaxTextureMemory 方法 properties.MaxTextureMemory = 268435456; } } } // properties.Apply3DProperties(domlayer); // ps.SceneGraph.RefreshViewers(); IActiveView iv = m_pSceneCtrl.Scene as IActiveView; iv.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null); } } }
private void BaseHeightPropertyPage_Load(object sender, EventArgs e) { int num; for (num = 0; num < this.ibasicMap_0.LayerCount; num++) { ILayer layer = this.ibasicMap_0.get_Layer(num); ISurface surface = this.method_0(layer); if (surface != null) { this.cboSufer.Items.Add(new SuferWrap(surface)); } } ILayerExtensions extensions = this.ilayer_0 as ILayerExtensions; for (int i = 0; i <= (extensions.ExtensionCount - 1); i++) { if (extensions.get_Extension(i) is I3DProperties) { I3DProperties properties = extensions.get_Extension(i) as I3DProperties; this.i3DProperties_0 = properties; if (properties.BaseOption != esriBaseOption.esriBaseSurface) { if (properties.BaseOption == esriBaseOption.esriBaseExpression) { this.rdoBaseExpression.Checked = true; this.txtBaseExpression.Text = properties.BaseExpressionString; } else { this.rdoBaseShape.Checked = true; } } else if (properties.BaseSurface != null) { this.rdoBaseSurface.Checked = true; ISurface baseSurface = properties.BaseSurface as ISurface; bool flag = true; for (num = 0; num < this.cboSufer.Items.Count; num++) { if ((this.cboSufer.Items[num] as SuferWrap).Surface == baseSurface) { this.cboSufer.SelectedIndex = num; flag = false; break; } } if (flag) { this.cboSufer.Items.Add(new SuferWrap(baseSurface)); this.cboSufer.SelectedIndex = this.cboSufer.Items.Count - 1; } } this.txtOffset.Text = properties.OffsetExpressionString; this.txtZFeator.Text = properties.ZFactor.ToString(); break; } } if (this.ilayer_0 is IFeatureLayer) { IFeatureClass featureClass = (this.ilayer_0 as IFeatureLayer).FeatureClass; if (featureClass != null) { int index = featureClass.Fields.FindField(featureClass.ShapeFieldName); if (!featureClass.Fields.get_Field(index).GeometryDef.HasZ) { this.rdoBaseShape.Enabled = false; } else { this.rdoBaseShape.Enabled = true; if (this.rdoBaseShape.Checked) { this.rdoBaseExpression.Checked = true; } } } } else { this.rdoBaseShape.Enabled = false; if (this.rdoBaseShape.Checked) { this.rdoBaseExpression.Checked = true; } } if (this.cboSufer.Items.Count == 0) { this.rdoBaseSurface.Enabled = false; this.cboSufer.Enabled = false; if (this.rdoBaseSurface.Checked) { this.rdoBaseExpression.Checked = true; } } }
public static IGroupElement CreateFacadesFromPolygon(IFeature ifeature_0, IFeature3DProperties ifeature3DProperties_0, clsTextureGroup clsTextureGroup_0, ISurface isurface_0, string string_0, IPolygon ipolygon_0, bool bool_0) { IGroupElement groupElement = null; IGroupElement result; try { IEncode3DProperties encode3DProperties = new GeometryEnvironment() as IEncode3DProperties; IGroupElement groupElement2 = new GroupElement() as IGroupElement; if (modFacades.m_limitAngle == 0.0) { modFacades.m_limitAngle = 0.5235987666666666; } IGeometry geometry = null; if (ifeature_0 != null) { if (ifeature3DProperties_0 != null && bool_0) { ifeature3DProperties_0.ApplyFeatureProperties(ifeature_0, out geometry, false); } else { geometry = ifeature_0.Shape; } } else if (ipolygon_0 != null) { geometry = ipolygon_0; } if (geometry == null) { result = null; return(result); } if (!(geometry is IMultiPatch)) { } IEnvelope envelope = geometry.Envelope; double num = envelope.ZMin; ISpatialReference spatialReference = BuildingProperty.Scene.SpatialReference; geometry.Project(spatialReference); string a = num.ToString(); if (a.Equals("非数字")) { num = 0.0; } double num2 = 0.0; if (ifeature3DProperties_0 != null) { I3DProperties i3DProperties = ifeature3DProperties_0 as I3DProperties; if (i3DProperties.OffsetExpressionString.Length > 0) { try { num2 = Convert.ToDouble(i3DProperties.OffsetExpressionString); } catch { } } if (geometry is IPolygon) { num += num2; } } IGeometryCollection geometryCollection = geometry as IGeometryCollection; int geometryCount = geometryCollection.GeometryCount; int num3; if (geometry is IMultiPatch) { geometryCount = geometryCollection.GeometryCount; num3 = geometryCollection.GeometryCount * 2 / 3; modFacades.m_extrusionHeight = geometry.Envelope.ZMax - geometry.Envelope.ZMin; } else { num3 = 0; geometryCount = geometryCollection.GeometryCount; } if (modFacades.m_extrusionHeight < 1.0) { modFacades.m_extrusionHeight = 1.0; } IPoint point = null; double num4 = 0.0; double num5 = 0.0; double num6 = 0.0; object value = Missing.Value; for (int i = num3; i < geometryCount; i++) { IGeometry geometry2 = geometryCollection.get_Geometry(i); esriGeometryType geometryType = geometry2.GeometryType; if (geometryType == esriGeometryType.esriGeometryRing || geometryType == esriGeometryType.esriGeometryPolyline) { IPointCollection pointCollection = geometry2 as IPointCollection; int pointCount = pointCollection.PointCount; if (pointCount >= 2) { int num7 = 0; int num8 = 1; bool flag = false; IPointCollection pointCollection2; double m; IMultiPatch multiPatch; IGeometryCollection geometryCollection2; IZAware iZAware; IMAware iMAware; IElement element; while (!flag) { bool flag2 = false; while (num8 < pointCount && !flag2) { if (num8 - num7 == 1) { IPoint point2 = pointCollection.get_Point(num7); point = pointCollection.get_Point(num8); num5 = point.X - point2.X; num6 = point.Y - point2.Y; num4 = Math.Sqrt(num5 * num5 + num6 * num6); if (isurface_0 != null) { num = isurface_0.get_Z(point.X, point.Y); num += num2; } } else { IPoint point2 = point; double num9 = num5; double num10 = num6; point = pointCollection.get_Point(num8); if (isurface_0 != null) { num = isurface_0.get_Z(point.X, point.Y); num += num2; } num5 = point.X - point2.X; num6 = point.Y - point2.Y; double num11 = Math.Sqrt(num9 * num9 + num10 * num10); double num12 = Math.Sqrt(num5 * num5 + num6 * num6); double num13 = (num9 * num5 + num10 * num6) / (num11 * num12); if (num13 < Math.Cos(modFacades.m_limitAngle)) { flag2 = true; break; } num4 += num12; } num8++; } if (flag2) { num8--; } else { num8--; } pointCollection2 = new TriangleStrip(); double num14 = 0.0; for (int j = num7; j <= num8; j++) { if (j > 0) { IPoint point2 = point; point = pointCollection.get_Point(j); num5 = point.X - point2.Y; num6 = point.Y - point2.Y; num14 += Math.Sqrt(num5 * num5 + num6 * num6); } else { point = pointCollection.get_Point(j); } point.Z = num; m = 0.0; encode3DProperties.PackTexture2D(num14 / num4, 0.0, out m); point.M = m; IClone clone = point as IClone; pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value); point.Z = num + modFacades.m_extrusionHeight; m = 0.0; encode3DProperties.PackTexture2D(num14 / num4, -1.0, out m); point.M = m; pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value); } multiPatch = new MultiPatch() as IMultiPatch; geometryCollection2 = (multiPatch as IGeometryCollection); iZAware = (multiPatch as IZAware); iZAware.ZAware = true; iMAware = (multiPatch as IMAware); iMAware.MAware = true; geometryCollection2.AddGeometry(pointCollection2 as IGeometry, ref value, ref value); if (clsTextureGroup_0 != null) { int index = modFacades.FindTextureByAspect(clsTextureGroup_0, num4 / modFacades.m_extrusionHeight); element = modFacades.CreateElement(multiPatch, clsTextureGroup_0.Symbols[index], string_0); } else { element = modFacades.CreateElement(multiPatch, null, string_0); } if (element != null) { groupElement2.AddElement(element); } num7 = num8; num8 = num7 + 1; if (num7 >= pointCount - 1) { flag = true; } } IVector3D vector3D = new Vector3D() as IVector3D; vector3D.XComponent = 0.0; vector3D.YComponent = 0.0; vector3D.ZComponent = 1.0; m = 0.0; encode3DProperties.PackNormal(vector3D, out m); pointCollection2 = new Ring(); for (int j = 0; j <= pointCount - 1; j++) { IPoint point3 = pointCollection.get_Point(j); point3.Z = num + modFacades.m_extrusionHeight; point3.M = 0.0; IClone clone = point3 as IClone; pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value); } IRing ring = pointCollection2 as IRing; ring.Close(); multiPatch = new MultiPatch() as IMultiPatch; geometryCollection2 = (multiPatch as IGeometryCollection); iZAware = (multiPatch as IZAware); iZAware.ZAware = true; iMAware = (multiPatch as IMAware); iMAware.MAware = true; geometryCollection2.AddGeometry(pointCollection2 as IGeometry, ref value, ref value); multiPatch.PutRingType(pointCollection2 as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing); if (clsTextureGroup_0 != null) { element = modFacades.CreateElement(multiPatch, clsTextureGroup_0.RoofSymbol, string_0 + ";ROOFCOLOR=" + clsTextureGroup_0.RoofColorRGB.ToString()); } else { element = modFacades.CreateElement(multiPatch, null, string_0 + ";ROOFCOLOR=1"); } if (element != null) { groupElement2.AddElement(element); } } } } if (groupElement2 != null) { IElementProperties elementProperties = groupElement2 as IElementProperties; elementProperties.Name = string_0; } groupElement = groupElement2; result = groupElement; return(result); } catch { } result = groupElement; return(result); }
public static IGroupElement CreateRoadSurfaceFromPolygon(IFeature ifeature_0, IFeature3DProperties ifeature3DProperties_0, clsTextureGroup clsTextureGroup_0, ISurface isurface_0, string string_0, IPolygon ipolygon_0, bool bool_0) { IGroupElement groupElement = null; IGroupElement result; try { IEncode3DProperties encode3DProperties = new GeometryEnvironment() as IEncode3DProperties; IGroupElement groupElement2 = new GroupElement() as IGroupElement; if (modFacades.m_limitAngle == 0.0) { modFacades.m_limitAngle = 0.5235987666666666; } IGeometry geometry = null; if (ifeature_0 != null) { if (ifeature3DProperties_0 != null && bool_0) { ifeature3DProperties_0.ApplyFeatureProperties(ifeature_0, out geometry, false); modFacades.g_bFeaturePropertiesApplied = true; } else { geometry = ifeature_0.Shape; modFacades.g_bFeaturePropertiesApplied = false; } } else if (ipolygon_0 != null) { geometry = ipolygon_0; } if (geometry == null) { result = groupElement; return(result); } if (!(geometry is IMultiPatch)) { } IEnvelope envelope = geometry.Envelope; double num = envelope.ZMin; if (modFacades.IsNaN(num)) { num = 0.0; } double num2 = 0.0; I3DProperties i3DProperties = ifeature3DProperties_0 as I3DProperties; if (i3DProperties.OffsetExpressionString.Length > 0) { num2 = Convert.ToDouble(i3DProperties.OffsetExpressionString); } if (geometry is IPolygon) { num += num2; } IGeometryCollection geometryCollection = geometry as IGeometryCollection; int geometryCount = geometryCollection.GeometryCount; int num3; if (geometry is IMultiPatch) { geometryCount = geometryCollection.GeometryCount; num3 = geometryCollection.GeometryCount * 2 / 3; modFacades.m_extrusionHeight = geometry.Envelope.ZMax - geometry.Envelope.ZMin; } else { num3 = 0; geometryCount = geometryCollection.GeometryCount; } if (modFacades.m_extrusionHeight >= 1.0) { } for (int i = num3; i <= geometryCount - 1; i++) { IGeometry geometry2 = geometryCollection.get_Geometry(i); esriGeometryType geometryType = geometry2.GeometryType; if (geometryType == esriGeometryType.esriGeometryRing || geometryType == esriGeometryType.esriGeometryPolyline) { } IPointCollection pointCollection = geometry2 as IPointCollection; int pointCount = pointCollection.PointCount; if (pointCount >= 2) { } IVector3D vector3D = new Vector3D() as IVector3D; vector3D.XComponent = 0.0; vector3D.YComponent = 0.0; vector3D.ZComponent = 1.0; double m = 0.0; encode3DProperties.PackNormal(vector3D, out m); IPointCollection pointCollection2 = new Ring(); object value = Missing.Value; short num4 = 0; while ((int)num4 <= pointCount - 1) { IPoint point = pointCollection.get_Point((int)num4); point.Z = num; point.M = m; IClone clone = point as IClone; pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value); num4 += 1; } IRing ring = pointCollection2 as IRing; ring.Close(); IMultiPatch multiPatch = new MultiPatch() as IMultiPatch; IGeometryCollection geometryCollection2 = multiPatch as IGeometryCollection; IZAware iZAware = multiPatch as IZAware; iZAware.ZAware = true; IMAware iMAware = multiPatch as IMAware; iMAware.MAware = true; geometryCollection2.AddGeometry(pointCollection2 as IGeometry, ref value, ref value); multiPatch.PutRingType(pointCollection2 as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing); IElement element = modFacades.CreateElement(multiPatch, clsTextureGroup_0.RoofSymbol, string_0 + ";ROOFCOLOR=" + clsTextureGroup_0.RoofColorRGB.ToString()); if (element != null) { groupElement2.AddElement(element); } } if (groupElement2 != null) { IElementProperties elementProperties = groupElement2 as IElementProperties; elementProperties.Name = string_0; } groupElement = groupElement2; result = groupElement; return(result); } catch { } result = groupElement; return(result); }
private ISurface GetSurfaceFromLayer(ILayer player) { try { IRasterLayer pRLayer; I3DProperties p3DProp = null; ILayerExtensions pLE; IRasterSurface pSurface = null;; ITinLayer pTLayer; if (player is IRasterLayer) { pRLayer = player as IRasterLayer; pLE = player as ILayerExtensions; for (int i = 0; i <= pLE.ExtensionCount - 1; i++) { if (pLE.get_Extension(i) is I3DProperties) { p3DProp = pLE.get_Extension(i) as I3DProperties; break; } } if (p3DProp == null) { IRasterBandCollection pBands; if (pRLayer.Raster != null) { pSurface = new RasterSurfaceClass(); pBands = pRLayer.Raster as IRasterBandCollection; pSurface.RasterBand = pBands.Item(0); } return(pSurface as ISurface); } else { pSurface = p3DProp.BaseSurface as IRasterSurface; } return(pSurface as ISurface); } else { if (player is ITinLayer) { pTLayer = player as ITinLayer; return(pTLayer.Dataset as ISurface); } } return(null); } catch (Exception ex) { string g = ex.Message; return(null); } }