- UID
- 658062
- 积分
- 2147
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2008-10-22
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.Geometry;
using AcBr = Autodesk.AutoCAD.BoundaryRepresentation;
using Autodesk.AutoCAD.Runtime;
namespace Autodesk.AutoCAD.DatabaseServices
{
public static class PolylineExtensionMethods
{
/// <summary>
///
/// Returns true if the given Polyline forms a
/// closed boundary and its Closed property is
/// false.
///
/// The result is true if any of the
/// following conditions are true:
///
/// 1. Any segment intersects any other segment.
/// Regardless of the value of the Closed property.
///
/// 2. Any vertex lies directly on any segment.
/// or is coincident with any other vertex,
/// including zero-length segments, regardless
/// of the value of the Closed property
///
/// 3. If the first and last vertices are coincident,
/// AND the PolyLine's Closed property is false,
/// the polyline is considered effectively closed.
///
/// 4. A Closed polyline with < 3 vertices.
///
/// The test is intended to be consistent with the
/// REGION command's testing of boundary entities.
///
/// </summary>
public static bool IsEffectivelyClosed( this Polyline pline )
{
int numverts = pline.NumberOfVertices;
if( numverts < 3 )
return pline.Closed;
if( !pline.Closed && pline.StartPoint.IsEqualTo( pline.EndPoint ) )
return true;
Point3dCollection points = new Point3dCollection();
pline.IntersectWith( pline, Intersect.OnBothOperands, points,
IntPtr.Zero, IntPtr.Zero );
if( !pline.Closed )
numverts -= 2;
return points.Count != numverts;
}
}
}
|
|