阅读:1051回复:0
ArcSence的拉伸功能如何用C#编写
大神们,我想实现ArcSence中将面拉伸成多面体的功能,不需要和Scene一模一样需要选择字段,我应该怎么编写呢。下面的代码是我写的转换按钮的点击事件,和使用的方法。它实现了能够按照已经加载在Scene控件中的HaveZ图层的面中属性表的ZValue字段里的数值,作为拉伸的高度height。但在转换后只有底部和顶部两个面,四个侧面都没有面,且各个面都会连接在一起。我自己觉得是使用了TIN的原因但不知道要怎么修改,帖子上传不了图片,恳求看到的大神解答一下。我用的是C#和.NET3.5.1框架。QQ是760804322
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(); } } |
|
|