예제 #1
0
        /// <summary>
        /// Reverses the order of the knot vector.
        /// </summary>
        /// <param name="knots">Knot vectors to be reversed.</param>
        /// <returns>Reversed knot vectors.</returns>
        public static KnotVector Reverse(KnotVector knots)
        {
            KnotVector reversedKnots = new KnotVector {
                knots[0]
            };

            for (int i = 1; i < knots.Count; i++)
            {
                reversedKnots.Add(reversedKnots[i - 1] + (knots[knots.Count - i] - knots[knots.Count - i - 1]));
            }

            return(reversedKnots);
        }
예제 #2
0
        /// <summary>
        /// Normalizes knot vectors of all curves to the same domain.
        /// </summary>
        internal static IList <NurbsBase> NormalizedKnots(IList <NurbsBase> curves)
        {
            // Unify knots, normalized them.
            curves = curves
                     .Select(curve => curve.Knots.GetDomain(curve.Degree).Length > 1
                    ? new NurbsCurve(curve.Degree, curve.Knots.Normalize(), curve.ControlPoints)
                    : curve).ToList();

            // Unify curves by knots.
            KnotVector combinedKnots = curves.First().Knots.Copy();

            foreach (NurbsBase curve in curves.Skip(1))
            {
                combinedKnots.AddRange(curve.Knots.Where(k => !combinedKnots.Contains(k)).ToList());
            }

            curves = (from curve in curves
                      let knotToInsert = combinedKnots.OrderBy(k => k).Where(k => !curve.Knots.Contains(k)).ToKnot()
                                         select KnotVector.Refine(curve, knotToInsert)).ToList();
            return(curves);
        }