public Brep[] PerformSweep(Curve rail, IEnumerable<Curve> crossSections, IEnumerable<double> crossSectionParameters) { List<Curve> sections = new List<Curve>(crossSections); List<double> parameters = new List<double>(crossSectionParameters); if (sections.Count > 1 && sections.Count == parameters.Count) { Curve[] crvs = sections.ToArray(); double[] par = parameters.ToArray(); Array.Sort(par, crvs); crossSections = crvs; crossSectionParameters = par; } ArgsSweep1 sweep = ArgsSweep1.Construct(rail, crossSections, crossSectionParameters, m_roadlike_up, m_bClosed, m_sweep_tol, m_angle_tol, m_miter_type); Runtime.INTERNAL_BrepArray breps = new Rhino.Runtime.INTERNAL_BrepArray(); IntPtr pArgsSweep1 = sweep.NonConstPointer(); IntPtr pBreps = breps.NonConstPointer(); UnsafeNativeMethods.RHC_Sweep1(pArgsSweep1, pBreps); Brep[] rc = breps.ToNonConstArray(); sweep.Dispose(); breps.Dispose(); return rc; }
public Brep[] PerformSweepRebuild(Curve rail, IEnumerable<Curve> crossSections, IEnumerable<double> crossSectionParameters, int rebuildCount) { ArgsSweep1 sweep = ArgsSweep1.Construct(rail, crossSections, crossSectionParameters, m_roadlike_up, m_bClosed, m_sweep_tol, m_angle_tol, m_miter_type); Runtime.INTERNAL_BrepArray breps = new Rhino.Runtime.INTERNAL_BrepArray(); IntPtr pArgsSweep1 = sweep.NonConstPointer(); IntPtr pBreps = breps.NonConstPointer(); UnsafeNativeMethods.RHC_Sweep1Rebuild(pArgsSweep1, pBreps, rebuildCount); Brep[] rc = breps.ToNonConstArray(); sweep.Dispose(); breps.Dispose(); return rc; }
/// <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> public static Point3d[] ProjectPointsToBreps(IEnumerable<Brep> breps, IEnumerable<Point3d> points, Vector3d direction, double tolerance) { Point3d[] rc = null; if (breps != null && points != null) { Rhino.Runtime.INTERNAL_BrepArray brep_array = new Rhino.Runtime.INTERNAL_BrepArray(); foreach (Brep brep in breps) brep_array.AddBrep(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; }