/// <summary> /// DS Line to SpeckleLine /// </summary> /// <param name="line"></param> /// <returns></returns> public Line LineToSpeckle(DS.Line line) { var l = new Line( PointListToFlatArray(new DS.Point[] { line.StartPoint, line.EndPoint }), ModelUnits); CopyProperties(l, line); return(l); }
/// <summary> /// DS Line to SpeckleLine /// </summary> /// <param name="line"></param> /// <returns></returns> public Line LineToSpeckle(DS.Line line, string units = null) { var u = units ?? ModelUnits; var l = new Line( PointListToFlatArray(new DS.Point[] { line.StartPoint, line.EndPoint }), u); CopyProperties(l, line); l.length = line.Length; l.bbox = BoxToSpeckle(line.BoundingBox.ToCuboid(), u); return(l); }
public Base CurveToSpeckle(DS.Curve curve, string units = null) { var u = units ?? ModelUnits; Base speckleCurve; if (curve.IsLinear()) { using (DS.Line line = curve.GetAsLine()) { speckleCurve = LineToSpeckle(line, u); } } else if (curve.IsArc()) { using (DS.Arc arc = curve.GetAsArc()) { speckleCurve = ArcToSpeckle(arc, u); } } else if (curve.IsCircle()) { using (DS.Circle circle = curve.GetAsCircle()) { speckleCurve = CircleToSpeckle(circle, u); } } else if (curve.IsEllipse()) { using (DS.Ellipse ellipse = curve.GetAsEllipse()) { speckleCurve = EllipseToSpeckle(ellipse, u); } } else { speckleCurve = CurveToSpeckle(curve.ToNurbsCurve(), u); } CopyProperties(speckleCurve, curve); return(speckleCurve); }
public Base CurveToSpeckle(DS.Curve curve) { Base speckleCurve; if (curve.IsLinear()) { using (DS.Line line = curve.GetAsLine()) { speckleCurve = LineToSpeckle(line); } } else if (curve.IsArc()) { using (DS.Arc arc = curve.GetAsArc()) { speckleCurve = ArcToSpeckle(arc); } } else if (curve.IsCircle()) { using (DS.Circle circle = curve.GetAsCircle()) { speckleCurve = CircleToSpeckle(circle); } } else if (curve.IsEllipse()) { using (DS.Ellipse ellipse = curve.GetAsEllipse()) { speckleCurve = EllipseToSpeckle(ellipse); } } else { speckleCurve = CurveToSpeckle(curve.ToNurbsCurve()); } CopyProperties(speckleCurve, curve); return(speckleCurve); }
public Base CurveToSpeckle(NurbsCurve curve, string units = null) { var u = units ?? ModelUnits; Base speckleCurve; if (curve.IsLinear()) { using (DS.Line line = curve.GetAsLine()) { speckleCurve = LineToSpeckle(line, u); } } else if (curve.IsArc()) { using (DS.Arc arc = curve.GetAsArc()) { speckleCurve = ArcToSpeckle(arc, u); } } else if (curve.IsCircle()) { using (DS.Circle circle = curve.GetAsCircle()) { speckleCurve = CircleToSpeckle(circle, u); } } else if (curve.IsEllipse()) { using (DS.Ellipse ellipse = curve.GetAsEllipse()) { speckleCurve = EllipseToSpeckle(ellipse, u); } } else { // SpeckleCurve DisplayValue DS.Curve[] curves = curve.ApproximateWithArcAndLineSegments(); List <double> polylineCoordinates = curves.SelectMany(c => PointListToFlatArray(new DS.Point[2] { c.StartPoint, c.EndPoint })).ToList(); polylineCoordinates.AddRange(PointToArray(curves.Last().EndPoint)); curves.ForEach(c => c.Dispose()); Polyline displayValue = new Polyline(polylineCoordinates, u); List <double> dsKnots = curve.Knots().ToList(); dsKnots.RemoveAt(dsKnots.Count - 1); dsKnots.RemoveAt(0); Curve spkCurve = new Curve(displayValue, u); spkCurve.weights = curve.Weights().ToList(); spkCurve.points = PointListToFlatArray(curve.ControlPoints()).ToList(); spkCurve.knots = dsKnots; spkCurve.degree = curve.Degree; spkCurve.periodic = curve.IsPeriodic; spkCurve.rational = curve.IsRational; spkCurve.closed = curve.IsClosed; spkCurve.domain = new Interval(curve.StartParameter(), curve.EndParameter()); //spkCurve.Properties //spkCurve.GenerateHash(); spkCurve.length = curve.Length; spkCurve.bbox = BoxToSpeckle(curve.BoundingBox.ToCuboid(), u); speckleCurve = spkCurve; } CopyProperties(speckleCurve, curve); return(speckleCurve); }