/// <summary>
        /// Constructs an array of <see cref="Hatch">hatches</see> from a set of curves.
        /// </summary>
        /// <param name="curves">An array, a list or any enumarable set of <see cref="Curve"/>.</param>
        /// <param name="hatchPatternIndex">The index of the hatch pattern in the document hatch pattern table.</param>
        /// <param name="rotationRadians">The relative rotation of the pattern.</param>
        /// <param name="scale">A scaling factor.</param>
        /// <returns>An array of hatches. The array might be empty on error.</returns>
        /// <exception cref="ArgumentNullException">If curves is null.</exception>
        public static Hatch[] Create(IEnumerable <Curve> curves, int hatchPatternIndex, double rotationRadians, double scale)
        {
            if (curves == null)
            {
                throw new ArgumentNullException("curves");
            }

            Rhino.Runtime.InteropWrappers.SimpleArrayCurvePointer curvearray = new Rhino.Runtime.InteropWrappers.SimpleArrayCurvePointer(curves);
            IntPtr pCurveArray = curvearray.NonConstPointer();

            Rhino.Runtime.InteropWrappers.SimpleArrayGeometryPointer hatcharray = new Rhino.Runtime.InteropWrappers.SimpleArrayGeometryPointer();
            IntPtr pOutput = hatcharray.NonConstPointer();

            UnsafeNativeMethods.RHC_RhinoCreateHatches(pCurveArray, hatchPatternIndex, rotationRadians, scale, pOutput);
            GeometryBase[] g = hatcharray.ToNonConstArray();
            if (g == null)
            {
                return(new Hatch[0]);
            }
            List <Hatch> hatches = new List <Hatch>();

            for (int i = 0; i < g.Length; i++)
            {
                Hatch hatch = g[i] as Hatch;
                if (hatch != null)
                {
                    hatches.Add(hatch);
                }
            }
            return(hatches.ToArray());
        }
Example #2
0
    /// <summary>
    /// Constructs an array of <see cref="Hatch">hatches</see> from a set of curves.
    /// </summary>
    /// <param name="curves">An array, a list or any enumarable set of <see cref="Curve"/>.</param>
    /// <param name="hatchPatternIndex">The index of the hatch pattern in the document hatch pattern table.</param>
    /// <param name="rotationRadians">The relative rotation of the pattern.</param>
    /// <param name="scale">A scaling factor.</param>
    /// <returns>An array of hatches. The array might be empty on error.</returns>
    /// <exception cref="ArgumentNullException">If curves is null.</exception>
    public static Hatch[] Create(IEnumerable<Curve> curves, int hatchPatternIndex, double rotationRadians, double scale)
    {
      if (curves == null) throw new ArgumentNullException("curves");

      Rhino.Runtime.InteropWrappers.SimpleArrayCurvePointer curvearray = new Rhino.Runtime.InteropWrappers.SimpleArrayCurvePointer(curves);
      IntPtr pCurveArray = curvearray.NonConstPointer();
      Rhino.Runtime.InteropWrappers.SimpleArrayGeometryPointer hatcharray = new Rhino.Runtime.InteropWrappers.SimpleArrayGeometryPointer();
      IntPtr pOutput = hatcharray.NonConstPointer();
      UnsafeNativeMethods.RHC_RhinoCreateHatches(pCurveArray, hatchPatternIndex, rotationRadians, scale, pOutput);
      GeometryBase[] g = hatcharray.ToNonConstArray();
      if( g==null )
        return new Hatch[0];
      List<Hatch> hatches = new List<Hatch>();
      for (int i = 0; i < g.Length; i++)
      {
        Hatch hatch = g[i] as Hatch;
        if (hatch != null)
          hatches.Add(hatch);
      }
      return hatches.ToArray();
    }
        /// <summary>
        /// Decomposes the hatch pattern into an array of geometry.
        /// </summary>
        /// <returns>An array of geometry that formed the appearance of the original elements.</returns>
        /// <example>
        /// <code source='examples\vbnet\ex_explodehatch.vb' lang='vbnet'/>
        /// <code source='examples\cs\ex_explodehatch.cs' lang='cs'/>
        /// <code source='examples\py\ex_explodehatch.py' lang='py'/>
        /// </example>
        public GeometryBase[] Explode()
        {
            using (Rhino.Runtime.InteropWrappers.SimpleArrayGeometryPointer geometry = new Rhino.Runtime.InteropWrappers.SimpleArrayGeometryPointer())
            {
                IntPtr pParentRhinoObject = IntPtr.Zero;

                if (IsDocumentControlled)
                {
                    Rhino.DocObjects.RhinoObject rhobj = ParentRhinoObject();
                    if (rhobj != null)
                    {
                        pParentRhinoObject = rhobj.ConstPointer();
                    }
                }
                IntPtr pGeometryArray = geometry.NonConstPointer();
                IntPtr pConstThis     = ConstPointer();

                UnsafeNativeMethods.ON_Hatch_Explode(pConstThis, pParentRhinoObject, pGeometryArray);
                GeometryBase[] rc = geometry.ToNonConstArray();
                return(rc);
            }
        }
Example #4
0
    /// <summary>
    /// Decomposes the hatch pattern into an array of geometry.
    /// </summary>
    /// <returns>An array of geometry that formed the appearance of the original elements.</returns>
    /// <example>
    /// <code source='examples\vbnet\ex_explodehatch.vb' lang='vbnet'/>
    /// <code source='examples\cs\ex_explodehatch.cs' lang='cs'/>
    /// <code source='examples\py\ex_explodehatch.py' lang='py'/>
    /// </example>
    public GeometryBase[] Explode()
    {
      Rhino.Runtime.InteropWrappers.SimpleArrayGeometryPointer geometry = new Rhino.Runtime.InteropWrappers.SimpleArrayGeometryPointer();
      IntPtr pParentRhinoObject = IntPtr.Zero;

#if RHINO_SDK
      if (IsDocumentControlled)
      {
        Rhino.DocObjects.RhinoObject rhobj = ParentRhinoObject();
        if (rhobj != null)
          pParentRhinoObject = rhobj.ConstPointer();
      }
#endif
      IntPtr pGeometryArray = geometry.NonConstPointer();
      IntPtr pConstThis = ConstPointer();

      UnsafeNativeMethods.ON_Hatch_Explode(pConstThis, pParentRhinoObject, pGeometryArray);
      GeometryBase[] rc = geometry.ToNonConstArray();
      geometry.Dispose();
      return rc;
    }