当前位置: 首页>>代码示例>>C#>>正文


C# Curve.Explode方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:vildar82,项目名称:AcadLib,代码行数:60,代码来源:GeomExt.cs


注:本文中的Curve.Explode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。