/// <summary> /// Create a regular star polygon. The star begins at circle.PointAt(0) and the vertices /// alternate between being on circle and begin on a concentric circle of other_radius. /// </summary> /// <param name="circle">The circle.</param> /// <param name="radius">The radius of other circle.</param> /// <param name="cornerCount">The number of corners on the circle. There will be 2*cornerCount sides and 2*cornerCount vertices.</param> /// <returns>A closed polyline if successful, null otherwise.</returns> /// <since>6.10</since> public static Polyline CreateStarPolygon(Circle circle, double radius, int cornerCount) { using (var output_points = new SimpleArrayPoint3d()) { IntPtr output_points_ptr = output_points.NonConstPointer(); bool rc = UnsafeNativeMethods.ON_Polyline_CreateStarPolygon(ref circle, radius, cornerCount, output_points_ptr); return(rc ? Polyline.PolyLineFromNativeArray(output_points) : null); } }
/// <summary> /// Create a regular polygon circumscribe about a circle. The midpoints of the polygon's edges will be tangent to the circle. /// </summary> /// <param name="circle">The circle.</param> /// <param name="sideCount">The number of sides</param> /// <returns>A closed polyline if successful, null otherwise.</returns> /// <since>6.10</since> public static Polyline CreateCircumscribedPolygon(Circle circle, int sideCount) { using (var output_points = new SimpleArrayPoint3d()) { IntPtr output_points_ptr = output_points.NonConstPointer(); bool rc = UnsafeNativeMethods.ON_Polyline_CreateCircumscribedPolygon(ref circle, sideCount, output_points_ptr); return(rc ? Polyline.PolyLineFromNativeArray(output_points) : null); } }
public Polyline ToPolyline() { // http://mcneel.myjetbrains.com/youtrack/issue/RH-30969 IntPtr const_ptr_this = ConstPointer(); using (var output_points = new SimpleArrayPoint3d()) { IntPtr output_points_ptr = output_points.NonConstPointer(); UnsafeNativeMethods.ON_PolylineCurve_CopyValues(const_ptr_this, output_points_ptr); return(Polyline.PolyLineFromNativeArray(output_points)); } }
/// <summary> /// Perform the 'get' operation. /// </summary> /// <param name="polyline"></param> /// <returns></returns> /// <since>6.0</since> public Commands.Result Get(out Geometry.Polyline polyline) { IntPtr ptr_this = NonConstPointer(); polyline = null; using (var points = new SimpleArrayPoint3d()) { IntPtr ptr_points = points.NonConstPointer(); var rc = (Commands.Result)UnsafeNativeMethods.RHC_RhinoGetPolyline2(ptr_this, ptr_points, IntPtr.Zero); if (rc == Commands.Result.Success) { polyline = new Geometry.Polyline(points.ToArray()); } return(rc); } }
/// <summary> /// Searches for locations where the distance from a RhinoObject, in one set of objects, /// is less than the specified distance to another RhinoObject in a second set of objects. /// This function uses the object's mesh to calculate the interferences. /// Acceptable object types include: BrepObject, ExtrusionObject, MeshObject, and SubDObject. /// </summary> /// <param name="setA">The first set of Rhino objects.</param> /// <param name="setB">The second set of Rhino objects.</param> /// <param name="distance">The largest distance at which a clash can occur.</param> /// <param name="meshType">The type of mesh to be used for the calculation.</param> /// <param name="meshingParameters">The meshing parameters used to generate meshes for the calculation.</param> /// <returns>An array of mesh interference object if successful, or an empty array on failure.</returns> public static MeshInterference[] Search(IEnumerable <RhinoObject> setA, IEnumerable <RhinoObject> setB, double distance, MeshType meshType, MeshingParameters meshingParameters) { using (var set_a_array = new Runtime.InternalRhinoObjectArray(setA)) using (var set_b_array = new Runtime.InternalRhinoObjectArray(setB)) { var ptr_set_a = set_a_array.NonConstPointer(); var ptr_set_b = set_b_array.NonConstPointer(); var ptr_mp = meshingParameters.ConstPointer(); var ptr_clash_events = UnsafeNativeMethods.RhObjectClashEventArray_New(); // new var count = UnsafeNativeMethods.RHC_CRhClashDetect_TestClash(ptr_set_a, ptr_set_b, distance, (int)meshType, ptr_mp, ptr_clash_events); var rc = new MeshInterference[count]; for (var i = 0; i < count; i++) { var index_a = -1; var index_b = -1; var hit_points = new SimpleArrayPoint3d(); // new var ptr_hit_points = hit_points.NonConstPointer(); var mi = new MeshInterference(); if (UnsafeNativeMethods.RhObjectClashEventArray_GetAt(ptr_clash_events, i, ref index_a, ref index_b, ptr_hit_points)) { mi.IndexA = index_a; mi.IndexB = index_b; mi.HitPoints = hit_points.Count > 0 ? hit_points.ToArray() : new Point3d[0]; } else { mi.IndexA = -1; mi.IndexB = -1; mi.HitPoints = new Point3d[0]; } hit_points.Dispose(); // delete rc[i] = mi; } UnsafeNativeMethods.RhObjectClashEventArray_Delete(ptr_clash_events); // delete GC.KeepAlive(setA); GC.KeepAlive(setB); return(rc); } }