ArcObjects TinNode简单操作类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ESRI.ArcGIS.Analyst3D;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.DataSourcesFile;
using ESRI.ArcGIS.DataSourcesGDB;
using ESRI.ArcGIS.Geodatabase;

namespace _3DTerrianDesignSystem
{
    static class TinNodeOperation
    {
        /// <summary>
        /// 改变某一TinNode的X和Y坐标
        /// </summary>
        /// <param name="tinNode"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public static void tinNode_ChangeXY(ITinNode tinNode, double x, double y)
        {
            ITin tin = tinNode.TheTin;
            ITinFeatureEdit tinFeatEdit = (ITinFeatureEdit)tin;

            //定义移动点的位置
            WKSPoint newPoint = new WKSPoint();
            newPoint.X = x;
            newPoint.Y = y;

            if (tinFeatEdit.StartInMemoryEditing())
            {
                ITinAdvanced tinAdvanced = (ITinAdvanced)tin;
                ITinEdge tinEdge = tinAdvanced.GetEdge(1);
                ITinFeatureSeed pSeed = (ITinFeatureSeed)tinEdge;
                pSeed.UseTagValue = false;
                tinFeatEdit.MoveVertex(tinNode, pSeed, newPoint, false);
            }
        }

        /// <summary>
        /// 改变某一TinNode的Z坐标
        /// </summary>
        /// <param name="tinNode"></param>
        /// <param name="z"></param>
        public static void tinNode_ChangeZ(ITinNode tinNode, double z)
        {
            ITin tin = tinNode.TheTin;
            ITinEdit pTinEdit = (ITinEdit)tin;
            pTinEdit.SetNodeZ(tinNode.Index, z);
        }

        /// <summary>
        /// 改变某一TinNode的XYZ坐标
        /// </summary>
        /// <param name="tinNode"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        public static void tinNode_ChangeXYZ(ITinNode tinNode, double x, double y, double z)
        {
            tinNode_ChangeXY(tinNode, x, y);
            tinNode_ChangeZ(tinNode, z);
        }

        /// <summary>
        /// 删除某一TinNode
        /// </summary>
        /// <param name="tinNode"></param>
        public static void tinNode_Delete(ITinNode tinNode)
        {
            ITin tin = tinNode.TheTin;
            ITinFeatureEdit tinFeatEdit = (ITinFeatureEdit)tin;
            if (tinFeatEdit.StartInMemoryEditing())
            {
                ITinAdvanced tinAdvanced = (ITinAdvanced)tin;
                ITinEdge tinEdge = tinAdvanced.GetEdge(1);
                ITinFeatureSeed pSeed = (ITinFeatureSeed)tinEdge;
                pSeed.UseTagValue = false;
                tinFeatEdit.DeleteVertex(tinNode, pSeed);
            }
        }

        /// <summary>
        /// 添加TinNode
        /// </summary>
        /// <param name="tin"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        public static void tinNode_Add(ITin tin, double x, double y, double z)
        {
            ITinFeatureEdit tinFeatEdit = (ITinFeatureEdit)tin;
            IPoint pPoint = new PointClass();
            pPoint.X = x;
            pPoint.Y = y;
            pPoint.Z = z;
            tinFeatEdit.AddPointZ(pPoint, 0, null);
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值