Exemplo n.º 1
0
    /// <summary>
    /// Projects points onto breps.
    /// </summary>
    /// <param name="breps">The breps projection targets.</param>
    /// <param name="points">The points to project.</param>
    /// <param name="direction">The direction to project.</param>
    /// <param name="tolerance">The tolerance used for intersections.</param>
    /// <returns>
    /// Array of projected points, or null in case of any error or invalid input.
    /// </returns>
    /// <example>
    /// <code source='examples\vbnet\ex_projectpointstobreps.vb' lang='vbnet'/>
    /// <code source='examples\cs\ex_projectpointstobreps.cs' lang='cs'/>
    /// <code source='examples\py\ex_projectpointstobreps.py' lang='py'/>
    /// </example>
    public static Point3d[] ProjectPointsToBreps(IEnumerable<Brep> breps, IEnumerable<Point3d> points, Vector3d direction, double tolerance)
    {
      Point3d[] rc = null;
      if (breps != null && points != null)
      {
        Rhino.Runtime.InteropWrappers.SimpleArrayBrepPointer brep_array = new Rhino.Runtime.InteropWrappers.SimpleArrayBrepPointer();
        foreach (Brep brep in breps)
          brep_array.Add(brep, true);

        Rhino.Collections.Point3dList inputpoints = new Rhino.Collections.Point3dList(points);
        if (inputpoints.Count > 0)
        {
          IntPtr pConstBrepArray = brep_array.ConstPointer();

          using (Runtime.InteropWrappers.SimpleArrayPoint3d output = new Rhino.Runtime.InteropWrappers.SimpleArrayPoint3d())
          {
            IntPtr pOutput = output.NonConstPointer();
            if (UnsafeNativeMethods.RHC_RhinoProjectPointsToBreps(pConstBrepArray, direction, tolerance, inputpoints.Count, inputpoints.m_items, pOutput))
              rc = output.ToArray();
          }
        }
      }
      return rc;
    }