/// <summary>
        /// Calls a more complicated, exported function
        /// </summary>
        public static int MooseFunction(Brep brep, int x, int y, out 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);

            // 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 = Environment.Is64BitProcess ?
                     UnsafeNativeMethods64.MooseFunction(const_ptr_brep, x, y, ptr_points_array, ptr_lines_array) :
                     UnsafeNativeMethods32.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);
        }
        /// <summary>
        /// Retrieves a Polyline at a given array index.
        /// </summary>
        /// <param name="index">THe index</param>
        /// <returns>The Polyline if successful, null otherwise.</returns>
        public Polyline Get(int index)
        {
            if (index < 0 || index >= Count)
            {
                return(null);
            }

            var points_array     = new Rhino.Runtime.InteropWrappers.SimpleArrayPoint3d();
            var ptr_points_array = points_array.NonConstPointer();
            var cnt = UnsafeNativeMethods.ON_PolylineArray_Get(m_ptr, index, ptr_points_array);

            Polyline rc = null;

            if (cnt > 0)
            {
                rc = new Polyline(points_array.ToArray());
            }

            points_array.Dispose();

            return(rc);
        }
示例#3
0
 /// <summary>
 /// Gets current construction points.
 /// </summary>
 /// <returns>An array of points.</returns>
 /// <remarks>
 /// Construction points are like snap points except that they get snapped to
 /// even when point osnap is off. Typically, there are only a few construction
 /// points while there can be many snap points. For example, when polylines
 /// are drawn the start point is a construction point and the other points are
 /// snap points.
 /// </remarks>
 public Point3d[] GetConstructionPoints()
 {
   Runtime.InteropWrappers.SimpleArrayPoint3d pts = new Rhino.Runtime.InteropWrappers.SimpleArrayPoint3d();
   IntPtr pGetPoint = ConstPointer();
   IntPtr pArray = pts.NonConstPointer();
   UnsafeNativeMethods.CRhinoGetPoint_GetSnapPoints(pGetPoint, pArray, false);
   Point3d[] rc = pts.ToArray();
   pts.Dispose();
   return rc;
 }