/// <summary> /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.FixedV (double, double, double)"/> /// </summary> /// <param name="v"></param> /// <param name="umin"></param> /// <param name="umax"></param> /// <returns></returns> public override ICurve FixedV(double v, double umin, double umax) { GeoPoint2D p2d = basisCurve2D.PointAt(GetPos(v)); Line2D l2d = new Line2D(new GeoPoint2D(umin, v), new GeoPoint2D(umax, v)); CurveOnSurface cos = CurveOnSurface.Construct(l2d, this); return(cos); // making an Ellipse as an exact NURBS Ellipse but with the pitch doesn't match the desired curve // because the NURBS doesn't run linear with the angle as parameter (also graphically tested) //int n = Math.Max(3, (int)Math.Round(Math.Abs((umax - umin)) / Math.PI * 2 * 18)); //double ustep = (umax - umin) / (n - 1); //GeoPoint[] pnts = new GeoPoint[n]; //for (int i = 0; i < n; i++) //{ // pnts[i] = PointAt(new GeoPoint2D(umin + i * ustep, v)); //} //BSpline res = BSpline.Construct(); //res.ThroughPoints(pnts, 3, false); //return res as ICurve; }
protected override void SolveInstance(IGH_DataAccess DA) { // --- Input var path = default(Path); var surface = default(Surface); var startingPoint = default(Vector3d); var stepSize = default(double); if (!DA.GetData(0, ref path)) { return; } if (!DA.GetData(1, ref surface)) { return; } if (!DA.GetData(2, ref startingPoint)) { return; } if (!DA.GetData(3, ref stepSize)) { return; } // --- Execute if (StartPointType == StartPointTypes.UV) { var u = surface.Domain(0).NormalizedParameterAt(startingPoint.X); var v = surface.Domain(1).NormalizedParameterAt(startingPoint.Y); startingPoint = new Vector3d(u, v, 0); } surface = (Surface)surface.Duplicate(); surface.SetDomain(0, new Interval(0, 1)); surface.SetDomain(1, new Interval(0, 1)); if (StartPointType == StartPointTypes.XYZ) { surface.ClosestPoint((Point3d)startingPoint, out double u, out double v); startingPoint = new Vector3d(u, v, 0); } var paths = new List <Polyline>(); var type = (path as NormalCurvaturePath)?.Type ?? (path as GeodesicTorsionPath)?.Type ?? (path as DGridPath)?.Type ?? (path as PSPath).Type; if (type.HasFlag(Path.Types.First)) { var pathfinder = Pathfinder.Create(path, surface, startingPoint, false, stepSize); var polyline = new Polyline(pathfinder.Points); paths.Add(polyline); } if (type.HasFlag(Path.Types.Second)) { var pathfinder = Pathfinder.Create(path, surface, startingPoint, true, stepSize); var polyline = new Polyline(pathfinder.Points); paths.Add(polyline); } // --- Output var curves = new List <CurveOnSurface>(); foreach (var p in paths) { var curve = new PolylineCurve(p.Select(o => { surface.ClosestPoint(o, out var u, out var v); return(new Point3d(u, v, 0)); })); curves.Add(CurveOnSurface.Create(surface, curve)); } DA.SetDataList(0, curves); }