本文整理汇总了C#中Curve.Explode方法的典型用法代码示例。如果您正苦于以下问题:C# Curve.Explode方法的具体用法?C# Curve.Explode怎么用?C# Curve.Explode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Curve
的用法示例。
在下文中一共展示了Curve.Explode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProjectPolyline
/// <summary>
/// Creates a new Polyline that is the result of projecting the polyline parallel to 'direction' onto 'plane' and returns it.
/// </summary>
/// <param name="pline">The polyline (any type) to project.</param>
/// <param name="plane">The plane onto which the curve is to be projected.</param>
/// <param name="direction">Direction (in WCS coordinates) of the projection.</param>
/// <returns>The projected Polyline.</returns>
internal static Polyline ProjectPolyline(Curve pline, Plane plane, Vector3d direction)
{
if (!(pline is Polyline) && !(pline is Polyline2d) && !(pline is Polyline3d))
return null;
plane = new Plane(Point3d.Origin.OrthoProject(plane), direction);
using (DBObjectCollection oldCol = new DBObjectCollection())
using (DBObjectCollection newCol = new DBObjectCollection())
{
pline.Explode(oldCol);
foreach (DBObject obj in oldCol)
{
Curve crv = obj as Curve;
if (crv != null)
{
Curve flat = crv.GetProjectedCurve(plane, direction);
newCol.Add(flat);
}
obj.Dispose();
}
PolylineSegmentCollection psc = new PolylineSegmentCollection();
for (int i = 0; i < newCol.Count; i++)
{
if (newCol[i] is Ellipse)
{
psc.AddRange(new PolylineSegmentCollection((Ellipse)newCol[i]));
continue;
}
Curve crv = (Curve)newCol[i];
Point3d start = crv.StartPoint;
Point3d end = crv.EndPoint;
double bulge = 0.0;
if (crv is Arc)
{
Arc arc = (Arc)crv;
double angle = arc.Center.GetVectorTo(start).GetAngleTo(arc.Center.GetVectorTo(end), arc.Normal);
bulge = Math.Tan(angle / 4.0);
}
psc.Add(new PolylineSegment(start.Convert2d(plane), end.Convert2d(plane), bulge));
}
foreach (DBObject o in newCol) o.Dispose();
Polyline projectedPline = psc.Join(new Tolerance(1e-9, 1e-9))[0].ToPolyline();
projectedPline.Normal = direction;
projectedPline.Elevation =
plane.PointOnPlane.TransformBy(Matrix3d.WorldToPlane(new Plane(Point3d.Origin, direction))).Z;
if (!pline.StartPoint.Project(plane, direction).IsEqualTo(projectedPline.StartPoint, new Tolerance(1e-9, 1e-9)))
{
projectedPline.Normal = direction = direction.Negate();
projectedPline.Elevation =
plane.PointOnPlane.TransformBy(Matrix3d.WorldToPlane(new Plane(Point3d.Origin, direction))).Z;
}
return projectedPline;
}
}