ArcEngine generates TIN from vertex

Source: Internet
Author: User

In the past two days, I wrote a 3D campus display program for others, using the second development of SceneControl. DOM and TIN must be used to construct a three-dimensional terrain. Now let's talk about the process of generating TIN Based on the path:

(1) generate point shapefile Based on the Excel file

(2) generate TIN using the AddFromFeatureClass method of ITinEdit

The high-end data format is as follows:

The operation interface is as follows:

:

Generate TIN:


The code is easy to understand, as follows:

# Region create TIN private void button_ OK _Click (object sender, EventArgs e) {try {strTinName = textBox_TINName.Text; outFolder = textBox_outpath.Text; if (strTinName = ") {MessageBox. show ("Enter the TIN name! ");} Else if (outFolder =" ") {MessageBox. show ("select TIN save path");} else {// generate vertex shape Excel2Shape excel2shape = new Excel2Shape (textBox_point.Text); excel2shape. createShapeFromExcel (); // obtain the shapefile string path = excel2shape. path; string name = excel2shape. name; IWorkspaceFactory pWSFac = new ShapefileWorkspaceFactoryClass (); IFeatureWorkspace pFeatureWS = pWSFac. openFromFile (path, 0) as IFeatureWork Space; IFeatureClass pFeatureClass = pFeatureWS. openFeatureClass (name); IField pField = pFeatureClass. fields. get_Field (pFeatureClass. findField ("Z"); // create TIN ITin pTin = Create_TIN (pFeatureClass, pField, outFolder); ITinLayer pTinlayer = new TinLayerClass (); pTinlayer. dataset = pTin; pTinlayer. name = strTinName; pSceneControl. sceneGraph. scene. addLayer (pTinlayer as ILayer, true); this. close ();}} Catch (System. Exception ex) {MessageBox. Show (ex. Message + "failed to create TIN! ");}} /// <Summary> /// create TIN /// </summary> /// <param name = "pFeatureClass"> point element class </param> /// <param name = "pField"> Z field </param> // <param name = "pPath"> path </param> public ITin Create_TIN (IFeatureClass pFeatureClass, IField pField, string pPath) {IGeoDataset pGeoDataset = pFeatureClass as IGeoDataset; ITinEdit pTinEdit = new TinClass (); pTinEdit. initNew (pGeoDataset. extent); object pObj = Type. missing; pTinEdit. addFromFeatureClass (pFeatureClass, null, pField, null, esriTinSurfaceType. esriTinMassPoint, ref pObj); if (System. IO. file. exists (pPath) {_ 3DCampus. helper. folderHelper. deleteFolder (pPath);} pTinEdit. saveAs (pPath, ref pObj); pTinEdit. refresh (); return pTinEdit as ITin;} # endregion


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.