AE用线来分割线面(C#2010+AE10.0… .
希望指正。
在 ITools 类中,部分方法如下:
public override void OnMouseDown(int Button, int Shift, int X, int Y)
{
if (Button != 1)
return;
#region……分割面
//根据已选择的要分割的要素的类型绘制分割线
if (pFeatureLayer.FeatureClass.ShapeType==esriGeometryType.esriGeometryPolygon)
{//分割线的样式
IScreenDisplay pScreenDisplay = m_hookHelper.ActiveView.ScreenDisplay;
ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass();
IRgbColor pRgbColor = new RgbColorClass();
pRgbColor.Red = 255;
pLineSymbol.Color = pRgbColor;
IRubberBand pRubberBand = new RubberLineClass();
IPolyline pPolyline = (IPolyline)pRubberBand.TrackNew(pScreenDisplay, (ISymbol)pLineSymbol);
pScreenDisplay.StartDrawing(pScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
pScreenDisplay.SetSymbol((ISymbol)pLineSymbol);
pScreenDisplay.DrawPolyline(pPolyline);
pScreenDisplay.FinishDrawing();
//清理将被分割的要素
ITopologicalOperator pTopoOpo;
pTopoOpo = pPolyline as ITopologicalOperator;
pTopoOpo.Simplify();//确保几何体的拓扑正确
m_engineEditor.StartOperation();
//分割方法
SplitPolygon(pSelectionSet, pPolyline);
ReBackStates();//刷新返回修改工具
m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_hookHelper.ActiveView.Extent);
}
#endregion
#region……鼠标画线分割线
//根据分割要素的类型绘制分割线
if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
{
IScreenDisplay pScreenDisplay = m_hookHelper.ActiveView.ScreenDisplay;
ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass();
IRgbColor pRgbColor = new RgbColorClass();
pRgbColor.Red = 255;
pLineSymbol.Color = pRgbColor;
IRubberBand pRubberBand = new RubberLineClass();
IPolyline pPolyline = (IPolyline)pRubberBand.TrackNew(pScreenDisplay, (ISymbol)pLineSymbol);
pScreenDisplay.StartDrawing(pScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
pScreenDisplay.SetSymbol((ISymbol)pLineSymbol);
pScreenDisplay.DrawPolyline(pPolyline);
pScreenDisplay.FinishDrawing();
m_engineEditor.StartOperation();//开启编辑
//分割方法
SplitPolyline(pSelectionSet, pPolyline);
ReBackStates();
m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_hookHelper.ActiveView.Extent);
}
#endregion
m_engineEditor.StopOperation("ControlToolsEditing_CreateNewFeatureTask");
}
//分割面
public void SplitPolygon(ISelectionSet pSelectionSet, IGeometry pGeometry)
{
//使用空间过滤器来获得将要与线或点进行分割的要素类
IFeatureCursor pFeatCursor;
ICursor pCursor;
ISpatialFilter pSpatialFilter;
pSpatialFilter = new SpatialFilterClass();
pSpatialFilter.Geometry = pGeometry;
if (pGeometry.GeometryType == esriGeometryType.esriGeometryPolyline)//.esriGeometryPoint)
{
pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses;//空间关系
}
pSelectionSet.Search(pSpatialFilter, true, out pCursor);
pFeatCursor = pCursor as IFeatureCursor;
//清理将被分割的要素
ITopologicalOperator pTopoOpo;
pTopoOpo = pGeometry as ITopologicalOperator;
pTopoOpo.Simplify();//确保几何体的拓扑正确
IFeature pFeature;
pFeature = pFeatCursor.NextFeature();
if (pFeature == null) return;
while (pFeature != null)
{
IFeatureEdit pFeatureEdit;
pFeatureEdit = pFeature as IFeatureEdit;
ISet pSet;
pSet = pFeatureEdit.Split(pGeometry);//直接用线分割
for (int setCount = 0; setCount < pSet.Count; setCount++)
{
pFeature = pSet.Next() as IFeature;
//featureSelection.SelectionSet.Add(pFeature.OID);
}
pFeature = pFeatCursor.NextFeature();
}
MessageBox.Show("面分割完毕!继续选择以分割!");
}
//分割线,线要素不能用线来分割,得用点来。所以要将分割线与被分割线求交叉点
public void SplitPolyline(ISelectionSet pSelectionSet, IGeometry pGeometry)
{
IFeatureClass featureClass=pFeatureLayer.FeatureClass;
IEnumIDs enumIDs = pSelectionSet.IDs;
int id = enumIDs.Next();
while(id!=-1)
{
pFeature = featureClass.GetFeature(id);
IGeometry pGeo = pFeature.ShapeCopy;
//由于在拓扑是需要空间参考一致,所以要将空间参考坐标设置一下。
pGeo.SpatialReference = pGeometry.SpatialReference;
ITopologicalOperator pTopoOpo = pGeo as ITopologicalOperator;
//Intersect()方法求出来的是MultiPoint,而不是单点
IPointCollection pPCol = pTopoOpo.Intersect(pGeometry, esriGeometryDimension.esriGeometry0Dimension) as IPointCollection;
pTopoOpo.Simplify();
if (pPCol == null)//如果没有相交的,那么点集就为空。
return;
if (pPCol.PointCount == 0)//如果选择的线有一些没有与分割线相交,那么PointCount为0,但是0并不是null。
{
id = enumIDs.Next();//那么就Next(),让他进入下一个回合吧
continue;
}
IFeatureEdit pFeatureEdit;
pFeatureEdit = pFeature as IFeatureEdit;
ISet pSet;
pSet = pFeatureEdit.Split(pPCol.get_Point(0));
pSet.Reset();
//这一步进入分割大赛,其实分割为两个部分,当然要是只是分割单个要素的话就用不着里面那一层嵌套循环了。
for (int setCount = 0; setCount < pSet.Count; setCount++)
{
pFeature = pSet.Next() as IFeature;
if (pFeature == null) return;
for (int i = 1; i < pPCol.PointCount; i++)
{
try
{
pFeatureEdit = pFeature as IFeatureEdit;
IPoint pPoint = pPCol.get_Point(i);
pSet = pFeatureEdit.Split(pPoint);//这里新产生的线要素,可能与下一个交点进行分割,所以要重新获取以便进行下一次分割
pSet.Reset();
pPCol.RemovePoints(i, 1);//为了少循环一次,用了一个点就从点集中移除它,因为两线相交肯定没有二心。
break;//打断,这一步是迫不得已的,因为懒得去想另一部分。当然这样的话有个问题:如3点分线应该是4段,但如果这点刚好是中间的点,那么就会丢掉他前面或者后面的一个分割点,如此的话就变成2点分线为3段了;而且画的分割折线与被分割线交点越多丢失的就越多。主要原因是MultiPoint撞到IPointCollection中后顺序并不是画线时候的交叉顺序。怎么办呢?
}
catch
{
continue;
}
}
}
id = enumIDs.Next();
}
MessageBox.Show("线分割完毕!继续选择以分割!");
}
private void ReBackStates()
{
//清空选择集
ICommand pCommand = new ControlsClearSelectionCommandClass();
pCommand.OnCreate(pMapControl.Object);
pCommand.OnClick();
pCommand = new ControlsEditingEditToolClass();
pCommand.OnCreate(pMapControl.Object);
pMapControl.CurrentTool = pCommand as ITool;
}
来自:http://blog.csdn.net/hong_taizi/article/details/10161557
AE用线来分割线面(C#2010+AE10.0… .的更多相关文章
- 问题解决——SolidWorks 已停止工作 (Windows7 + SolidWorks 2010 SP0.0)
给同事的SolidWorks解决问题时偶然间发现的. -------------------------------------------------------------- 本文原创,转载请注明 ...
- #error : Xiron Platform Abstraction Layer - Win32 - Microsoft Visual Studio versions above 2010 (10.0) are not supported! 解决方案
OpenNI1.5 VS2013配置环境后,编译会出现这个错误: 错误 error C1189: #error : Xiron Platform Abstraction Layer - Win32 - ...
- AE10.0及AE10.0以上的版本调用ESRI.ArcGIS.esriSystem出现的问题
如果本地安装的是AE10.0以上,那么添加ESRI.ArcGIS.esriSystem引用时,会出现esriLicenseProductCode并不包含esriLicenseProductCodeAr ...
- AE10.0在Visual Studio 2012下安装没有模板(转)
转自百度经验: VS2012中丢失ArcGIS模板的解决方法 由于ArcGIS10.0(for .NET)默认是用VS2010作为开发工具的,所以在先安装VS2012后装ArcGIS10.0 桌面版及 ...
- HTML 几种特别分割线特效
一.基本线条 二.特效(效果并不是孤立的,可相互组合)1.两头渐变透明:<HR style="FILTER: alpha(opacity=100,finishopacity=0,sty ...
- iOS tableView移除某一行的分割线 让分割线宽度为整个cell的宽度
移除tableViewCell中某一行的分割线 有2种方法 1. 移除系统的分割线,自己定义每行的分割线 self.tableView.separatorStyle = UITableViewCell ...
- UITableView移除某行的分割线和让分割线宽度为cell的宽度
1.移除 UITableView 某一行的分割线 所谓移除,其实就是使其偏移出 cell 的显示范围,看不到即移除. 方法1: 移除系统的分割线,自己定义每行的分割线 self.tableView.s ...
- 【Python全栈-HTML】HTML如何做出分割线效果
参考: https://blog.csdn.net/weixin_39198406/article/details/78827671 一.普通效果 <hr> <hr align=ce ...
- html几种美丽的分割线
一.普通 1.<HR> 2.<HR align=center width=300 color=#987cb9 SIZE=1>align 线条位置(可选left.right.ce ...
随机推荐
- 自制Console线(已测试CISCO3560可用)
D9的顺序是5口在上,4口在下.从右到左分别是1-5,6-9. 5 4 3 2 1 o o o o o o o o o 9 8 7 6 用万用表量出D9的口的对应颜色.然后按照下面的表.把颜色填写上. ...
- Django:Model的Filter
转自:http://www.douban.com/note/301166150/ django model filter 条件过滤,及多表连接查询.反向查询,某字段的distinct 1.多表 ...
- maven pox.xml 设置主入口配置节点
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven ...
- Tips11:用[Rang]来限制Inspector中的变量
我们在写脚本的过程中可能会用到很多Public变量,如INT型,Float型,这些变量在项目中可能有着一个默认的实际范围,如血量不能为负数,而且int float本来就是有一个范围的,如果对这些变量加 ...
- Linux文件查找工具之find “大宝剑”--转载
原文地址:http://xinzong.blog.51cto.com/10018904/1749465 一.文件查找工具常用软件 locate: locate命令其实是find -name的另一种写法 ...
- Linux常用命令回顾
文件操作:ls 查看文件ls -a 查看全部文件,包括隐藏文件(以.开头)ls -l 查看文件的详细信息(ll同样的效果)ls -lh 查看文件的详细信息,人性化显示,文件大小标注单位文件权限-代表文 ...
- [git]解决rebase冲突
git pull --rebase时产生冲突 有三个选项: git rebase --skip 效果是:抛弃本地的commit,采用远程的commit(慎用因为你本地的修改就会都没有!) git re ...
- 第一次接触终极事务处理——Hekaton
在这篇文章里,我想给出如何与终极事务处理(Extreme Transaction Processing (XTP) )的第一次接触,即大家熟知的Hakaton.如果你想对XTP有个很好的概况认识,我推 ...
- 分享一下我封装iOS自定义控件的体会,附上三个好用的控件Demo <时间选择器&多行输入框&日期选择器>
前段时间有小伙伴问到我:"这样的控件该怎么做呢?",我感觉是个比较简单的控件,可能对于入行不久的同志思路没有很清晰吧.趁着最近工作不忙,就来这里分享一下我封装自定义控件的几点体会吧 ...
- Eclipse启动报错:A java runtime Environment(JRE) or java Development……的解决办法
第一种: 解决方法: 系统变量里设置下面: 变量名:JAVA_HOME 变量值:D:\Java\jdk1.8.0_31 变量名:CLASSPATH 变量值:.;%JAVA_HOME%\lib; 变量名 ...