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


C# Curve.CreateOffset方法代码示例

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


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

示例1: GetOrientedCurveList

      /// <summary>
      /// Returns a list of curves that represent the profile of an extrusion to be split into material layers, for simple cases.
      /// </summary>
      /// <param name="loops">The original CurveLoops representing the extrusion profile.</param>
      /// <param name="axisCurve">The axis curve used by IfcMaterialLayerUsage to place the IfcMaterialLayers.</param>
      /// <param name="offsetNorm">The normal used for calculating curve offsets.</param>
      /// <param name="offset">The offset distance from the axis curve to the material layers, as defined in the IfcMaterialLayerSetUsage "OffsetFromReferenceLine" parameter.</param>
      /// <param name="totalThickness">The total thickness of all of the generated material layers.</param>
      /// <returns>A list of curves oriented according to the axis curve.</returns>
      /// <remarks>The list will contain 4 curves in this order:
      /// 1. The curve (a bounded Line or an Arc) at the boundary of the first material layer, oriented in the same direction as the Axis curve.
      /// 2. The line, possibly slanted, representing an end cap and connecting the 1st curve to the 3rd curve.
      /// 3. The curve (of the same type as the first) at the boundary of the last material layer, oriented in the opposite direction as the Axis curve.
      /// 4. The line, possibly slanted, representing an end cap and connecting the 3rd curve to the 1st curve.
      /// Over time, we may increase the number of cases suported.</remarks>
      private IList<Curve> GetOrientedCurveList(IList<CurveLoop> loops, Curve axisCurve, XYZ offsetNorm, double offset, double totalThickness)
      {
         // We are going to limit our attempts to a fairly simple but common case:
         // 1. 2 bounded curves parallel to the axis curve, of the same type, and either Lines or Arcs.
         // 2. 2 other edges connecting the two other curves, which are Lines.
         // This covers most cases and gets rid of issues with highly irregular edges.
         if (loops.Count() != 1 || loops[0].Count() != 4)
            return null;

         // The CreateOffset routine works opposite what IFC expects.  For a line, the Revit API offset direction
         // is the (line tangent) X (the normal of the plane containing the line).  In IFC, the (local) line tangent is +X,
         // the local normal of the plane is +Z, and the positive direction of the offset is +Y.  As such, we need to
         // reverse the normal of the plane to offset in the right direction.
         Curve offsetAxisCurve = axisCurve.CreateOffset(offset, -offsetNorm);

         Curve unboundOffsetAxisCurve = offsetAxisCurve.Clone();
         unboundOffsetAxisCurve.MakeUnbound();

         IList<Curve> originalCurveList = new List<Curve>();
         IList<Curve> unboundCurveList = new List<Curve>();
         foreach (Curve loopCurve in loops[0])
         {
            originalCurveList.Add(loopCurve);
            Curve unboundCurve = loopCurve.Clone();
            unboundCurve.MakeUnbound();
            unboundCurveList.Add(unboundCurve);
         }

         int startIndex = -1;
         bool flipped = false;
         for (int ii = 0; ii < 4; ii++)
         {
            // The offset axis curve should match one of the curves of the extrusion profile.  
            // We check that here by seeing if a point on the offset axis curve is on the current unbounded curve.
            if (unboundCurveList[ii].Intersect(unboundOffsetAxisCurve) != SetComparisonResult.Overlap &&
                MathUtil.IsAlmostZero(unboundCurveList[ii].Distance(offsetAxisCurve.GetEndPoint(0))))
            {
               startIndex = ii;

               Transform originalCurveLCS = originalCurveList[ii].ComputeDerivatives(0.0, true);
               Transform axisCurveLCS = axisCurve.ComputeDerivatives(0.0, true);

               // We want the first curve to have the same orientation as the axis curve. We will flip the resulting
               // "curve loop" if not.
               bool? maybeFlipped = CurvesHaveOppositeOrientation(originalCurveList[ii], axisCurve);
               if (!maybeFlipped.HasValue)
                  return null;

               flipped = maybeFlipped.Value;

               // Now check that startIndex and startIndex+2 are parallel, and totalThickness apart.
               if ((unboundCurveList[ii].Intersect(unboundCurveList[(ii + 2) % 4]) == SetComparisonResult.Overlap) ||
                   !MathUtil.IsAlmostEqual(unboundCurveList[ii].Distance(originalCurveList[(ii + 2) % 4].GetEndPoint(0)), totalThickness))
                  return null;

               break;
            }
         }

         // We may want to consider loosening the IsAlmostEqual check above if this fails a lot for seemingly good cases.
         if (startIndex == -1)
            return null;

         IList<Curve> orientedCurveList = new List<Curve>();
         for (int ii = 0, currentIndex = startIndex; ii < 4; ii++)
         {
            Curve currentCurve = originalCurveList[currentIndex];
            if (flipped)
               currentCurve = currentCurve.CreateReversed();
            orientedCurveList.Add(currentCurve);
            currentIndex = flipped ? (currentIndex + 3) % 4 : (currentIndex + 1) % 4;
         }
         return orientedCurveList;
      }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:89,代码来源:IFCExtrudedAreaSolid.cs


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