阅读:569回复:0
ArcSence的拉伸功能如何用C#编写
我已经搭建好了Scene控件,和加载shp文件的功能和界面。但是在将面拉伸为多面体时,出现只有底部和顶部两个面,高度是正确的(在shp文件中我增添了ZValue的字段,高度是按照字段里的数值),但侧面要如何生成呢,为什么我拉伸后是空的呢。以下是点击转换按钮触发的事件,和加载的方法。麻烦大佬帮忙看一下。
private void btnChange_Click(object sender, EventArgs e) { try { string path = textBox1.Text.ToString(); if (path == "" | path == null) { MessageBox.Show("结果保存路径不能为空!!!"); return; } CreateMultiPatchFromFeature(pFeatureClass, path); } catch { } /// <summary> /// 通过矢量图层创建多面体 /// </summary> public void CreateMultiPatchFromFeature(IFeatureClass featureclass, string savepath) { IGeoDataset pGeodataset = featureclass as IGeoDataset; IEnvelope extent = pGeodataset.Extent; extent.SpatialReference = pGeodataset.SpatialReference; IFields fields = featureclass.Fields; int zValueIndex = fields.FindField("ZValue"); ITinEdit tinedit = new TinClass(); tinedit.InitNew(extent); try { tinedit.AddFromFeatureClass(featureclass,null,fields.get_Field(zValueIndex),null,esriTinSurfaceType.esriTinHardLine); } catch { MessageBox.Show("拉伸失败"); } tinedit.SaveAs(savepath); tinedit.StopEditing(false); AddTinData(savepath); } /// <summary> /// 将生成的TIN数据加载显示 /// </summary> /// <param name="path"></param> public void AddTinData(string path) { IWorkspaceFactory pWSF = new TinWorkspaceFactory(); ITinWorkspace TinWS; ITin tin; FileInfo fileinfo = new FileInfo(path); if (pWSF.IsWorkspace(fileinfo.DirectoryName)) { TinWS = pWSF.OpenFromFile(fileinfo.DirectoryName, 0) as ITinWorkspace; tin = TinWS.OpenTin(fileinfo.Name); ITinLayer tinlayer = new TinLayerClass(); tinlayer.Dataset = tin; ILayer layer = tinlayer as ILayer; axSceneControl1.Scene.AddLayer(layer, true); axSceneControl1.SceneGraph.RefreshViewers(); } } |
|
|