Esempio n. 1
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 enumerable 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>
        /// <param name="tolerance"></param>
        /// <returns>An array of hatches. The array might be empty on error.</returns>
        /// <exception cref="ArgumentNullException">If curves is null.</exception>
        /// <since>6.0</since>
        public static Hatch[] Create(IEnumerable <Curve> curves, int hatchPatternIndex, double rotationRadians, double scale, double tolerance)
        {
            if (curves == null)
            {
                throw new ArgumentNullException("curves");
            }

            var    curvearray      = new Runtime.InteropWrappers.SimpleArrayCurvePointer(curves);
            IntPtr ptr_curve_array = curvearray.NonConstPointer();
            var    hatcharray      = new Runtime.InteropWrappers.SimpleArrayGeometryPointer();
            IntPtr ptr_hatch_array = hatcharray.NonConstPointer();

            UnsafeNativeMethods.RHC_RhinoCreateHatches(ptr_curve_array, tolerance, hatchPatternIndex, rotationRadians, scale, ptr_hatch_array);
            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);
                }
            }
            GC.KeepAlive(curves);
            return(hatches.ToArray());
        }
Esempio n. 2
0
        public GeometryBase[] Explode()
        {
            using (Runtime.InteropWrappers.SimpleArrayGeometryPointer geometry = new Runtime.InteropWrappers.SimpleArrayGeometryPointer())
            {
                IntPtr ptr_parent_rhinoobject = IntPtr.Zero;

                if (IsDocumentControlled)
                {
                    DocObjects.RhinoObject rhobj = ParentRhinoObject();
                    if (rhobj != null)
                    {
                        ptr_parent_rhinoobject = rhobj.ConstPointer();
                    }
                }
                IntPtr ptr_geometry_array = geometry.NonConstPointer();
                IntPtr const_ptr_this     = ConstPointer();

                UnsafeNativeMethods.ON_Hatch_Explode(const_ptr_this, ptr_parent_rhinoobject, ptr_geometry_array);
                GeometryBase[] rc = geometry.ToNonConstArray();
                return(rc);
            }
        }