Exemple #1
0
        /// <summary>
        /// Converts the circle in a Polyline2D.
        /// </summary>
        /// <param name="precision">Number of vertexes generated.</param>
        /// <returns>A new instance of <see cref="Polyline2D">Polyline2D</see> that represents the circle.</returns>
        public Polyline2D ToPolyline2D(int precision)
        {
            IEnumerable <Vector2> vertexes = this.PolygonalVertexes(precision);
            Vector3 ocsCenter = MathHelper.Transform(this.Center, this.Normal, CoordinateSystem.World, CoordinateSystem.Object);

            Polyline2D poly = new Polyline2D
            {
                Layer         = (Layer)this.Layer.Clone(),
                Linetype      = (Linetype)this.Linetype.Clone(),
                Color         = (AciColor)this.Color.Clone(),
                Lineweight    = this.Lineweight,
                Transparency  = (Transparency)this.Transparency.Clone(),
                LinetypeScale = this.LinetypeScale,
                Normal        = this.Normal,
                Elevation     = ocsCenter.Z,
                Thickness     = this.thickness,
                IsClosed      = true
            };

            foreach (Vector2 v in vertexes)
            {
                poly.Vertexes.Add(new Polyline2DVertex(v.X + ocsCenter.X, v.Y + ocsCenter.Y));
            }
            return(poly);
        }
Exemple #2
0
        /// <summary>
        /// Creates a new Polyline2D that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Polyline2D that is a copy of this instance.</returns>
        public override object Clone()
        {
            Polyline2D entity = new Polyline2D
            {
                //EntityObject properties
                Layer         = (Layer)this.Layer.Clone(),
                Linetype      = (Linetype)this.Linetype.Clone(),
                Color         = (AciColor)this.Color.Clone(),
                Lineweight    = this.Lineweight,
                Transparency  = (Transparency)this.Transparency.Clone(),
                LinetypeScale = this.LinetypeScale,
                Normal        = this.Normal,
                IsVisible     = this.IsVisible,
                //LwPolyline properties
                Elevation = this.elevation,
                Thickness = this.thickness,
                Flags     = this.flags
            };

            foreach (Polyline2DVertex vertex in this.vertexes)
            {
                entity.Vertexes.Add((Polyline2DVertex)vertex.Clone());
            }

            foreach (XData data in this.XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Exemple #3
0
        /// <summary>
        /// Moves, scales, and/or rotates the current entity given a 3x3 transformation matrix and a translation vector.
        /// </summary>
        /// <param name="transformation">Transformation matrix.</param>
        /// <param name="translation">Translation vector.</param>
        /// <remarks>Matrix3 adopts the convention of using column vectors to represent a transformation matrix.</remarks>
        public override void TransformBy(Matrix3 transformation, Vector3 translation)
        {
            Vector3 newNormal = transformation * this.Normal;

            if (Vector3.Equals(Vector3.Zero, newNormal))
            {
                newNormal = this.Normal;
            }
            this.Normal = newNormal;

            EntityObject clippingEntity = this.ClippingBoundary;

            if (clippingEntity == null)
            {
                if (transformation.IsIdentity)
                {
                    this.center += translation;
                    return;
                }

                // when a view port is transformed a Polyline2D will be generated
                List <Polyline2DVertex> vertexes = new List <Polyline2DVertex>
                {
                    new Polyline2DVertex(this.center.X - this.width * 0.5, this.center.Y - this.height * 0.5),
                    new Polyline2DVertex(this.center.X + this.width * 0.5, this.center.Y - this.height * 0.5),
                    new Polyline2DVertex(this.center.X + this.width * 0.5, this.center.Y + this.height * 0.5),
                    new Polyline2DVertex(this.center.X - this.width * 0.5, this.center.Y + this.height * 0.5)
                };
                clippingEntity = new Polyline2D(vertexes, true);
            }

            clippingEntity.TransformBy(transformation, translation);
            this.ClippingBoundary = clippingEntity;
        }
Exemple #4
0
        /// <summary>
        /// Converts the actual Polyline3D in a Polyline2D.
        /// </summary>
        /// <param name="precision">Number of vertexes generated, only applicable for smoothed polylines.</param>
        /// <returns>A Polyline2D that represents the polyline.</returns>
        /// <remarks>
        /// The resulting Polyline2D will be a projection of the actual polyline into the plane defined by its normal vector.
        /// </remarks>
        public Polyline2D ToPolyline2D(int precision)
        {
            List <Vector3> vertexes3D = this.PolygonalVertexes(precision);
            List <Vector2> vertexes2D = MathHelper.Transform(vertexes3D, this.Normal, out double _);
            Polyline2D     polyline2D = new Polyline2D(vertexes2D)
            {
                Layer         = (Layer)this.Layer.Clone(),
                Linetype      = (Linetype)this.Linetype.Clone(),
                Color         = (AciColor)this.Color.Clone(),
                Lineweight    = this.Lineweight,
                Transparency  = (Transparency)this.Transparency.Clone(),
                LinetypeScale = this.LinetypeScale,
                Normal        = this.Normal,
                IsClosed      = this.IsClosed
            };

            return(polyline2D);
        }
Exemple #5
0
 private static Polyline2D ProcessLwPolyline(Polyline2D polyline2D, Vector3 normal, double elevation)
 {
     polyline2D.Elevation = elevation;
     polyline2D.Normal    = normal;
     return(polyline2D);
 }