示例#1
0
            public Spline(EntityObject entity)
                : base(EdgeType.Spline)
            {
                if (entity == null)
                {
                    throw new ArgumentNullException(nameof(entity));
                }

                Entities.Spline spline = entity as Entities.Spline;
                if (spline == null)
                {
                    throw new ArgumentException("The entity is not an Spline", nameof(entity));
                }

                this.Degree     = spline.Degree;
                this.IsRational = spline.Flags.HasFlag(SplinetypeFlags.Rational);
                this.IsPeriodic = spline.IsPeriodic;
                if (spline.ControlPoints.Count == 0)
                {
                    throw new ArgumentException("The HatchBoundaryPath spline edge requires a spline entity with control points.", nameof(entity));
                }
                this.ControlPoints = new Vector3[spline.ControlPoints.Count];
                for (int i = 0; i < spline.ControlPoints.Count; i++)
                {
                    this.ControlPoints[i] = new Vector3(spline.ControlPoints[i].Position.X, spline.ControlPoints[i].Position.Y, spline.ControlPoints[i].Weigth);
                }
                this.Knots = new double[spline.Knots.Count];
                for (int i = 0; i < spline.Knots.Count; i++)
                {
                    this.Knots[i] = spline.Knots[i];
                }
            }
            public Spline(EntityObject entity)
                : base(EdgeType.Spline)
            {
                if (entity == null)
                {
                    throw new ArgumentNullException("entity");
                }

                Entities.Spline spline = entity as Entities.Spline;
                if (spline == null)
                {
                    throw new ArgumentException("The entity is not an Spline", "entity");
                }

                this.Degree     = spline.Degree;
                this.IsRational = (spline.Flags & SplineTypeFlags.Rational) == SplineTypeFlags.Rational;
                this.IsPeriodic = spline.IsPeriodic;
                this.Knots      = new double[spline.Knots.Length];
                for (int i = 0; i < spline.Knots.Length; i++)
                {
                    this.Knots[i] = spline.Knots[i];
                }
                this.ControlPoints = new Vector3[spline.ControlPoints.Count];
                for (int i = 0; i < spline.ControlPoints.Count; i++)
                {
                    this.ControlPoints[i] = new Vector3(spline.ControlPoints[i].Location.X, spline.ControlPoints[i].Location.Y, spline.ControlPoints[i].Weigth);
                }
            }
            /// <summary>
            /// Initializes a new instance of the <c>HatchBoundaryPath.Spline</c> class.
            /// </summary>
            /// <param name="entity"><see cref="EntityObject">Entity</see> that represents the edge.</param>
            public Spline(EntityObject entity)
                : base(EdgeType.Spline)
            {
                if (entity == null)
                {
                    throw new ArgumentNullException(nameof(entity));
                }

                Entities.Spline spline = entity as Entities.Spline;
                if (spline == null)
                {
                    throw new ArgumentException("The entity is not an Spline", nameof(entity));
                }

                this.Degree     = spline.Degree;
                this.IsRational = true;
                this.IsPeriodic = spline.IsClosedPeriodic;
                if (spline.ControlPoints.Count == 0)
                {
                    throw new ArgumentException("The HatchBoundaryPath spline edge requires a spline entity with control points.", nameof(entity));
                }

                Matrix3 trans = MathHelper.ArbitraryAxis(entity.Normal).Transpose();

                this.ControlPoints = new Vector3[spline.ControlPoints.Count];
                for (int i = 0; i < spline.ControlPoints.Count; i++)
                {
                    Vector3 point = trans * spline.ControlPoints[i].Position;
                    this.ControlPoints[i] = new Vector3(point.X, point.Y, spline.ControlPoints[i].Weight);
                }

                this.Knots = new double[spline.Knots.Length];
                for (int i = 0; i < spline.Knots.Length; i++)
                {
                    this.Knots[i] = spline.Knots[i];
                }
            }