/// <summary> /// Initializes a new instance of the <c>Spline</c> class. /// </summary> /// <param name="fitPoints">Spline fit points.</param> /// <remarks>Spline entities created with a list of fit points cannot be used as a boundary path in a hatch.</remarks> public Spline(IEnumerable<Vector3> fitPoints) : base(EntityType.Spline, DxfObjectCode.Spline) { this.degree = 3; this.isPeriodic = false; this.controlPoints = new List<SplineVertex>(); this.knots = new List<double>(); if (fitPoints == null) throw new ArgumentNullException(nameof(fitPoints)); this.fitPoints = new List<Vector3>(fitPoints); this.creationMethod = SplineCreationMethod.FitPoints; this.isClosed = this.fitPoints[0].Equals(this.fitPoints[this.fitPoints.Count - 1]); this.flags = this.isClosed ? SplinetypeFlags.Closed | SplinetypeFlags.Rational : SplinetypeFlags.Rational; }
/// <summary> /// Initializes a new instance of the <c>Spline</c> class. /// </summary> /// <param name="fitPoints">Spline fit points.</param> /// <remarks>Spline entities created with a list of fit points cannot be used as a boundary path in a hatch.</remarks> public Spline(IEnumerable <Vector3> fitPoints) : base(EntityType.Spline, DxfObjectCode.Spline) { this.degree = 3; this.isPeriodic = false; this.controlPoints = new List <SplineVertex>(); this.knots = new List <double>(); if (fitPoints == null) { throw new ArgumentNullException(nameof(fitPoints)); } this.fitPoints = new List <Vector3>(fitPoints); this.creationMethod = SplineCreationMethod.FitPoints; this.isClosed = this.fitPoints[0].Equals(this.fitPoints[this.fitPoints.Count - 1]); this.flags = this.isClosed ? SplinetypeFlags.Closed | SplinetypeFlags.Rational : SplinetypeFlags.Rational; }
/// <summary> /// Initializes a new instance of the <c>Spline</c> class. /// </summary> /// <param name="controlPoints">Spline control points.</param> /// <param name="knots">Spline knot vector.</param> /// <param name="degree">Degree of the spline curve. Valid values are 1 (linear), degree 2 (quadratic), degree 3 (cubic), and so on up to degree 10.</param> internal Spline(List <SplineVertex> controlPoints, List <double> knots, short degree, List <Vector3> fitPoints, SplineCreationMethod method, bool isPeriodic) : base(EntityType.Spline, DxfObjectCode.Spline) { if (degree < 1 || degree > 10) { throw new ArgumentOutOfRangeException(nameof(degree), degree, "The spline degree valid values range from 1 to 10."); } if (controlPoints == null) { throw new ArgumentNullException(nameof(controlPoints)); } if (controlPoints.Count < 2) { throw new ArgumentException("The number of control points must be equal or greater than 2."); } if (controlPoints.Count < degree + 1) { throw new ArgumentException("The number of control points must be equal or greater than the spline degree + 1."); } if (knots == null) { throw new ArgumentNullException(nameof(knots)); } if (knots.Count != controlPoints.Count + degree + 1) { throw new ArgumentException("The number of knots must be equals to the number of control points + spline degree + 1."); } this.fitPoints = fitPoints; this.controlPoints = controlPoints; this.knots = knots; this.degree = degree; this.creationMethod = method; this.isPeriodic = isPeriodic; if (this.isPeriodic) { this.isClosed = true; this.flags = SplinetypeFlags.Closed | SplinetypeFlags.Periodic | SplinetypeFlags.Rational; } else { this.isClosed = controlPoints[0].Position.Equals(controlPoints[controlPoints.Count - 1].Position); this.flags = this.isClosed ? SplinetypeFlags.Closed | SplinetypeFlags.Rational : SplinetypeFlags.Rational; } }
/// <summary> /// Initializes a new instance of the <c>Spline</c> class. /// </summary> /// <param name="controlPoints">Spline control points.</param> /// <param name="degree">Degree of the spline curve. Valid values are 1 (linear), degree 2 (quadratic), degree 3 (cubic), and so on up to degree 10.</param> /// <param name="periodic">Sets if the spline as periodic closed (default false).</param> public Spline(List <SplineVertex> controlPoints, short degree, bool periodic) : base(EntityType.Spline, DxfObjectCode.Spline) { if (degree < 1 || degree > 10) { throw new ArgumentOutOfRangeException("degree", degree, "The spline degree valid values range from 1 to 10."); } if (controlPoints == null) { throw new ArgumentNullException("controlPoints"); } if (controlPoints.Count < 2) { throw new ArgumentException("The number of control points must be equal or greater than 2."); } if (controlPoints.Count < degree + 1) { throw new ArgumentException("The number of control points must be equal or greater than the spline degree + 1."); } this.fitPoints = new List <Vector3>(); this.degree = degree; this.creationMethod = SplineCreationMethod.ControlPoints; this.isPeriodic = periodic; if (this.isPeriodic) { this.isClosed = true; this.flags = SplinetypeFlags.Closed | SplinetypeFlags.Periodic | SplinetypeFlags.Rational; } else { this.isClosed = controlPoints[0].Position.Equals(controlPoints[controlPoints.Count - 1].Position); this.flags = this.isClosed ? SplinetypeFlags.Closed | SplinetypeFlags.Rational : SplinetypeFlags.Rational; } this.Create(controlPoints); }
public static bool HasFlag(this SplinetypeFlags flags, SplinetypeFlags flag) { return((flags & flag) != 0); }
/// <summary> /// Initializes a new instance of the <c>Spline</c> class. /// </summary> /// <param name="controlPoints">Spline control points.</param> /// <param name="knots">Spline knot vector.</param> /// <param name="degree">Degree of the spline curve. Valid values are 1 (linear), degree 2 (quadratic), degree 3 (cubic), and so on up to degree 10.</param> internal Spline(List<SplineVertex> controlPoints, List<double> knots, short degree, List<Vector3> fitPoints, SplineCreationMethod method, bool isPeriodic) : base(EntityType.Spline, DxfObjectCode.Spline) { if (degree < 1 || degree > 10) throw new ArgumentOutOfRangeException(nameof(degree), degree, "The spline degree valid values range from 1 to 10."); if (controlPoints == null) throw new ArgumentNullException(nameof(controlPoints)); if (controlPoints.Count < 2) throw new ArgumentException("The number of control points must be equal or greater than 2."); if (controlPoints.Count < degree + 1) throw new ArgumentException("The number of control points must be equal or greater than the spline degree + 1."); if (knots == null) throw new ArgumentNullException(nameof(knots)); if (knots.Count != controlPoints.Count + degree + 1) throw new ArgumentException("The number of knots must be equals to the number of control points + spline degree + 1."); this.fitPoints = fitPoints; this.controlPoints = controlPoints; this.knots = knots; this.degree = degree; this.creationMethod = method; this.isPeriodic = isPeriodic; if (this.isPeriodic) { this.isClosed = true; this.flags = SplinetypeFlags.Closed | SplinetypeFlags.Periodic | SplinetypeFlags.Rational; } else { this.isClosed = controlPoints[0].Position.Equals(controlPoints[controlPoints.Count - 1].Position); this.flags = this.isClosed ? SplinetypeFlags.Closed | SplinetypeFlags.Rational : SplinetypeFlags.Rational; } }