|
发表于 2011-3-29 12:01:00
|
显示全部楼层
呵呵,当然,所有的函数都是人写出来的,别人可以,当然你也可以!
下面是个示意,希望能帮到你。
///
/// 求两条曲线的交点,本函数为应对Polyline.IntersectWith函数的Bug
/// Vrsion : 2009.02.10 Sieben
/// Vrsion : 2010.12.25 增加判断输入实体是否为平面实体
///
///
///
///
public static Point3dCollection IntersectWith(Entity ent1, Entity ent2, Intersect intersectType)
{
try
{
if (ent1 is Polyline || ent2 is Polyline)
{
if (ent1 is Polyline && ent2 is Polyline)
{
Polyline pline1 = (Polyline)ent1;
Polyline pline2 = (Polyline)ent2;
return IntersectWith(pline1.ConvertTo(false), pline2.ConvertTo(false), intersectType);
}
else if (ent1 is Polyline)
{
Polyline pline1 = (Polyline)ent1;
return IntersectWith(pline1.ConvertTo(false), ent2, intersectType);
}
else
{
Polyline pline2 = (Polyline)ent2;
return IntersectWith(ent1, pline2.ConvertTo(false), intersectType);
}
}
else
{
Point3dCollection interPs = new Point3dCollection();
if (ent1.IsPlanar && ent2.IsPlanar)
ent1.IntersectWith(ent2, intersectType, new Plane(Point3d.Origin, Vector3d.ZAxis), interPs, 0, 0);
else
ent1.IntersectWith(ent2, intersectType, interPs, 0, 0);
return interPs;
}
}
catch (System.Exception ex)
{
return null;
}
} |
|