public static PathSmoothResult SmoothPath(List <Coordinates> path_pts, List <Coordinates> ub_pts, List <Coordinates> lb_pts, List <Coordinates> smoothed_path, SmoothingAlg alg)
        {
            smoother_options opt = DefaultOptions;

            opt.alg = (int)alg;

            return(SmoothPath(path_pts, ub_pts, lb_pts, smoothed_path, opt));
        }
        public static PathSmoothResult SmoothPath(List<Coordinates> path_pts, List<Coordinates> ub_pts, List<Coordinates> lb_pts, List<Coordinates> smoothed_path, smoother_options opt)
        {
            Stopwatch sw = Stopwatch.StartNew();
            double[] px = new double[path_pts.Count];
            double[] py = new double[path_pts.Count];

            double[] ub_x = new double[ub_pts.Count];
            double[] ub_y = new double[ub_pts.Count];

            double[] lb_x = new double[lb_pts.Count];
            double[] lb_y = new double[lb_pts.Count];

            for (int i = 0; i < path_pts.Count; i++) {
                px[i] = path_pts[i].X;
                py[i] = path_pts[i].Y;
            }

            for (int i = 0; i < ub_pts.Count; i++) {
                ub_x[i] = ub_pts[i].X;
                ub_y[i] = ub_pts[i].Y;
            }

            for (int i = 0; i < lb_pts.Count; i++) {
                lb_x[i] = lb_pts[i].X;
                lb_y[i] = lb_pts[i].Y;
            }

            // allocate space for the return points
            double[] smoothed_x = new double[300];
            double[] smoothed_y = new double[300];

            int len = 300;

            int ret = smooth_path(px, py, px.Length, ub_x, ub_y, ub_x.Length, lb_x, lb_y, lb_x.Length, opt, smoothed_x, smoothed_y, ref len);

            smoothed_path.Clear();
            smoothed_path.Capacity = len;
            for (int i = 0; i < len; i++) {
                smoothed_path.Add(new Coordinates(smoothed_x[i], smoothed_y[i]));
            }

            sw.Stop();

            Console.WriteLine("took " + sw.ElapsedMilliseconds + " ms");

            return (PathSmoothResult)ret;
        }
        public static PathSmoothResult SmoothPath(List <Coordinates> path_pts, List <Coordinates> ub_pts, List <Coordinates> lb_pts, List <Coordinates> smoothed_path, smoother_options opt)
        {
            Stopwatch sw = Stopwatch.StartNew();

            double[] px = new double[path_pts.Count];
            double[] py = new double[path_pts.Count];

            double[] ub_x = new double[ub_pts.Count];
            double[] ub_y = new double[ub_pts.Count];

            double[] lb_x = new double[lb_pts.Count];
            double[] lb_y = new double[lb_pts.Count];

            for (int i = 0; i < path_pts.Count; i++)
            {
                px[i] = path_pts[i].X;
                py[i] = path_pts[i].Y;
            }

            for (int i = 0; i < ub_pts.Count; i++)
            {
                ub_x[i] = ub_pts[i].X;
                ub_y[i] = ub_pts[i].Y;
            }

            for (int i = 0; i < lb_pts.Count; i++)
            {
                lb_x[i] = lb_pts[i].X;
                lb_y[i] = lb_pts[i].Y;
            }

            // allocate space for the return points
            double[] smoothed_x = new double[300];
            double[] smoothed_y = new double[300];

            int len = 300;

            int ret = smooth_path(px, py, px.Length, ub_x, ub_y, ub_x.Length, lb_x, lb_y, lb_x.Length, opt, smoothed_x, smoothed_y, ref len);

            smoothed_path.Clear();
            smoothed_path.Capacity = len;
            for (int i = 0; i < len; i++)
            {
                smoothed_path.Add(new Coordinates(smoothed_x[i], smoothed_y[i]));
            }

            sw.Stop();

            Console.WriteLine("took " + sw.ElapsedMilliseconds + " ms");

            return((PathSmoothResult)ret);
        }
 private static extern int smooth_path(
     [In, MarshalAs(UnmanagedType.LPArray)] double[] px, [In, MarshalAs(UnmanagedType.LPArray)] double[] py, [In] int n_p,
     [In, MarshalAs(UnmanagedType.LPArray)] double[] ub_x, [In, MarshalAs(UnmanagedType.LPArray)] double[] ub_y, [In] int n_ub,
     [In, MarshalAs(UnmanagedType.LPArray)] double[] lb_x, [In, MarshalAs(UnmanagedType.LPArray)] double[] lb_y, [In] int n_lb,
     [In] smoother_options opt,
     [In, Out, MarshalAs(UnmanagedType.LPArray)] double[] sm_x, [In, Out, MarshalAs(UnmanagedType.LPArray)] double[] sm_y, [In, Out] ref int n_sm);