/// <summary>Utility for picking meshes</summary>
        /// <param name="mesh">mesh to test</param>
        /// <param name="pickStyle">mode used for pick test</param>
        /// <param name="hitPoint">location returned here for point picks</param>
        /// <param name="depth">
        /// depth returned here for point picks
        /// LARGER values are NEARER to the camera.
        /// SMALLER values are FARTHER from the camera.
        /// </param>
        /// <param name="distance">
        /// planar distance returned here for point picks.
        /// SMALLER values are CLOSER to the pick point
        /// </param>
        /// <param name="hitFlag">
        /// For point picks, How to interpret the hitIndex (vertex hit, edge hit, or face hit)
        /// </param>
        /// <param name="hitIndex">
        /// index of vertex/edge/face that was hit. Use hitFlag to determine what this index
        /// corresponds to
        /// </param>
        /// <returns></returns>
        public bool PickFrustumTest(Rhino.Geometry.Mesh mesh, MeshPickStyle pickStyle, out Rhino.Geometry.Point3d hitPoint, out double depth, out double distance, out MeshHitFlag hitFlag, out int hitIndex)
        {
            hitPoint = Rhino.Geometry.Point3d.Unset;
            depth    = -1;
            distance = -1;
            hitIndex = -1;
            IntPtr pConstThis = ConstPointer();
            IntPtr pConstMesh = mesh.ConstPointer();
            int    vef_flag   = -1;
            bool   rc         = UnsafeNativeMethods.CRhinoPickContext_PickMesh2(pConstThis, pConstMesh, (int)pickStyle, ref hitPoint, ref depth, ref distance, ref vef_flag, ref hitIndex);

            hitFlag = (MeshHitFlag)vef_flag;
            return(rc);
        }
Beispiel #2
0
        /// <summary>
        /// Constructs a Rhino_DotNet OnMesh that is a copy of a given mesh.
        /// </summary>
        /// <param name="source">A source brep.</param>
        /// <returns>
        /// Rhino_DotNet object on success. This will be an independent copy.
        /// </returns>
        public static object ToOnMesh(Rhino.Geometry.Mesh source)
        {
            object rc      = null;
            IntPtr pSource = source.ConstPointer();
            Type   onType  = GetRhinoDotNetType("RMA.OpenNURBS.OnMesh");

            if (IntPtr.Zero != pSource && null != onType)
            {
                System.Reflection.MethodInfo mi = onType.GetMethod("WrapNativePointer", new Type[] { typeof(IntPtr), typeof(bool), typeof(bool) });
                IntPtr pNewMesh = UnsafeNativeMethods.ON_Mesh_New(pSource);
                rc = mi.Invoke(null, new object[] { pNewMesh, false, true });
            }
            return(rc);
        }
 /// <summary>
 /// Utility for picking mesh vertices
 /// </summary>
 /// <param name="mesh"></param>
 /// <returns>indices of mesh topology vertices that were picked</returns>
 public int[] PickMeshTopologyVertices(Rhino.Geometry.Mesh mesh)
 {
     using (var indices = new Runtime.InteropWrappers.SimpleArrayInt())
     {
         IntPtr pConstThis = ConstPointer();
         IntPtr pConstMesh = mesh.ConstPointer();
         IntPtr pIndices   = indices.NonConstPointer();
         int    rc         = UnsafeNativeMethods.CRhinoPickContext_PickMeshTopologyVertices(pConstThis, pConstMesh, pIndices);
         if (rc < 1)
         {
             return(new int[0]);
         }
         return(indices.ToArray());
     }
 }
 public void Add(Rhino.Geometry.Mesh mesh, RenderMaterial material)
 {
     UnsafeNativeMethods.Rdk_CustomMeshes_AddMesh(NonConstPointer(), mesh.ConstPointer(), material.ConstPointer());
 }