//public static EllipseArc ToNative(this SpeckleCurve arc) //{ // //TODO: Implement EllipseArc converter // throw new NotImplementedException("EllipsArc not implemented yet."); //} /// <summary> /// DS Polycurve to SpecklePolyline if all curves are linear /// SpecklePolycurve otherwise /// </summary> /// <param name="polycurve"></param> /// <returns name="speckleObject"></returns> public static SpeckleObject ToSpeckle(this PolyCurve polycurve) { if (polycurve.IsPolyline()) { var points = polycurve.Curves().SelectMany(c => c.StartPoint.ToArray()).ToList(); points.AddRange(polycurve.Curves().Last().EndPoint.ToArray()); return(new SpecklePolyline(points)); } else { SpecklePolycurve spkPolycurve = new SpecklePolycurve(); spkPolycurve.Segments = polycurve.Curves().Select(c => c.ToSpeckle()).ToList(); spkPolycurve.GenerateHash(); return(spkPolycurve); } }
// Polycurve // Rh Capture/Gh Capture public static SpecklePolycurve ToSpeckle(this PolyCurve p) { SpecklePolycurve myPoly = new SpecklePolycurve(); myPoly.Closed = p.IsClosed; myPoly.Domain = p.Domain.ToSpeckle(); var segments = new List <Curve>(); CurveSegments(segments, p, true); myPoly.Segments = segments.Select(s => { return(SpeckleCore.Converter.Serialise(s) as SpeckleObject); }).ToList(); myPoly.Properties = p.UserDictionary.ToSpeckle(root: p); myPoly.GenerateHash(); return(myPoly); }