//David: I just copied this function from Point3dList... internal static Polyline PolyLineFromNativeArray(Runtime.InteropWrappers.SimpleArrayPoint3d pts) { if (null == pts) { return(null); } int count = pts.Count; Polyline list = new Polyline(count); if (count > 0) { IntPtr pNativeArray = pts.ConstPointer(); UnsafeNativeMethods.ON_3dPointArray_CopyValues(pNativeArray, list.m_items); list.m_size = count; } return(list); }
/// <summary> /// Intersects two Surfaces. /// </summary> /// <param name="surfaceA">First Surface for intersection.</param> /// <param name="surfaceB">Second Surface for intersection.</param> /// <param name="tolerance">Intersection tolerance.</param> /// <param name="intersectionCurves">The intersection curves will be returned here.</param> /// <param name="intersectionPoints">The intersection points will be returned here.</param> /// <returns>true on success, false on failure.</returns> public static bool SurfaceSurface(Surface surfaceA, Surface surfaceB, double tolerance, out Curve[] intersectionCurves, out Point3d[] intersectionPoints) { intersectionCurves = new Curve[0]; intersectionPoints = new Point3d[0]; Runtime.InteropWrappers.SimpleArrayPoint3d outputPoints = new Runtime.InteropWrappers.SimpleArrayPoint3d(); IntPtr outputPointsPtr = outputPoints.NonConstPointer(); Runtime.InteropWrappers.SimpleArrayCurvePointer outputCurves = new Runtime.InteropWrappers.SimpleArrayCurvePointer(); IntPtr outputCurvesPtr = outputCurves.NonConstPointer(); IntPtr srfPtrA = surfaceA.ConstPointer(); IntPtr srfPtrB = surfaceB.ConstPointer(); bool rc = UnsafeNativeMethods.RHC_RhinoIntersectSurfaces( srfPtrA, srfPtrB, tolerance, outputCurvesPtr, outputPointsPtr); if (rc) { intersectionCurves = outputCurves.ToNonConstArray(); intersectionPoints = outputPoints.ToArray(); } outputPoints.Dispose(); outputCurves.Dispose(); return rc; }
/// <summary> /// Intersects a Brep and a Surface. /// </summary> /// <param name="brep">A brep to be intersected.</param> /// <param name="surface">A surface to be intersected.</param> /// <param name="tolerance">A tolerance value.</param> /// <param name="intersectionCurves">The intersection curves array argument. This out reference is assigned during the call.</param> /// <param name="intersectionPoints">The intersection points array argument. This out reference is assigned during the call.</param> /// <returns>true on success; false on failure.</returns> public static bool BrepSurface(Brep brep, Surface surface, double tolerance, out Curve[] intersectionCurves, out Point3d[] intersectionPoints) { intersectionCurves = new Curve[0]; intersectionPoints = new Point3d[0]; Runtime.InteropWrappers.SimpleArrayPoint3d outputPoints = new Runtime.InteropWrappers.SimpleArrayPoint3d(); IntPtr outputPointsPtr = outputPoints.NonConstPointer(); Runtime.InteropWrappers.SimpleArrayCurvePointer outputCurves = new Runtime.InteropWrappers.SimpleArrayCurvePointer(); IntPtr outputCurvesPtr = outputCurves.NonConstPointer(); IntPtr brepPtr = brep.ConstPointer(); IntPtr surfacePtr = surface.ConstPointer(); bool rc = UnsafeNativeMethods.ON_Intersect_BrepSurface(brepPtr, surfacePtr, tolerance, outputCurvesPtr, outputPointsPtr); if (rc) { intersectionCurves = outputCurves.ToNonConstArray(); intersectionPoints = outputPoints.ToArray(); } outputPoints.Dispose(); outputCurves.Dispose(); return rc; }
/// <summary> /// Intersects a curve with a Brep face. /// </summary> /// <param name="curve">A curve.</param> /// <param name="face">A brep face.</param> /// <param name="tolerance">Fitting and near miss tolerance.</param> /// <param name="overlapCurves">A overlap curves array argument. This out reference is assigned during the call.</param> /// <param name="intersectionPoints">A points array argument. This out reference is assigned during the call.</param> /// <returns>true on success, false on failure.</returns> public static bool CurveBrepFace(Curve curve, BrepFace face, double tolerance, out Curve[] overlapCurves, out Point3d[] intersectionPoints) { overlapCurves = new Curve[0]; intersectionPoints = new Point3d[0]; Runtime.InteropWrappers.SimpleArrayPoint3d outputPoints = new Runtime.InteropWrappers.SimpleArrayPoint3d(); IntPtr outputPointsPtr = outputPoints.NonConstPointer(); Runtime.InteropWrappers.SimpleArrayCurvePointer outputCurves = new Runtime.InteropWrappers.SimpleArrayCurvePointer(); IntPtr outputCurvesPtr = outputCurves.NonConstPointer(); IntPtr curvePtr = curve.ConstPointer(); IntPtr facePtr = face.ConstPointer(); bool rc = UnsafeNativeMethods.RHC_RhinoCurveFaceIntersect(curvePtr, facePtr, tolerance, outputCurvesPtr, outputPointsPtr); if (rc) { overlapCurves = outputCurves.ToNonConstArray(); intersectionPoints = outputPoints.ToArray(); } outputPoints.Dispose(); outputCurves.Dispose(); return rc; }