示例#1
0
        public bool Extend(CurveEnd end, double length, CurveExtensionStyle style = CurveExtensionStyle.Smooth)
        {
            Curve c = Centreline.Extend(end, length, style);

            if (c == null)
            {
                return(false);
            }

            Centreline = c;
            return(true);
        }
示例#2
0
    /// <summary>
    /// Extends a curve to a point.
    /// </summary>
    /// <param name="side">The end of the curve to extend.</param>
    /// <param name="style">The style or type of extension to use.</param>
    /// <param name="endPoint">A new end point.</param>
    /// <returns>New extended curve result on success, null on failure.</returns>
    public Curve Extend(CurveEnd side, CurveExtensionStyle style, Point3d endPoint)
    {
      if (CurveEnd.None == side)
        return null;
      int _side = 0;
      if (CurveEnd.End == side)
        _side = 1;
      else if (CurveEnd.Both == side)
        _side = 2;

      IntPtr pConstPtr = ConstPointer();

      int extendStyle = idxExtendTypeLine;
      if (style == CurveExtensionStyle.Arc)
        extendStyle = idxExtendTypeArc;
      else if (style == CurveExtensionStyle.Smooth)
        extendStyle = idxExtendTypeSmooth;

      IntPtr rc = UnsafeNativeMethods.RHC_RhinoExtendCurve2(pConstPtr, extendStyle, _side, endPoint);
      return GeometryBase.CreateGeometryHelper(rc, null) as Curve;
    }
示例#3
0
    /// <summary>
    /// Extends a curve until it intersects a collection of objects.
    /// </summary>
    /// <param name="side">The end of the curve to extend.</param>
    /// <param name="style">The style or type of extension to use.</param>
    /// <param name="geometry">A collection of objects. Allowable object types are Curve, Surface, Brep.</param>
    /// <returns>New extended curve result on success, null on failure.</returns>
    public Curve Extend(CurveEnd side, CurveExtensionStyle style, System.Collections.Generic.IEnumerable<GeometryBase> geometry)
    {
      if (CurveEnd.None == side)
        return null;
      int _side = 0;
      if (CurveEnd.End == side)
        _side = 1;
      else if (CurveEnd.Both == side)
        _side = 2;

      IntPtr pConstPtr = ConstPointer();

      using (SimpleArrayGeometryPointer geometryArray = new SimpleArrayGeometryPointer(geometry))
      {
        IntPtr geometryArrayPtr = geometryArray.ConstPointer();

        int extendStyle = idxExtendTypeLine;
        if (style == CurveExtensionStyle.Arc)
          extendStyle = idxExtendTypeArc;
        else if (style == CurveExtensionStyle.Smooth)
          extendStyle = idxExtendTypeSmooth;

        IntPtr rc = UnsafeNativeMethods.RHC_RhinoExtendCurve1(pConstPtr, extendStyle, _side, geometryArrayPtr);
        return GeometryBase.CreateGeometryHelper(rc, null) as Curve;
      }
    }
示例#4
0
    /// <summary>
    /// Extends a curve by a specific length.
    /// </summary>
    /// <param name="side">Curve end to extend.</param>
    /// <param name="length">Length to add to the curve end.</param>
    /// <param name="style">Extension style.</param>
    /// <returns>A curve with extended ends or null on failure.</returns>
    public Curve Extend(CurveEnd side, double length, CurveExtensionStyle style)
    {
      if (side == CurveEnd.None)
        return DuplicateCurve();

      length = Math.Max(length, 0.0);

      double l0 = length;
      double l1 = length;

      if (side == CurveEnd.End)
        l0 = 0.0;
      if (side == CurveEnd.Start)
        l1 = 0.0;

      IntPtr ptr = ConstPointer();
      IntPtr rc = UnsafeNativeMethods.RHC_RhinoExtendCurve(ptr, l0, l1, (int)style);
      return GeometryBase.CreateGeometryHelper(rc, null) as Curve;
    }
示例#5
0
    /// <summary>
    /// Extends a curve to a point.
    /// </summary>
    /// <param name="side">The end of the curve to extend.</param>
    /// <param name="style">The style or type of extension to use.</param>
    /// <param name="endPoint">A new end point.</param>
    /// <returns>New extended curve result on success, null on failure.</returns>
    public Curve Extend(CurveEnd side, CurveExtensionStyle style, Point3d endPoint)
    {
      if (CurveEnd.None == side)
        return null;
      int _side = 0;
      if (CurveEnd.End == side)
        _side = 1;
      else if (CurveEnd.Both == side)
        _side = 2;

      IntPtr pConstPtr = ConstPointer();

      IntPtr rc = UnsafeNativeMethods.RHC_RhinoExtendCurve2(pConstPtr, ConvertExtensionStyle(style), _side, endPoint);
      return GeometryBase.CreateGeometryHelper(rc, null) as Curve;
    }
示例#6
0
    static UnsafeNativeMethods.ExtendCurveConsts ConvertExtensionStyle(CurveExtensionStyle style)
    {
      if (style == CurveExtensionStyle.Arc)
        return UnsafeNativeMethods.ExtendCurveConsts.ExtendTypeArc;
      if (style == CurveExtensionStyle.Line)
        return UnsafeNativeMethods.ExtendCurveConsts.ExtendTypeLine;

      return UnsafeNativeMethods.ExtendCurveConsts.ExtendTypeSmooth;
    }