/// <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;
      }
    }
    /// <summary>
    /// Finds the object (and the closest point in that object) that is closest to
    /// this curve. <para><see cref="Brep">Breps</see>, <see cref="Surface">surfaces</see>,
    /// <see cref="Curve">curves</see> and <see cref="PointCloud">point clouds</see> are examples of
    /// objects that can be passed to this function.</para>
    /// </summary>
    /// <param name="geometry">A list, an array or any enumerable set of geometry to search.</param>
    /// <param name="pointOnCurve">The point on curve. This out parameter is assigned during this call.</param>
    /// <param name="pointOnObject">The point on geometry. This out parameter is assigned during this call.</param>
    /// <param name="whichGeometry">The index of the geometry. This out parameter is assigned during this call.</param>
    /// <param name="maximumDistance">Maximum allowable distance. Past this distance, the research is given up and false is returned.</param>
    /// <returns>true on success; false if no object was found or selected.</returns>
    /// <exception cref="ArgumentNullException">If geometry is null.</exception>
    public bool ClosestPoints(IEnumerable<GeometryBase> geometry,
      out Point3d pointOnCurve,
      out Point3d pointOnObject,
      out int whichGeometry,
      double maximumDistance)
    {
      if (geometry == null) throw new ArgumentNullException("geometry");

      using (SimpleArrayGeometryPointer geom = new SimpleArrayGeometryPointer(geometry))
      {
        pointOnCurve = Point3d.Unset;
        pointOnObject = Point3d.Unset;
        IntPtr pConstThis = ConstPointer();
        IntPtr pGeometryArray = geom.ConstPointer();
        whichGeometry = 0;
        bool rc = UnsafeNativeMethods.RHC_RhinoGetClosestPoint(pConstThis, pGeometryArray, maximumDistance, ref pointOnCurve, ref pointOnObject, ref whichGeometry);
        return rc;
      }
    }