/// <summary> /// Creates preview line segments of the hatch pattern. /// </summary> /// <param name="width">The width of the preview.</param> /// <param name="height">The height of the preview.</param> /// <param name="angle">The rotation angle of the pattern display in radians.</param> /// <returns>The preview line segments if successful, an empty array on failure.</returns> /// <since>6.8</since> public Rhino.Geometry.Line[] CreatePreviewGeometry(int width, int height, double angle) { IntPtr const_ptr_this = ConstPointer(); using (var line_array = new Runtime.InteropWrappers.SimpleArrayLine()) { IntPtr ptr_lines = line_array.NonConstPointer(); int rc = UnsafeNativeMethods.RHC_RhCreateHatchPatternPreviewGeometry(const_ptr_this, width, height, angle, ptr_lines); if (rc == 0) { return(new Rhino.Geometry.Line[0]); } return(line_array.ToArray()); } }
/// <summary> /// Generate geometry that would be used to draw the hatch with a given hatch pattern /// </summary> /// <param name="pattern"></param> /// <param name="patternScale"></param> /// <param name="bounds"></param> /// <param name="lines"></param> /// <param name="solidBrep"></param> public void CreateDisplayGeometry(DocObjects.HatchPattern pattern, double patternScale, out Curve[] bounds, out Line[] lines, out Brep solidBrep) { IntPtr const_ptr_this = ConstPointer(); IntPtr const_ptr_pattern = pattern.ConstPointer(); using (var curve_array = new Runtime.InteropWrappers.SimpleArrayCurvePointer()) using (var line_array = new Runtime.InteropWrappers.SimpleArrayLine()) { IntPtr ptr_curves = curve_array.NonConstPointer(); IntPtr ptr_lines = line_array.NonConstPointer(); IntPtr ptr_brep = UnsafeNativeMethods.CRhinoHatchPattern_CreateDisplay(const_ptr_this, const_ptr_pattern, patternScale, ptr_curves, ptr_lines); solidBrep = (ptr_brep == IntPtr.Zero) ? null : new Brep(ptr_brep, null); bounds = curve_array.ToNonConstArray(); lines = line_array.ToArray(); } }
/// <summary> /// Quickly intersects two meshes. Overlaps and near misses are ignored. /// </summary> /// <param name="meshA">First mesh for intersection.</param> /// <param name="meshB">Second mesh for intersection.</param> /// <returns>An array of intersection line segments.</returns> public static Line[] MeshMeshFast(Mesh meshA, Mesh meshB) { IntPtr ptrA = meshA.ConstPointer(); IntPtr ptrB = meshB.ConstPointer(); Line[] intersectionLines = new Line[0]; using (Runtime.InteropWrappers.SimpleArrayLine arr = new Runtime.InteropWrappers.SimpleArrayLine()) { IntPtr pLines = arr.NonConstPointer(); int rc = UnsafeNativeMethods.ON_Mesh_IntersectMesh(ptrA, ptrB, pLines); if (rc > 0) intersectionLines = arr.ToArray(); } return intersectionLines; }
/// <summary> /// Generate geometry that would be used to draw the hatch with a given hatch pattern /// </summary> /// <param name="pattern"></param> /// <param name="patternScale"></param> /// <param name="bounds"></param> /// <param name="lines"></param> /// <param name="solidBrep"></param> public void CreateDisplayGeometry(DocObjects.HatchPattern pattern, double patternScale, out Curve[] bounds, out Line[] lines, out Brep solidBrep) { IntPtr const_ptr_this = ConstPointer(); IntPtr const_ptr_pattern = pattern.ConstPointer(); using(var curve_array = new Runtime.InteropWrappers.SimpleArrayCurvePointer()) using(var line_array = new Runtime.InteropWrappers.SimpleArrayLine()) { IntPtr ptr_curves = curve_array.NonConstPointer(); IntPtr ptr_lines = line_array.NonConstPointer(); IntPtr ptr_brep = UnsafeNativeMethods.CRhinoHatchPattern_CreateDisplay(const_ptr_this, const_ptr_pattern, patternScale, ptr_curves, ptr_lines); solidBrep = (ptr_brep==IntPtr.Zero) ? null : new Brep(ptr_brep, null); bounds = curve_array.ToNonConstArray(); lines = line_array.ToArray(); } }