PolyCurve
using Autodesk.DesignScript.Geometry.Properties;
using Autodesk.DesignScript.Interfaces;
using Autodesk.DesignScript.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Autodesk.DesignScript.Geometry
{
    public class PolyCurve : Curve
    {
        internal IPolyCurveEntity PolyCurveEntity => HostImpl as IPolyCurveEntity;
        public Point[] Points => Point.Wrap(PolyCurveEntity.get_Points(), true);
        public int NumberOfCurves => PolyCurveEntity.get_NumberOfCurves();
        internal PolyCurve(IPolyCurveEntity host, bool persist)
            : base(host, persist)
        {
        }
        public override string ToString()
        {
            return "PolyCurve(NumberOfCurves = " + NumberOfCurves.ToString() + ")";
        }
        internal new static void InitType()
        {
            Geometry.RegisterHostType(typeof(IPolyCurveEntity), (IGeometryEntity host, bool persist) => new PolyCurve(host as IPolyCurveEntity, persist));
        }
        internal static PolyCurve Wrap(IPolyCurveEntity host, bool persist = true)
        {
            return Geometry.Wrap(host, false, null) as PolyCurve;
        }
        internal static PolyCurve[] Wrap(IPolyCurveEntity[] hosts, bool persist = true)
        {
            return (from x in hosts
            select Wrap(x, persist)).ToArray();
        }
        internal static PolyCurve[][] Wrap(IPolyCurveEntity[][] hosts, bool persist = true)
        {
            return (from x in hosts
            select Wrap(x, persist)).ToArray();
        }
        internal static IPolyCurveEntity[][] Unwrap(PolyCurve[][] o)
        {
            return (from x in o
            select Unwrap(x)).ToArray();
        }
        internal static IPolyCurveEntity[] Unwrap(PolyCurve[] o)
        {
            return (from x in o
            select Unwrap(x)).ToArray();
        }
        internal static IPolyCurveEntity[] Unwrap(IEnumerable<PolyCurve> o)
        {
            return (from x in o
            select Unwrap(x)).ToArray();
        }
        internal static IPolyCurveEntity Unwrap(PolyCurve o)
        {
            return o.PolyCurveEntity;
        }
        [IsVisibleInDynamoLibrary(false)]
        [IsObsolete("polycurve_byjoinedcurves_deprecated", typeof(Resources))]
        [Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use PolyCurve.ByJoinedCurves(Curve[] curves, double joinTolerance, bool trimCurves, double trimLength) instead")]
        public static PolyCurve ByJoinedCurves(IEnumerable<Curve> curves, [Scaling()] double joinTolerance = 0.001)
        {
            DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
                joinTolerance
            });
            joinTolerance /= DesignScriptEntity.scaleFactor;
            return Wrap(HostFactory.Factory.PolyCurveByJoinedCurves(Curve.Unwrap(curves), joinTolerance), true);
        }
        public static PolyCurve ByJoinedCurves(IEnumerable<Curve> curves, [Scaling()] double joinTolerance = 0.001, bool trimCurves = false, [Scaling()] double trimLength = 0)
        {
            DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
                joinTolerance,
                trimLength
            });
            joinTolerance /= DesignScriptEntity.scaleFactor;
            trimLength /= DesignScriptEntity.scaleFactor;
            return Wrap(HostFactory.Factory.PolyCurveByJoinedCurves(Curve.Unwrap(curves), joinTolerance, trimCurves, trimLength), true);
        }
        [IsVisibleInDynamoLibrary(false)]
        [IsObsolete("polycurve_bygroupedcurves_deprecated", typeof(Resources))]
        [Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use PolyCurve.ByGroupedCurves(Curve[] curves, double joinTolerance, bool trimCurves, double trimLength) instead")]
        [AllowRankReduction]
        public static PolyCurve[] ByGroupedCurves(IEnumerable<Curve> curves, [Scaling()] double joinTolerance = 0.001)
        {
            DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
                joinTolerance
            });
            joinTolerance /= DesignScriptEntity.scaleFactor;
            return Wrap(HostFactory.Factory.PolyCurveByGroupedCurves(Curve.Unwrap(curves), joinTolerance), true);
        }
        [AllowRankReduction]
        public static PolyCurve[] ByGroupedCurves(IEnumerable<Curve> curves, [Scaling()] double joinTolerance = 0.001, bool trimCurves = false, [Scaling()] double trimLength = 0)
        {
            DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
                joinTolerance,
                trimLength
            });
            joinTolerance /= DesignScriptEntity.scaleFactor;
            trimLength /= DesignScriptEntity.scaleFactor;
            return Wrap(HostFactory.Factory.PolyCurveByGroupedCurves(Curve.Unwrap(curves), joinTolerance, trimCurves, trimLength), true);
        }
        public static PolyCurve ByPoints(IEnumerable<Point> points, bool connectLastToFirst = false)
        {
            return Wrap(HostFactory.Factory.PolyCurveByPoints(Point.Unwrap(points), connectLastToFirst), true);
        }
        [IsVisibleInDynamoLibrary(false)]
        [IsObsolete("polycurve_bythickeningcurve_depreacted", typeof(Resources))]
        [Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use PolyCurve.ByThickeningCurveNormal(Curve curve, double thickness, Vector normal) instead")]
        public static PolyCurve ByThickeningCurve(Curve curve, [Scaling()] double thickness, Vector nor)
        {
            DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
                thickness
            });
            thickness /= DesignScriptEntity.scaleFactor;
            return Wrap(HostFactory.Factory.PolyCurveByThickeningCurve(Curve.Unwrap(curve), thickness, Vector.Unwrap(nor)), true);
        }
        public static PolyCurve ByThickeningCurveNormal(Curve curve, [Scaling()] double thickness, [DefaultArgument("null")] Vector normal)
        {
            DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
                thickness
            });
            thickness /= DesignScriptEntity.scaleFactor;
            return Wrap(HostFactory.Factory.PolyCurveByThickeningCurveNormal(Curve.Unwrap(curve), thickness, Vector.Unwrap(normal)), true);
        }
        public Curve[] Curves()
        {
            return Curve.Wrap(PolyCurveEntity.Curves(), true);
        }
        public Curve CurveAtIndex(int index = 0, bool endOrStart = false)
        {
            return Curve.Wrap(PolyCurveEntity.CurveAtIndex(index, endOrStart), true);
        }
        public Plane BasePlane()
        {
            return Plane.Wrap(PolyCurveEntity.BasePlane(), true);
        }
        public PolyCurve ExtendWithEllipse([Scaling()] double length, [Scaling()] double radius1, [Scaling()] double radius2, double endEllipseParameter, bool endOrStart)
        {
            DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
                length,
                radius1,
                radius2
            });
            length /= DesignScriptEntity.scaleFactor;
            radius1 /= DesignScriptEntity.scaleFactor;
            radius2 /= DesignScriptEntity.scaleFactor;
            return Wrap(PolyCurveEntity.ExtendWithEllipse(length, radius1, radius2, endEllipseParameter, endOrStart), true);
        }
        public PolyCurve ExtendWithArc([Scaling()] double length, [Scaling()] double radius, bool endOrStart)
        {
            DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
                length,
                radius
            });
            length /= DesignScriptEntity.scaleFactor;
            radius /= DesignScriptEntity.scaleFactor;
            return Wrap(PolyCurveEntity.ExtendWithArc(length, radius, endOrStart), true);
        }
        public PolyCurve CloseWithLine()
        {
            return Wrap(PolyCurveEntity.CloseWithLine(), true);
        }
        public PolyCurve CloseWithLineAndTangentArcs([Scaling()] double radiusAtStart = 1, [Scaling()] double radiusAtEnd = 1)
        {
            DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
                radiusAtStart,
                radiusAtEnd
            });
            radiusAtStart /= DesignScriptEntity.scaleFactor;
            radiusAtEnd /= DesignScriptEntity.scaleFactor;
            return Wrap(PolyCurveEntity.CloseWithLineAndTangentArcs(radiusAtStart, radiusAtEnd), true);
        }
        [IsVisibleInDynamoLibrary(false)]
        [IsObsolete("polycurve_offset_deprecated", typeof(Resources))]
        [Obsolete("This method is deprecated and will be removed in a future version of Dynamo. Use PolyCurve.OffsetMany instead.")]
        public Curve Offset([Scaling()] double signedDistance, bool extendCircular)
        {
            DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
                signedDistance
            });
            signedDistance /= DesignScriptEntity.scaleFactor;
            return Curve.Wrap(PolyCurveEntity.Offset(signedDistance, extendCircular), true);
        }
        [AllowRankReduction]
        public Curve[] OffsetMany([Scaling()] double signedDistance, bool extendCircular, [DefaultArgument("null")] Vector planeNormal)
        {
            DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
                signedDistance
            });
            signedDistance /= DesignScriptEntity.scaleFactor;
            return Curve.Wrap(PolyCurveEntity.OffsetMany(signedDistance, extendCircular, Vector.Unwrap(planeNormal)), true);
        }
        public PolyCurve Fillet([Scaling()] double radius = 1, bool clockwise_corners = true)
        {
            DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
                radius
            });
            radius /= DesignScriptEntity.scaleFactor;
            return Wrap(PolyCurveEntity.Fillet(radius, clockwise_corners), true);
        }
        public PolyCurve Heal([Scaling()] double trimLength = 0)
        {
            DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
                trimLength
            });
            trimLength /= DesignScriptEntity.scaleFactor;
            return Wrap(PolyCurveEntity.Heal(trimLength), true);
        }
    }
}
            