Ejemplo n.º 1
0
        //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,
                           appId,
                           polycurve.GetSpeckleProperties()));
            }
            else
            {
                SpecklePolycurve spkPolycurve = new SpecklePolycurve();
                spkPolycurve.Properties = polycurve.GetSpeckleProperties();
                spkPolycurve.Segments   = polycurve.Curves().Select(c => c.ToSpeckle()).ToList();
                spkPolycurve.GenerateHash();
                return(spkPolycurve);
            }
        }