Exemplo n.º 1
0
        /// <summary>
        /// Calls another more complicated, exported function
        /// </summary>
        public static int MooseFunction2(Brep brep, int x, int y, IEnumerable <Point3d> points, out Line[] lines)
        {
            if (null == brep)
            {
                throw new ArgumentNullException("brep");
            }

            // Get the native ON_Brep pointer
            var const_ptr_brep = Interop.NativeGeometryConstPointer(brep);

            var pts     = new List <Point3d>(points);
            var ptarray = pts.ToArray();

            // Creates a ON_SimpleArray<ON_Line> wrapper class instance
            var lines_array = new Rhino.Runtime.InteropWrappers.SimpleArrayLine();
            // Get a non-const point to this class
            var ptr_lines_array = lines_array.NonConstPointer();

            var rc = Environment.Is64BitProcess ?
                     UnsafeNativeMethods64.MooseFunction2(const_ptr_brep, x, y, ptarray.Length, ptarray, ptr_lines_array) :
                     UnsafeNativeMethods32.MooseFunction2(const_ptr_brep, x, y, ptarray.Length, ptarray, ptr_lines_array);

            lines = rc > 0 ? lines_array.ToArray() : new Line[0];
            lines_array.Dispose();

            return(rc);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Example function
        /// </summary>
        public static int ExampleFunction(Brep brep, int x, int y, out Point3d[] points, out Line[] lines)
        {
            if (null == brep)
            {
                throw new ArgumentNullException(nameof(brep));
            }

            // Get the native ON_Brep pointer
            var const_ptr_brep = Interop.NativeGeometryConstPointer(brep);

            // Creates a ON_3dPointArray wrapper class instance
            var points_array = new Rhino.Runtime.InteropWrappers.SimpleArrayPoint3d();
            // Get a non-const point to this class
            var ptr_points_array = points_array.NonConstPointer();

            // Creates a ON_SimpleArray<ON_Line> wrapper class instance
            var lines_array = new Rhino.Runtime.InteropWrappers.SimpleArrayLine();
            // Get a non-const point to this class
            var ptr_lines_array = lines_array.NonConstPointer();

            var rc = UnsafeNativeMethods.MooseFunction(const_ptr_brep, x, y, ptr_points_array, ptr_lines_array);

            if (rc > 0)
            {
                points = points_array.ToArray();
                lines  = lines_array.ToArray();
            }
            else
            {
                points = new Point3d[0];
                lines  = new Line[0];
            }

            points_array.Dispose();
            lines_array.Dispose();

            return(rc);
        }