Polyline的封闭与打断
来源:互联网 发布:python matplotlib版本 编辑:程序博客网 时间:2024/04/30 09:23
/// <summary>
/// 利用面生成闭合的曲线
/// </summary>
/// <param name="pPolygon">传入的面图形</param>
/// <returns></returns>
private IPolyline PolygonToLine(IPolygon pPolygon)
{
IGeometryCollection pGeometryCollectionPolygon;
IClone pClone;
ISegmentCollection pSegmentCollectionPath;
object o = Type.Missing;
IGeometryCollection pGeoCol = new PolylineClass();
pClone = (IClone)pPolygon;
pGeometryCollectionPolygon = pClone.Clone() as IGeometryCollection;
for (int i = 0; i < pGeometryCollectionPolygon.GeometryCount; i++)
{
pSegmentCollectionPath = new PathClass();
pSegmentCollectionPath.AddSegmentCollection(pGeometryCollectionPolygon.get_Geometry(i) as ISegmentCollection);
pGeoCol.AddGeometry(pSegmentCollectionPath as IGeometry, ref o, ref o);
}
return pGeoCol as IPolyline;
}
/// <summary>
/// 线上距离FromPoint的DisOnLine距离上的一点,在这点处把线打断为两段
/// </summary>
/// <param name="myPolyline">传入的线图形</param>
/// <param name="DisOnLine">离FromPoint的距离</param>
/// <returns></returns>
private IPolyline[] BreakLineToTwoPart(IPolyline myPolyline,double DisOnLine)
{
if (DisOnLine < myPolyline.Length) //如果传入的长度大于线的长度,不与操作
{
return null;
}
IPolyline[] Lines = new IPolyline[2];
bool isSplit;
int splitIndex, segIndex;
object o = Type.Missing;
myPolyline.SplitAtDistance(DisOnLine, false, false, out isSplit, out splitIndex, out segIndex);
IPolyline newLine = new PolylineClass();
ISegmentCollection lineSegCol = (ISegmentCollection)myPolyline;
ISegmentCollection newSegCol = (ISegmentCollection)newLine;
for (int j = segIndex; j < lineSegCol.SegmentCount; j++)
{
newSegCol.AddSegment(lineSegCol.get_Segment(j), ref o, ref o);
}
//重新构建两条线
lineSegCol.RemoveSegments(segIndex, lineSegCol.SegmentCount - segIndex, true);
lineSegCol.SegmentsChanged();
newSegCol.SegmentsChanged();
IPolyline oldLine = lineSegCol as IPolyline;
newLine = newSegCol as IPolyline;
Lines[0] = oldLine;
Lines[1] = newLine;
return Lines;
}
/// <summary>
/// 在SplitePoint处打断线要素的图形,并去除新的线
/// </summary>
/// <param name="LineCurve">传入的线</param>
/// <param name="SplitePoint">线上的一点</param>
/// <returns></returns>
private IPolyline[] SpliteLineAtPoint(IPolyline LineCurve, IPoint SplitePoint)
{
IPolyline[] Lines = new IPolyline[2];
bool isSplit;
int splitIndex, segIndex;
LineCurve.SplitAtPoint(SplitePoint, true, false, out isSplit, out splitIndex, out segIndex);
if (isSplit)
{
IPolyline newLine = new PolylineClass();
ISegmentCollection lineSegCol = (ISegmentCollection)LineCurve;
ISegmentCollection newSegCol = (ISegmentCollection)newLine;
object o = Type.Missing;
for (int j = segIndex; j < lineSegCol.SegmentCount; j++)
{
newSegCol.AddSegment(lineSegCol.get_Segment(j), ref o, ref o);
}
lineSegCol.RemoveSegments(segIndex, lineSegCol.SegmentCount - segIndex, true);
lineSegCol.SegmentsChanged();
newSegCol.SegmentsChanged();
IPolyline oldLine = lineSegCol as IPolyline;
newLine = newSegCol as IPolyline;
Lines[0] = newLine;
Lines[1] = oldLine;
}
return Lines;
}
/// <summary>
/// 用一个面图形把一个面要素切割为两部分
/// </summary>
/// <param name="polyClass">面要素集</param>
/// <param name="polyFeat">面要素</param>
/// <param name="CutPolygon">用于切割的图形</param>
private void BreakPolygonToTwoPart(IFeatureClass polyClass, IFeature polyFeat, IPolygon CutPolygon)
{
IGeometry featGeo = polyFeat.Shape;
ITopologicalOperator topo = featGeo as ITopologicalOperator;
IGeometry pOutGeometry = topo.Difference(CutPolygon); //去除相交的部分
if (pOutGeometry is IGeometryCollection)
{
IGeometryCollection pGeometryCollection = pOutGeometry as IGeometryCollection;
for (int i = 0; i < pGeometryCollection.GeometryCount; i++)
{
IGeometry pGeometry = pGeometryCollection.get_Geometry(i);
if (pGeometry != null && !pGeometry.IsEmpty && pGeometry.GeometryType == esriGeometryType.esriGeometryRing)
{
IClone pClone = pGeometry as IClone;
IPolygon pPolygon = ConvertGeometryToPolygon(pClone.Clone() as IGeometry);
if (pPolygon != null && !pPolygon.IsEmpty)
{
IFeature pNewFeature = polyClass.CreateFeature();
pNewFeature.Shape = pPolygon;
pNewFeature.Store();
}
}
}
polyFeat.Delete();
}
}
private IPolygon ConvertGeometryToPolygon(IGeometry pGeometry)
{
IPointCollection pPointCollection = pGeometry as IPointCollection;
IPointCollection pNewPointCollection = new PolygonClass();
pNewPointCollection.AddPointCollection(pPointCollection);
IPolygon pPolygon = pNewPointCollection as IPolygon;
return pPolygon;
}
- Polyline的封闭与打断
- polyline与polygon
- 智能手机的开放与封闭刍议
- 思维的基本功:开放与封闭
- Swift与苹果的封闭之道
- WPF的Polyline和Polygon
- 开放与封闭
- 开放与封闭
- 开放与封闭
- 开放与封闭
- 智能手机的开放与封闭刍议(一)
- 成员名称不能与它们的封闭类型相同
- nstimer 被打断的问题
- 打断点遇到的异常
- 关于打断设计的作用
- 开放-封闭的原则
- 封闭生活的开始
- 封闭开发的日子
- 向量空间模型VSM和余弦距离
- C++中extern “C”含义深层探索及extern用法详解
- Web搜索中的用户意图的自动识别
- uml各种图例及说明(摘录)
- CString、Char、Byte之间的转换
- Polyline的封闭与打断
- myeclipse 8.5 or 8.6 手动添加插件
- #define XXX 后面一定要回车
- 用javascript限制一个文本框只能输入数字,英文
- HDOJ 1003 - Max Num
- SD卡驱动相关内容
- C#接口的作用
- BW:小结:BW系统升级
- 信号灯RSemaphore在线程里的用处