Exemple #1
0
        /***************************************************/

        private static PolyCurve ExtendTangent(this PolyCurve curve, double start = 0.0, double end = 0.0, double tolerance = Tolerance.Distance)
        {
            if (-start > curve.Length() || -end > curve.Length()) //ExtendTangent allows to trim the curve but only to the limit of it's length.
            {
                Reflection.Compute.RecordError("Extension value too small");

                return(null);
            }

            if (start < 0 && end < 0)
            {
                return(curve.Extend(start, end, false, tolerance));
            }

            if (start < 0 && !(end < 0))
            {
                curve = curve.Extend(start, 0, false, tolerance);
                return(curve.ExtendTangent(0, end, tolerance));
            }

            if (!(start < 0) && end < 0)
            {
                curve = curve.Extend(0, end, false, tolerance);
                return(curve.ExtendTangent(start, 0, tolerance));
            }

            List <ICurve> curves = curve.SubParts();

            if (curves.Count == 1)
            {
                return new PolyCurve {
                           Curves = curves[0].IExtend(start, end, true, tolerance).ISubParts().ToList()
                }
            }
            ;
            else
            {
                curves[0] = curves[0].IExtend(start, 0, true, tolerance);

                curves[curves.Count - 1] = curves[curves.Count - 1].IExtend(0, end, true, tolerance);
                return(new PolyCurve {
                    Curves = curves
                });
            }
        }