Пример #1
0
    /// <summary>
    /// Offset a curve on a brep face surface. This curve must lie on the surface.
    /// <para>This overload allows to specify a surface point at which the offset will pass.</para>
    /// </summary>
    /// <param name="face">The brep face on which to offset.</param>
    /// <param name="throughPoint">2d point on the brep face to offset through.</param>
    /// <param name="fittingTolerance">A fitting tolerance.</param>
    /// <returns>Offset curves on success, or null on failure.</returns>
    /// <exception cref="ArgumentNullException">If face is null.</exception>
    public Curve[] OffsetOnSurface(BrepFace face, Point2d throughPoint, double fittingTolerance)
    {
      if (face == null)
        throw new ArgumentNullException("face");

      int fid = face.m_index;
      IntPtr pConstBrep = face.m_brep.ConstPointer();
      SimpleArrayCurvePointer offsetCurves = new SimpleArrayCurvePointer();
      IntPtr pCurveArray = offsetCurves.NonConstPointer();
      IntPtr pConstCurve = ConstPointer();
      int count = UnsafeNativeMethods.RHC_RhinoOffsetCurveOnSrf2(pConstCurve, pConstBrep, fid, throughPoint, fittingTolerance, pCurveArray);
      Curve[] curves = offsetCurves.ToNonConstArray();
      offsetCurves.Dispose();
      if (count < 1)
        return null;
      return curves;
    }
Пример #2
0
    /// <summary>
    /// Offset a curve on a brep face surface. This curve must lie on the surface.
    /// <para>This overload allows to specify different offsets for different curve parameters.</para>
    /// </summary>
    /// <param name="face">The brep face on which to offset.</param>
    /// <param name="curveParameters">Curve parameters corresponding to the offset distances.</param>
    /// <param name="offsetDistances">distances to offset (+)left, (-)right.</param>
    /// <param name="fittingTolerance">A fitting tolerance.</param>
    /// <returns>Offset curves on success, or null on failure.</returns>
    /// <exception cref="ArgumentNullException">If face, curveParameters or offsetDistances are null.</exception>
    public Curve[] OffsetOnSurface(BrepFace face, double[] curveParameters, double[] offsetDistances, double fittingTolerance)
    {
      if (face == null) throw new ArgumentNullException("face");
      if (curveParameters == null) throw new ArgumentNullException("curveParameters");
      if (offsetDistances == null) throw new ArgumentNullException("offsetDistances");

      int array_count = curveParameters.Length;
      if (offsetDistances.Length != array_count)
        throw new ArgumentException("curveParameters and offsetDistances must be the same length");

      int fid = face.m_index;
      IntPtr pConstBrep = face.m_brep.ConstPointer();
      SimpleArrayCurvePointer offsetCurves = new SimpleArrayCurvePointer();
      IntPtr pCurveArray = offsetCurves.NonConstPointer();
      IntPtr pConstCurve = ConstPointer();
      int count = UnsafeNativeMethods.RHC_RhinoOffsetCurveOnSrf3(pConstCurve, pConstBrep, fid, array_count, curveParameters, offsetDistances, fittingTolerance, pCurveArray);
      Curve[] curves = offsetCurves.ToNonConstArray();
      offsetCurves.Dispose();
      if (count < 1)
        return null;
      return curves;
    }
Пример #3
0
 /// <summary>
 /// Offsets this curve. If you have a nice offset, then there will be one entry in 
 /// the array. If the original curve had kinks or the offset curve had self 
 /// intersections, you will get multiple segments in the offset_curves[] array.
 /// </summary>
 /// <param name="directionPoint">A point that indicates the direction of the offset.</param>
 /// <param name="normal">The normal to the offset plane.</param>
 /// <param name="distance">The positive or negative distance to offset.</param>
 /// <param name="tolerance">The offset or fitting tolerance.</param>
 /// <param name="cornerStyle">Corner style for offset kinks.</param>
 /// <returns>Offset curves on success, null on failure.</returns>
 public Curve[] Offset(Point3d directionPoint, Vector3d normal, double distance, double tolerance, CurveOffsetCornerStyle cornerStyle)
 {
   IntPtr ptr = ConstPointer();
   SimpleArrayCurvePointer offsetCurves = new SimpleArrayCurvePointer();
   IntPtr pCurveArray = offsetCurves.NonConstPointer();
   bool rc = UnsafeNativeMethods.RHC_RhinoOffsetCurve2(ptr, distance, directionPoint, normal, (int)cornerStyle, tolerance, pCurveArray);
   Curve[] curves = offsetCurves.ToNonConstArray();
   offsetCurves.Dispose();
   if (!rc)
     return null;
   return curves;
 }