//
        // Steps Extrude
        //

        public static Surface Extrude(this Polyline curve, int steps, double height, double taper)
        {
            Vector3F normal = Vector3F.Undefined;

            taper = (taper < 0 ? -1f : 1f) - taper;

            if (curve.Points.Count < 2)
            {
                return(null);
            }

            if (steps < 2)
            {
                return(null);
            }

            steps = ((steps / 4) + ((steps % 4) != 0 ? 4 : 0)) * 4;

            if (curve.Points.Count > 2)
            {
                normal = Vector3F.CrossProduct(new Vector3F(curve.Points[0].Point, curve.Points[1].Point), new Vector3F(curve.Points[0].Point, curve.Points[2].Point));
            }

            if (normal.IsUndefined)
            {
                normal = new Vector3F(0, 0, -1);
            }

            normal = normal.Unit();

            Surface surface = new Surface();

            for (double i = 0; i <= 1; i = i + 1 / (double)steps)
            {
                surface.Points.Add(curve.GetParametricPoint(i));
            }

            int num = 0;

            Point3F sumBase   = new Point3F(0, 0, 0);
            Point3F sumHeight = new Point3F(0, 0, 0);

            for (double j = 0; j <= 1; j = j + 1 / (double)steps)
            {
                Point3F item = surface.Points[num];

                sumBase = sumBase.Add(item);

                item.X = (item.X * taper) + (normal.X * height);
                item.Y = (item.Y * taper) + (normal.Y * height);
                item.Z = item.Z + (normal.Z * height);

                sumHeight = sumHeight.Add(item);

                surface.Points.Add(item);

                num++;
            }

            sumBase.DivideBy(num);
            sumHeight.DivideBy(num);

            TriangleFace[] faces = new TriangleFace[(num + (curve.Closed ? 1 : 0)) * 2];

            int k;

            for (k = 0; k < num - 1; k++)
            {
                faces [k * 2]     = new TriangleFace(k, k + 1, k + num + 1);
                faces [k * 2 + 1] = new TriangleFace(k, k + num + 1, k + num);
            }

            if (curve.Closed)
            {
                faces [k * 2]     = new TriangleFace(num - 1, 0, num);
                faces [k * 2 + 1] = new TriangleFace(num - 1, num, 2 * num - 1);
            }

            surface.Faces = faces;

            return(surface);
        }