/// <summary> /// Constructs a new surface of revolution from a generatrix curve and an axis. /// <para>This overload accepts a slice start and end angles.</para> /// </summary> /// <param name="revoluteCurve">A generatrix.</param> /// <param name="axisOfRevolution">An axis.</param> /// <param name="startAngleRadians">An angle in radias for the start.</param> /// <param name="endAngleRadians">An angle in radias for the end.</param> /// <returns>A new surface of revolution, or null if any of the inputs is invalid or on error.</returns> public static RevSurface Create(Curve revoluteCurve, Line axisOfRevolution, double startAngleRadians, double endAngleRadians) { IntPtr pConstCurve = revoluteCurve.ConstPointer(); IntPtr pRevSurface = UnsafeNativeMethods.ON_RevSurface_Create(pConstCurve, ref axisOfRevolution, startAngleRadians, endAngleRadians); if (IntPtr.Zero == pRevSurface) return null; return new RevSurface(pRevSurface, null); }
/// <summary> /// Constructs a new sum surface by extruding a curve A along a path B. /// </summary> /// <param name="curveA">The curve used as extrusion profile.</param> /// <param name="curveB">The curve used as path.</param> /// <returns>A new sum surface on success; null on failure.</returns> public static SumSurface Create(Curve curveA, Curve curveB) { IntPtr pConstCurveA = curveA.ConstPointer(); IntPtr pConstCurveB = curveB.ConstPointer(); IntPtr pSumSurface = UnsafeNativeMethods.ON_SumSurface_Create(pConstCurveA, pConstCurveB); if (IntPtr.Zero == pSumSurface) return null; return new SumSurface(pSumSurface, null); }
/// <summary> /// Try to fit a circle to two curves using tangent relationships. /// </summary> /// <param name="c1">First curve to touch.</param> /// <param name="c2">Second curve to touch.</param> /// <param name="t1">Parameter on first curve close to desired solution.</param> /// <param name="t2">Parameter on second curve closet to desired solution.</param> /// <returns>Valid circle on success, Circle.Unset on failure.</returns> public static Circle TryFitCircleTT(Curve c1, Curve c2, double t1, double t2) { if (c1 == null) { throw new ArgumentNullException("c1"); } if (c2 == null) { throw new ArgumentNullException("c2"); } if (!RhinoMath.IsValidDouble(t1)) { throw new ArgumentNullException("t1"); } if (!RhinoMath.IsValidDouble(t2)) { throw new ArgumentNullException("t2"); } Circle rc = Circle.Unset; if (!UnsafeNativeMethods.ON_Circle_TryFitTT(c1.ConstPointer(), c2.ConstPointer(), t1, t2, ref rc)) rc = Circle.Unset; return rc; }
/// <summary> /// Constructs an array of cubic, non-rational beziers that fit a curve to a tolerance. /// </summary> /// <param name="sourceCurve">A curve to approximate.</param> /// <param name="distanceTolerance"> /// The max fitting error. Use RhinoMath.SqrtEpsilon as a minimum. /// </param> /// <param name="kinkTolerance"> /// If the input curve has a g1-discontinuity with angle radian measure /// greater than kinkTolerance at some point P, the list of beziers will /// also have a kink at P. /// </param> /// <returns>A new array of bezier curves. The array can be empty and might contain null items.</returns> public static BezierCurve[] CreateCubicBeziers(Curve sourceCurve, double distanceTolerance, double kinkTolerance) { IntPtr pConstCurve = sourceCurve.ConstPointer(); IntPtr pBezArray = UnsafeNativeMethods.ON_SimpleArray_BezierCurveNew(); int count = UnsafeNativeMethods.RHC_RhinoMakeCubicBeziers(pConstCurve, pBezArray, distanceTolerance, kinkTolerance); BezierCurve[] rc = new BezierCurve[count]; for (int i = 0; i < count; i++) { IntPtr ptr = UnsafeNativeMethods.ON_SimpleArray_BezierCurvePtr(pBezArray, i); if (ptr != IntPtr.Zero) rc[i] = new BezierCurve(ptr); } UnsafeNativeMethods.ON_SimpleArray_BezierCurveDelete(pBezArray); return rc; }
IntPtr m_ptr; //CArgsRhinoSweep2* public static ArgsSweep2 Construct(Curve rail1, Curve rail2, IEnumerable<Curve> crossSections, IEnumerable<double> crossSectionParameters1, IEnumerable<double> crossSectionParameters2, bool closed, double sweep_tol, double angle_tol, bool maintain_height) { ArgsSweep2 rc = new ArgsSweep2(); List<Curve> xsec = new List<Curve>(crossSections); List<double> xsec_t1 = new List<double>(crossSectionParameters1); List<double> xsec_t2 = new List<double>(crossSectionParameters2); if (xsec.Count < 1) throw new ArgumentException("must have at least one cross section"); if (xsec.Count != xsec_t1.Count || xsec.Count != xsec_t2.Count) throw new ArgumentException("must have same number of elements in crossSections and crossSectionParameters"); IntPtr pConstRail1 = rail1.ConstPointer(); IntPtr pConstRail2 = rail2.ConstPointer(); using (var sections = new Rhino.Runtime.InteropWrappers.SimpleArrayCurvePointer(crossSections)) { IntPtr pSections = sections.ConstPointer(); double[] tvals1 = xsec_t1.ToArray(); double[] tvals2 = xsec_t2.ToArray(); rc.m_ptr = UnsafeNativeMethods.CArgsRhinoSweep2_New(pConstRail1, pConstRail2, pSections, tvals1, tvals2, closed, sweep_tol, angle_tol, maintain_height); } return rc; }
/// <summary> /// Constructs a surface by extruding a curve to a point. /// </summary> /// <param name="profile">Profile curve to extrude.</param> /// <param name="apexPoint">Apex point of extrusion.</param> /// <returns>A Surface on success or null on failure.</returns> public static Surface CreateExtrusionToPoint(Curve profile, Point3d apexPoint) { IntPtr pConstCurve = profile.ConstPointer(); IntPtr pSurface = UnsafeNativeMethods.RHC_RhinoExtrudeCurveToPoint(pConstCurve, apexPoint); if (IntPtr.Zero == pSurface) return null; // CreateGeometryHelper will create the "actual" surface type (Nurbs, Sum, Rev,...) GeometryBase g = GeometryBase.CreateGeometryHelper(pSurface, null); Surface rc = g as Surface; return rc; }
/// <summary> /// Projects a Curve onto a Brep along a given direction. /// </summary> /// <param name="curve">Curve to project.</param> /// <param name="brep">Brep to project onto.</param> /// <param name="direction">Direction of projection.</param> /// <param name="tolerance">Tolerance to use for projection.</param> /// <returns>An array of projected curves or empty array if the projection set is empty.</returns> public static Curve[] ProjectToBrep(Curve curve, Brep brep, Vector3d direction, double tolerance) { IntPtr brep_ptr = brep.ConstPointer(); IntPtr curve_ptr = curve.ConstPointer(); using (SimpleArrayCurvePointer rc = new SimpleArrayCurvePointer()) { IntPtr rc_ptr = rc.NonConstPointer(); return UnsafeNativeMethods.RHC_RhinoProjectCurveToBrep(brep_ptr, curve_ptr, direction, tolerance, rc_ptr) ? rc.ToNonConstArray() : new Curve[0]; } }
/// <summary> /// Finds points at which to cut a pair of curves so that a fillet of given radius can be inserted. /// </summary> /// <param name="curve0">First curve to fillet.</param> /// <param name="curve1">Second curve to fillet.</param> /// <param name="radius">Fillet radius.</param> /// <param name="t0Base">Parameter value for base point on curve0.</param> /// <param name="t1Base">Parameter value for base point on curve1.</param> /// <param name="t0">Parameter value of fillet point on curve 0.</param> /// <param name="t1">Parameter value of fillet point on curve 1.</param> /// <param name="filletPlane"> /// The fillet is contained in this plane with the fillet center at the plane origin. /// </param> /// <returns>true on success, false on failure.</returns> /// <remarks> /// A fillet point is a pair of curve parameters (t0,t1) such that there is a circle /// of radius point3 tangent to curve c0 at t0 and tangent to curve c1 at t1. Of all possible /// fillet points this function returns the one which is the closest to the base point /// t0Base, t1Base. Distance from the base point is measured by the sum of arc lengths /// along the two curves. /// </remarks> public static bool GetFilletPoints(Curve curve0, Curve curve1, double radius, double t0Base, double t1Base, out double t0, out double t1, out Plane filletPlane) { t0 = 0; t1 = 0; filletPlane = new Plane(); if (null == curve0 || null == curve1) return false; IntPtr pCurve0 = curve0.ConstPointer(); IntPtr pCurve1 = curve1.ConstPointer(); bool rc = UnsafeNativeMethods.RHC_GetFilletPoints(pCurve0, pCurve1, radius, t0Base, t1Base, ref t0, ref t1, ref filletPlane); return rc; }
/// <summary> /// Makes a curve blend between 2 curves at the parameters specified /// with the directions and continuities specified /// </summary> /// <param name="curve0">First curve to blend from</param> /// <param name="t0">Parameter on first curve for blend endpoint</param> /// <param name="reverse0"> /// If false, the blend will go in the natural direction of the curve. /// If true, the blend will go in the opposite direction to the curve /// </param> /// <param name="continuity0">continuity for the blend at the start</param> /// <param name="curve1">Second curve to blend from</param> /// <param name="t1">Parameter on second curve for blend endpoint</param> /// <param name="reverse1"> /// If false, the blend will go in the natural direction of the curve. /// If true, the blend will go in the opposite direction to the curve /// </param> /// <param name="continuity1">continuity for the blend at the end</param> /// <returns>the blend curve on success. null on failure</returns> public static Curve CreateBlendCurve(Curve curve0, double t0, bool reverse0, BlendContinuity continuity0, Curve curve1, double t1, bool reverse1, BlendContinuity continuity1) { IntPtr pConstCurve0 = curve0.ConstPointer(); IntPtr pConstCurve1 = curve1.ConstPointer(); IntPtr pCurve = UnsafeNativeMethods.CRhinoBlend_CurveBlend(pConstCurve0, t0, reverse0, (int)continuity0, pConstCurve1, t1, reverse1, (int)continuity1); return GeometryBase.CreateGeometryHelper(pCurve, null) as Curve; }
/// <summary> /// Constructs a mean, or average, curve from two curves. /// </summary> /// <param name="curveA">A first curve.</param> /// <param name="curveB">A second curve.</param> /// <param name="angleToleranceRadians"> /// The angle tolerance, in radians, used to match kinks between curves. /// If you are unsure how to set this parameter, then either use the /// document's angle tolerance RhinoDoc.AngleToleranceRadians, /// or the default value (RhinoMath.UnsetValue) /// </param> /// <returns>The average curve, or null on error.</returns> /// <exception cref="ArgumentNullException">If curveA or curveB are null.</exception> public static Curve CreateMeanCurve(Curve curveA, Curve curveB, double angleToleranceRadians) { if (curveA == null) throw new ArgumentNullException("curveA"); if (curveB == null) throw new ArgumentNullException("curveB"); IntPtr pCurveA = curveA.ConstPointer(); IntPtr pCurveB = curveB.ConstPointer(); IntPtr pNewCurve = UnsafeNativeMethods.RHC_RhinoMeanCurve(pCurveA, pCurveB, angleToleranceRadians); return GeometryBase.CreateGeometryHelper(pNewCurve, null) as Curve; }
/// <summary> /// Determines whether two coplanar simple closed curves are disjoint or intersect; /// otherwise, if the regions have a containment relationship, discovers /// which curve encloses the other. /// </summary> /// <param name="curveA">A first curve.</param> /// <param name="curveB">A second curve.</param> /// <param name="testPlane">A plane.</param> /// <param name="tolerance">A tolerance value.</param> /// <returns> /// A value indicating the relationship between the first and the second curve. /// </returns> public static RegionContainment PlanarClosedCurveRelationship(Curve curveA, Curve curveB, Plane testPlane, double tolerance) { IntPtr pConstCurveA = curveA.ConstPointer(); IntPtr pConstCurveB = curveB.ConstPointer(); return (RegionContainment)UnsafeNativeMethods.RHC_RhinoPlanarClosedCurveContainmentTest(pConstCurveA, pConstCurveB, ref testPlane, tolerance); }
protected CustomCurveObject(Curve curve) : base() { Guid type_id = GetType().GUID; IntPtr pConstCurve = curve.ConstPointer(); m_pRhinoObject = UnsafeNativeMethods.CRhinoCustomObject_New2(type_id, pConstCurve); }
/// <summary> /// Creates a tangent arc between two curves and trims or extends the curves to the arc. /// </summary> /// <param name="curve0">The first curve to fillet.</param> /// <param name="point0"> /// A point on the first curve that is near the end where the fillet will /// be created. /// </param> /// <param name="curve1">The second curve to fillet.</param> /// <param name="point1"> /// A point on the second curve that is near the end where the fillet will /// be created. /// </param> /// <param name="radius">The radius of the fillet.</param> /// <param name="join">Join the output curves.</param> /// <param name="trim"> /// Trim copies of the input curves to the output fillet curve. /// </param> /// <param name="arcExtension"> /// Applies when arcs are filleted but need to be extended to meet the /// fillet curve or chamfer line. If true, then the arc is extended /// maintaining its validity. If false, then the arc is extended with a /// line segment, which is joined to the arc converting it to a polycurve. /// </param> /// <param name="tolerance"> /// The tolerance, generally the document's absolute tolerance. /// </param> /// <param name="angleTolerance"></param> /// <returns> /// The results of the fillet operation. The number of output curves depends /// on the input curves and the values of the parameters that were used /// during the fillet operation. In most cases, the output array will contain /// either one or three curves, although two curves can be returned if the /// radius is zero and join = false. /// For example, if both join and trim = true, then the output curve /// will be a polycurve containing the fillet curve joined with trimmed copies /// of the input curves. If join = false and trim = true, then three curves, /// the fillet curve and trimmed copies of the input curves, will be returned. /// If both join and trim = false, then just the fillet curve is returned. /// </returns> /// <example> /// <code source='examples\vbnet\ex_filletcurves.vb' lang='vbnet'/> /// <code source='examples\cs\ex_filletcurves.cs' lang='cs'/> /// <code source='examples\py\ex_filletcurves.py' lang='py'/> /// </example> public static Curve[] CreateFilletCurves( Curve curve0, Point3d point0, Curve curve1, Point3d point1, double radius, bool join, bool trim, bool arcExtension, double tolerance, double angleTolerance) { IntPtr const_ptr_curve0 = curve0.ConstPointer(); IntPtr const_ptr_curve1 = curve1.ConstPointer(); using (var output_array = new SimpleArrayCurvePointer()) { IntPtr ptr_output_array = output_array.NonConstPointer(); UnsafeNativeMethods.RHC_RhFilletCurve(const_ptr_curve0, point0, const_ptr_curve1, point1, radius, join, trim, arcExtension, tolerance, angleTolerance, ptr_output_array); return output_array.ToNonConstArray(); } }
IntPtr m_ptr; //CArgsRhinoSweep1* public static ArgsSweep1 Construct(Curve rail, IEnumerable<Curve> crossSections, IEnumerable<double> crossSectionParameters, Vector3d roadlike_up, bool closed, double sweep_tol, double angle_tol, int miter_type) { ArgsSweep1 rc = new ArgsSweep1(); List<Curve> xsec = new List<Curve>(crossSections); List<double> xsec_t = new List<double>(crossSectionParameters); if (xsec.Count < 1) throw new ArgumentException("must have at least one cross section"); if (xsec.Count != xsec_t.Count) throw new ArgumentException("must have same number of elements in crossSections and crossSectionParameters"); IntPtr pConstRail = rail.ConstPointer(); Runtime.InteropWrappers.SimpleArrayCurvePointer sections = new Rhino.Runtime.InteropWrappers.SimpleArrayCurvePointer(crossSections); IntPtr pSections = sections.ConstPointer(); double[] tvals = xsec_t.ToArray(); rc.m_ptr = UnsafeNativeMethods.CArgsRhinoSweep1_New(pConstRail, pSections, tvals, roadlike_up, closed, sweep_tol, angle_tol, miter_type); sections.Dispose(); return rc; }
/// <summary> /// Pull a curve to a BrepFace using closest point projection. /// </summary> /// <param name="curve">Curve to pull.</param> /// <param name="face">Brepface that pulls.</param> /// <param name="tolerance">Tolerance to use for pulling.</param> /// <returns>An array of pulled curves, or an empty array on failure.</returns> public static Curve[] PullToBrepFace(Curve curve, BrepFace face, double tolerance) { IntPtr brep_ptr = face.m_brep.ConstPointer(); IntPtr curve_ptr = curve.ConstPointer(); using (SimpleArrayCurvePointer rc = new SimpleArrayCurvePointer()) { IntPtr rc_ptr = rc.NonConstPointer(); if (UnsafeNativeMethods.RHC_RhinoPullCurveToBrep(brep_ptr, face.FaceIndex, curve_ptr, tolerance, rc_ptr)) { return rc.ToNonConstArray(); } return new Curve[0]; } }
/// <summary> /// Sets the outer profile of the extrusion. /// </summary> /// <param name="outerProfile">curve in the XY plane or a 2D curve.</param> /// <param name="cap"> /// If outerProfile is a closed curve, then cap determines if the extrusion /// has end caps. If outerProfile is an open curve, cap is ignored. /// </param> /// <returns> /// true if the profile was set. If the outer profile is closed, then the /// extrusion may also have inner profiles. If the outer profile is open, /// the extrusion may not have inner profiles. If the extrusion already /// has a profile, the set will fail. /// </returns> public bool SetOuterProfile(Curve outerProfile, bool cap) { IntPtr pThis = NonConstPointer(); IntPtr pConstCurve = outerProfile.ConstPointer(); return UnsafeNativeMethods.ON_Extrusion_SetOuterProfile(pThis, pConstCurve, cap); }
/// <summary> /// Computes the distance between two arbitrary curves. /// </summary> /// <param name="curveA">A curve.</param> /// <param name="curveB">Another curve.</param> /// <param name="tolerance">A tolerance value.</param> /// <param name="maxDistance">The maximum distance value. This is an out reference argument.</param> /// <param name="maxDistanceParameterA">The maximum distance parameter on curve A. This is an out reference argument.</param> /// <param name="maxDistanceParameterB">The maximum distance parameter on curve B. This is an out reference argument.</param> /// <param name="minDistance">The minimum distance value. This is an out reference argument.</param> /// <param name="minDistanceParameterA">The minimum distance parameter on curve A. This is an out reference argument.</param> /// <param name="minDistanceParameterB">The minimum distance parameter on curve B. This is an out reference argument.</param> /// <returns>true if the operation succeeded; otherwise false.</returns> public static bool GetDistancesBetweenCurves(Curve curveA, Curve curveB, double tolerance, out double maxDistance, out double maxDistanceParameterA, out double maxDistanceParameterB, out double minDistance, out double minDistanceParameterA, out double minDistanceParameterB) { IntPtr pConstCrvA = curveA.ConstPointer(); IntPtr pConstCrvB = curveB.ConstPointer(); maxDistance = 0; maxDistanceParameterA = 0; maxDistanceParameterB = 0; minDistance = 0; minDistanceParameterA = 0; minDistanceParameterB = 0; bool rc = UnsafeNativeMethods.RHC_RhinoGetOverlapDistance(pConstCrvA, pConstCrvB, tolerance, ref maxDistanceParameterA, ref maxDistanceParameterB, ref maxDistance, ref minDistanceParameterA, ref minDistanceParameterB, ref minDistance); return rc; }
/// <summary> /// Adds an inner profile. /// </summary> /// <param name="innerProfile">Closed curve in the XY plane or a 2d curve.</param> /// <returns>true if the profile was set.</returns> public bool AddInnerProfile(Curve innerProfile) { IntPtr pThis = NonConstPointer(); IntPtr pConstCurve = innerProfile.ConstPointer(); return UnsafeNativeMethods.ON_Extrusion_AddInnerProfile(pThis, pConstCurve); }
/// <summary> /// Determines if tro coplanar curves collide (intersect). /// </summary> /// <param name="curveA">A curve.</param> /// <param name="curveB">Another curve.</param> /// <param name="testPlane">A valid plane containing the curves.</param> /// <param name="tolerance">A tolerance value for intersection.</param> /// <returns>true if the curves intersect, otherwise false</returns> public static bool PlanarCurveCollision(Curve curveA, Curve curveB, Plane testPlane, double tolerance) { IntPtr pConstCurveA = curveA.ConstPointer(); IntPtr pConstCurveB = curveB.ConstPointer(); return UnsafeNativeMethods.RHC_RhinoPlanarCurveCollisionTest(pConstCurveA, pConstCurveB, ref testPlane, tolerance); }
protected CustomCurveObject(Curve curve) : base() { IntPtr pConstCurve = curve.ConstPointer(); m_pRhinoObject = UnsafeNativeMethods.CRhinoCustomObject_New2(pConstCurve); }
/// <summary> /// Create a Blend curve between two existing curves. /// </summary> /// <param name="curveA">Curve to blend from (blending will occur at curve end point).</param> /// <param name="curveB">Curve to blend to (blending will occur at curve start point).</param> /// <param name="continuity">Continuity of blend.</param> /// <param name="bulgeA">Bulge factor at curveA end of blend. Values near 1.0 work best.</param> /// <param name="bulgeB">Bulge factor at curveB end of blend. Values near 1.0 work best.</param> /// <returns>A curve representing the blend between A and B or null on failure.</returns> public static Curve CreateBlendCurve(Curve curveA, Curve curveB, BlendContinuity continuity, double bulgeA, double bulgeB) { if (curveA == null) throw new ArgumentNullException("curveA"); if (curveB == null) throw new ArgumentNullException("curveB"); IntPtr pCurveA = curveA.ConstPointer(); IntPtr pCurveB = curveB.ConstPointer(); switch (continuity) { case BlendContinuity.Position: return new LineCurve(curveA.PointAtEnd, curveB.PointAtStart); case BlendContinuity.Tangency: IntPtr pG1Curve = UnsafeNativeMethods.RHC_RhinoBlendG1Curve(pCurveA, pCurveB, bulgeA, bulgeB); return GeometryBase.CreateGeometryHelper(pG1Curve, null) as Curve; case BlendContinuity.Curvature: IntPtr pG2Curve = UnsafeNativeMethods.RHC_RhinoBlendG2Curve(pCurveA, pCurveB, bulgeA, bulgeB); return GeometryBase.CreateGeometryHelper(pG2Curve, null) as Curve; } return null; }
/// <summary> /// Computes an AreaMassProperties for a closed planar curve. /// </summary> /// <param name="closedPlanarCurve">Curve to measure.</param> /// <param name="planarTolerance">absolute tolerance used to insure the closed curve is planar</param> /// <returns>The AreaMassProperties for the given curve or null on failure.</returns> /// <exception cref="System.ArgumentNullException">When closedPlanarCurve is null.</exception> public static AreaMassProperties Compute(Curve closedPlanarCurve, double planarTolerance) { if (closedPlanarCurve == null) throw new ArgumentNullException("closedPlanarCurve"); const double relativeTolerance = 1.0e-6; const double absoluteTolerance = 1.0e-6; IntPtr ptr = closedPlanarCurve.ConstPointer(); IntPtr rc = UnsafeNativeMethods.ON_Curve_AreaMassProperties(ptr, relativeTolerance, absoluteTolerance, planarTolerance); return rc == IntPtr.Zero ? null : new AreaMassProperties(rc, false); }
/// <summary> /// Creates curves between two open or closed input curves. Use sample points method to make curves compatible. /// This is how the algorithm workd: Divides the two curves into an equal number of points, finds the midpoint between the /// corresponding points on the curves and interpolates the tween curve through those points. There is no matching of curves /// direction. Caller must match input curves direction before calling the function. /// </summary> /// <param name="curve0">The first, or starting, curve.</param> /// <param name="curve1">The second, or ending, curve.</param> /// <param name="numCurves">Number of tween curves to create.</param> /// <param name="numSamples">Number of sample points along input curves.</param> /// <returns>>An array of joint curves. This array can be empty.</returns> public static Curve[] CreateTweenCurvesWithSampling(Curve curve0, Curve curve1, int numCurves, int numSamples) { IntPtr pConstCurve0 = curve0.ConstPointer(); IntPtr pConstCurve1 = curve1.ConstPointer(); SimpleArrayCurvePointer output = new SimpleArrayCurvePointer(); IntPtr outputPtr = output.NonConstPointer(); bool rc = UnsafeNativeMethods.RHC_RhinoTweenCurveWithSampling(pConstCurve0, pConstCurve1, numCurves, numSamples, outputPtr); return rc ? output.ToNonConstArray() : new Curve[0]; }
public bool SetFromCurve(Curve curve) { IntPtr pThis = NonConstPointer(); IntPtr pConstCurve = curve.ConstPointer(); return UnsafeNativeMethods.CRhinoGumball_SetFromCurve(pThis, pConstCurve); }
/// <summary> /// Determines whether two curves travel more or less in the same direction. /// </summary> /// <param name="curveA">First curve to test.</param> /// <param name="curveB">Second curve to test.</param> /// <returns>true if both curves more or less point in the same direction, /// false if they point in the opposite directions.</returns> public static bool DoDirectionsMatch(Curve curveA, Curve curveB) { IntPtr ptr0 = curveA.ConstPointer(); IntPtr ptr1 = curveB.ConstPointer(); return UnsafeNativeMethods.ON_Curve_DoCurveDirectionsMatch(ptr0, ptr1); }
/// <summary> /// Appends and matches the start of the curve to the end of polycurve. /// This function will fail if the PolyCurve is closed or if SegmentCount > 0 and the new segment is closed. /// </summary> /// <param name="curve">Segment to append.</param> /// <returns>true on success, false on failure.</returns> public bool Append(Curve curve) { if (null == curve) return false; IntPtr ptr = NonConstPointer(); IntPtr pCurve = curve.ConstPointer(); bool rc = UnsafeNativeMethods.ON_PolyCurve_AppendAndMatch2(ptr, pCurve); return rc; }
/// <summary> /// Pulls a 3d curve back to the surface's parameter space. /// </summary> /// <param name="curve3d">A curve.</param> /// <param name="tolerance"> /// the maximum acceptable 3d distance between from surface(curve_2d(t)) /// to the locus of points on the surface that are closest to curve_3d. /// </param> /// <param name="curve3dSubdomain">A subdomain of the curve to sample.</param> /// <returns>2d curve.</returns> public Curve Pullback(Curve curve3d, double tolerance, Interval curve3dSubdomain) { if (null == curve3d) return null; IntPtr ptr = ConstPointer(); IntPtr pCurve3d = curve3d.ConstPointer(); IntPtr rc = UnsafeNativeMethods.ON_Surface_Pullback(ptr, pCurve3d, tolerance, curve3dSubdomain); return GeometryBase.CreateGeometryHelper(rc, null) as Curve; }
/// <summary> /// Constructs a curve by projecting an existing curve to a plane. /// </summary> /// <param name="curve">A curve.</param> /// <param name="plane">A plane.</param> /// <returns>The projected curve on success; null on failure.</returns> public static Curve ProjectToPlane(Curve curve, Plane plane) { IntPtr pConstCurve = curve.ConstPointer(); IntPtr pNewCurve = UnsafeNativeMethods.RHC_RhinoProjectCurveToPlane(pConstCurve, ref plane); return GeometryBase.CreateGeometryHelper(pNewCurve, null) as Curve; }
//[skipping] // virtual BOOL GetParameterTolerance( // returns tminus < tplus: parameters tminus <= s <= tplus /// <summary> /// Determines if a 2D curve is iso-parameteric in the parameter space of this surface. /// </summary> /// <param name="curve">Curve to test.</param> /// <param name="curveDomain">Sub domain of the curve.</param> /// <returns>IsoStatus flag describing the iso-parametric relationship between the surface and the curve.</returns> public IsoStatus IsIsoparametric(Curve curve, Interval curveDomain) { if (null == curve) return IsoStatus.None; IntPtr ptr = ConstPointer(); IntPtr pCurve = curve.ConstPointer(); int rc = UnsafeNativeMethods.ON_Surface_IsIsoparametric(ptr, pCurve, curveDomain); return (IsoStatus)rc; }
/// <summary> /// Creates an extrusion of a 3d curve (which must be planar) and a height. /// </summary> /// <param name="planarCurve"> /// Planar curve used as profile /// </param> /// <param name="height"> /// If the height > 0, the bottom of the extrusion will be in plane and /// the top will be height units above the plane. /// If the height < 0, the top of the extrusion will be in plane and /// the bottom will be height units below the plane. /// The plane used is the one that is returned from the curve's TryGetPlane function. /// </param> /// <param name="cap"> /// If the curve is closed and cap is true, then the resulting extrusion is capped. /// </param> /// <returns> /// If the input is valid, then a new extrusion is returned. Otherwise null is returned /// </returns> public static Extrusion Create(Curve planarCurve, double height, bool cap) { IntPtr pConstCurve = planarCurve.ConstPointer(); IntPtr pExtrusion = UnsafeNativeMethods.ON_Extrusion_CreateFrom3dCurve(pConstCurve, height, cap); return IntPtr.Zero == pExtrusion ? null : new Extrusion(pExtrusion, null); }