Пример #1
0
 /// <summary>
 /// Adds a new linetype with specified definition to the linetype table.
 /// </summary>
 /// <param name="name">A name for the new linetype.</param>
 /// <param name="segmentLengths">Positive values are dashes, negative values are gaps.</param>
 /// <returns>
 /// Index of new linetype or -1 on error.
 /// </returns>
 public int Add(string name, IEnumerable <double> segmentLengths)
 {
     using (Runtime.InteropWrappers.SimpleArrayDouble segs = new Rhino.Runtime.InteropWrappers.SimpleArrayDouble(segmentLengths))
     {
         IntPtr pSegs = segs.NonConstPointer();
         return(UnsafeNativeMethods.CRhinoLinetypeTable_AddLinetype2(m_doc.RuntimeSerialNumber, name, pSegs));
     }
 }
Пример #2
0
    /// <summary>
    /// Divide the curve into specific length segments.
    /// </summary>
    /// <param name="segmentLength">The length of each and every segment (except potentially the last one).</param>
    /// <param name="includeStart">If true, then the points at the start of the curve is included.</param>
    /// <returns>Array containing division curve parameters if successful, null on failure.</returns>
    /// <example>
    /// <code source='examples\vbnet\ex_dividebylength.vb' lang='vbnet'/>
    /// <code source='examples\cs\ex_dividebylength.cs' lang='cs'/>
    /// <code source='examples\py\ex_dividebylength.py' lang='py'/>
    /// </example>
    public double[] DivideByLength(double segmentLength, bool includeStart)
    {
      IntPtr pConstThis = ConstPointer();
      SimpleArrayDouble outputParams = new SimpleArrayDouble();
      IntPtr outputParamsPtr = outputParams.NonConstPointer();

      bool success = UnsafeNativeMethods.RHC_RhinoDivideCurve3(pConstThis, segmentLength, includeStart, outputParamsPtr);

      double[] rc = null;
      if (success)
      {
        rc = outputParams.ToArray();
      }
      outputParams.Dispose();

      return success ? rc : null;
    }
Пример #3
0
    /// <summary>
    /// Several types of Curve can have the form of a polyline 
    /// including a degree 1 NurbsCurve, a PolylineCurve, 
    /// and a PolyCurve all of whose segments are some form of 
    /// polyline. IsPolyline tests a curve to see if it can be 
    /// represented as a polyline.
    /// </summary>
    /// <param name="polyline">
    /// If true is returned, then the polyline form is returned here.
    /// </param>
    /// <param name="parameters">
    /// if true is returned, then the parameters of the polyline
    /// points are returned here.
    /// </param>
    /// <returns>true if this curve can be represented as a polyline; otherwise, false.</returns>
    public bool TryGetPolyline(out Polyline polyline, out double[] parameters)
    {
      polyline = null;
      parameters = null;
      SimpleArrayPoint3d outputPts = new SimpleArrayPoint3d();
      int pointCount = 0;
      IntPtr pCurve = ConstPointer();
      IntPtr outputPointsPointer = outputPts.NonConstPointer();
      Rhino.Runtime.InteropWrappers.SimpleArrayDouble tparams = new SimpleArrayDouble();
      IntPtr ptparams = tparams.NonConstPointer();
      UnsafeNativeMethods.ON_Curve_IsPolyline2(pCurve, outputPointsPointer, ref pointCount, ptparams);
      if (pointCount > 0)
      {
        polyline = Polyline.PolyLineFromNativeArray(outputPts);
        parameters = tparams.ToArray();
      }

      tparams.Dispose();
      outputPts.Dispose();
      return (pointCount != 0);
    }