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


C# CurveLoop.GetCurveLoopIterator方法代码示例

本文整理汇总了C#中CurveLoop.GetCurveLoopIterator方法的典型用法代码示例。如果您正苦于以下问题:C# CurveLoop.GetCurveLoopIterator方法的具体用法?C# CurveLoop.GetCurveLoopIterator怎么用?C# CurveLoop.GetCurveLoopIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CurveLoop的用法示例。


在下文中一共展示了CurveLoop.GetCurveLoopIterator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertCurveLoopIntoSingleCurve

      /// <summary>
      /// Create a curve representation of this IFCCompositeCurve from a curveloop
      /// </summary>
      /// <param name="curveLoop">The curveloop</param>
      /// <returns>A Revit curve that is made by appending every curve in the given curveloop, if possible</returns>
      private Curve ConvertCurveLoopIntoSingleCurve(CurveLoop curveLoop)
      {
         if (curveLoop == null)
         {
            return null;
         }

         CurveLoopIterator curveIterator = curveLoop.GetCurveLoopIterator();
         Curve firstCurve = curveIterator.Current;
         Curve returnCurve = null;

         // We only connect the curves if they are Line, Arc or Ellipse
         if (!((firstCurve is Line) || (firstCurve is Arc) || (firstCurve is Ellipse)))
         {
            return null;
         }

         XYZ firstStartPoint = firstCurve.GetEndPoint(0);

         Curve currentCurve = null;
         if (firstCurve is Line)
         {
            Line firstLine = firstCurve as Line;
            while(curveIterator.MoveNext())
            {
               currentCurve = curveIterator.Current;
               if (!(currentCurve is Line))
               {
                  return null;
               }
               Line currentLine = currentCurve as Line;

               if (!(firstLine.Direction.IsAlmostEqualTo(currentLine.Direction)))
               {
                  return null;
               }
            }
            returnCurve = Line.CreateBound(firstStartPoint, currentCurve.GetEndPoint(1));
         }
         else if (firstCurve is Arc)
         {
            Arc firstArc = firstCurve as Arc;
            XYZ firstCurveNormal = firstArc.Normal;

            while(curveIterator.MoveNext())
            {
               currentCurve = curveIterator.Current;
               if (!(currentCurve is Arc))
               {
                   return null;
               }

               XYZ currentStartPoint = currentCurve.GetEndPoint(0);
               XYZ currentEndPoint = currentCurve.GetEndPoint(1);

               Arc currentArc = currentCurve as Arc;
               XYZ currentCenter = currentArc.Center;
               double currentRadius = currentArc.Radius;
               XYZ currentNormal = currentArc.Normal;

               // We check if this circle is similar to the first circle by checking that they have the same center, same radius,
               // and lie on the same plane
               if (!(currentCenter.IsAlmostEqualTo(firstArc.Center) && MathUtil.IsAlmostEqual(currentRadius, firstArc.Radius)))
               {
                  return null;
               }
               if (!MathUtil.IsAlmostEqual(Math.Abs(currentNormal.DotProduct(firstCurveNormal)), 1))
               {
                  return null;
               }
            }
            // If all of the curve segments are part of the same circle, then the returning curve will be a circle bounded
            // by the start point of the first curve and the end point of the last curve.
            XYZ lastPoint = currentCurve.GetEndPoint(1);
            if (lastPoint.IsAlmostEqualTo(firstStartPoint))
            {
               firstCurve.MakeUnbound();
            }
            else
            {
               double startParameter = firstArc.GetEndParameter(0);
               double endParameter = firstArc.Project(lastPoint).Parameter;

               if (endParameter < startParameter)
                  endParameter += Math.PI * 2;

               firstCurve.MakeBound(startParameter, endParameter);
            }
            returnCurve = firstCurve;
            
         }
         else if (firstCurve is Ellipse)
         {
            Ellipse firstEllipse = firstCurve as Ellipse;
            double radiusX = firstEllipse.RadiusX;
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:101,代码来源:IFCCompositeCurve.cs


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