Example #1
0
 /// <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);
     }
 }
Example #2
0
        /// <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>
    /// Projects a collection of Curves onto a collection of Breps along a given direction.
    /// </summary>
    /// <param name="curves">Curves to project.</param>
    /// <param name="breps">Breps to project onto.</param>
    /// <param name="direction">Direction of projection.</param>
    /// <param name="tolerance">Tolerance to use for projection.</param>
    /// <param name="curveIndices">Index of which curve in the input list was the source for a curve in the return array.</param>
    /// <param name="brepIndices">Index of which brep was used to generate a curve in the return array.</param>
    /// <returns>An array of projected curves. Array is empty if the projection set is empty.</returns>
    public static Curve[] ProjectToBrep(IEnumerable<Curve> curves, IEnumerable<Brep> breps, Vector3d direction, double tolerance, out int[] curveIndices, out int[] brepIndices)
    {
      curveIndices = null;
      brepIndices = null;

      foreach (Curve crv in curves) { if (crv == null) { throw new ArgumentNullException("curves"); } }
      foreach (Brep brp in breps) { if (brp == null) { throw new ArgumentNullException("breps"); } }

      SimpleArrayCurvePointer crv_array = new SimpleArrayCurvePointer(curves);
      Runtime.InteropWrappers.SimpleArrayBrepPointer brp_array = new Runtime.InteropWrappers.SimpleArrayBrepPointer();
      foreach (Brep brp in breps) { brp_array.Add(brp, true); }

      IntPtr ptr_crv_array = crv_array.ConstPointer();
      IntPtr ptr_brp_array = brp_array.ConstPointer();

      SimpleArrayInt brp_top = new SimpleArrayInt();
      SimpleArrayInt crv_top = new SimpleArrayInt();

      SimpleArrayCurvePointer rc = new SimpleArrayCurvePointer();
      IntPtr ptr_rc = rc.NonConstPointer();

      if (UnsafeNativeMethods.RHC_RhinoProjectCurveToBrepEx(ptr_brp_array,
                                                            ptr_crv_array,
                                                            direction,
                                                            tolerance,
                                                            ptr_rc,
                                                            brp_top.m_ptr,
                                                            crv_top.m_ptr))
      {
        brepIndices = brp_top.ToArray();
        curveIndices = crv_top.ToArray();
        return rc.ToNonConstArray();
      }
      return new Curve[0];
    }
Example #4
0
 public static System.Windows.Forms.DialogResult ShowSelectMultipleLayersDialog(IEnumerable<int> defaultLayerIndices, string dialogTitle, bool showNewLayerButton, out int[] layerIndices)
 {
   using (var array_int = new SimpleArrayInt(defaultLayerIndices))
   {
     IntPtr ptr_array_int = array_int.NonConstPointer();
     bool rc = UnsafeNativeMethods.RHC_RhinoSelectMultipleLayersDialog(dialogTitle, ptr_array_int, true, showNewLayerButton);
     layerIndices = rc ? array_int.ToArray() : new int[0];
     return rc ? System.Windows.Forms.DialogResult.OK : System.Windows.Forms.DialogResult.Cancel;
   }
 }