/// <summary> /// Gets a list of all the InstanceDefinitions that contain a reference this InstanceDefinition. /// </summary> /// <returns>An array of instance definitions. The returned array can be empty, but not null.</returns> public InstanceDefinition[] GetContainers() { using (Runtime.InteropWrappers.SimpleArrayInt arr = new Rhino.Runtime.InteropWrappers.SimpleArrayInt()) { IntPtr ptr = arr.m_ptr; int count = UnsafeNativeMethods.CRhinoInstanceDefinition_GetContainers(m_doc.m_docId, m_index, ptr); InstanceDefinition[] rc = null; if (count > 0) { int[] indices = arr.ToArray(); if (indices != null) { count = indices.Length; rc = new InstanceDefinition[count]; for (int i = 0; i < count; i++) { rc[i] = new InstanceDefinition(indices[i], m_doc); } } } else { rc = new InstanceDefinition[0]; } return(rc); } }
/// <summary> /// Gets immediate children of this layer. Note that child layers may have their own children. /// </summary> /// <returns>Array of child layers. null if this layer does not have any children.</returns> public Layer[] GetChildren() { Runtime.InteropWrappers.SimpleArrayInt childIndices = new Rhino.Runtime.InteropWrappers.SimpleArrayInt(); int index = LayerIndex; int count = UnsafeNativeMethods.CRhinoLayerNode_GetChildren(m_doc.m_docId, index, childIndices.m_ptr); Layer[] rc = null; if (count > 0) { int[] indices = childIndices.ToArray(); count = indices.Length; rc = new Layer[count]; for (int i = 0; i < count; i++) { rc[i] = new Layer(indices[i], m_doc); } } childIndices.Dispose(); return(rc); }
/// <summary>Finds the first intersection of a ray with a mesh.</summary> /// <param name="mesh">A mesh to intersect.</param> /// <param name="ray">A ray to be casted.</param> /// <param name="meshFaceIndices">faces on mesh that ray intersects.</param> /// <returns> /// >= 0.0 parameter along ray if successful. /// < 0.0 if no intersection found. /// </returns> /// <remarks> /// The ray may intersect more than one face in cases where the ray hits /// the edge between two faces or the vertex corner shared by multiple faces. /// </remarks> public static double MeshRay(Mesh mesh, Ray3d ray, out int[] meshFaceIndices) { meshFaceIndices = null; using (Runtime.InteropWrappers.SimpleArrayInt indices = new Rhino.Runtime.InteropWrappers.SimpleArrayInt()) { IntPtr pConstMesh = mesh.ConstPointer(); double rc = UnsafeNativeMethods.ON_Intersect_MeshRay1(pConstMesh, ref ray, indices.m_ptr ); int[] vals = indices.ToArray(); if (vals!=null && vals.Length > 0) meshFaceIndices = vals; return rc; } }