Ejemplo n.º 1
0
        private List <EntityObject> CreateRoundCap(Vector2 start, Vector2 end, Matrix3 transformation, AciColor color1, Linetype linetype1, AciColor color2, Linetype linetype2)
        {
            List <EntityObject> entities = new List <EntityObject>();

            Vector2 center     = Vector2.MidPoint(start, end);
            double  startAngle = Vector2.Angle(start - center) * MathHelper.RadToDeg;
            double  endAngle   = startAngle + 180.0;
            double  radius     = (start - center).Modulus();

            if (!MathHelper.IsZero(radius))
            {
                if (!color1.Equals(color2) || !linetype1.Equals(linetype2))
                {
                    double midAngle = startAngle + 90.0;
                    Arc    arc1     = this.CreateArc(center, radius, startAngle, midAngle, color1, linetype1);
                    arc1.TransformBy(transformation, Vector3.Zero);
                    entities.Add(arc1);
                    Arc arc2 = this.CreateArc(center, radius, midAngle, endAngle, color2, linetype2);
                    arc2.TransformBy(transformation, Vector3.Zero);
                    entities.Add(arc2);
                }
                else
                {
                    Arc arc = this.CreateArc(center, radius, startAngle, endAngle, color1, linetype1);
                    arc.TransformBy(transformation, Vector3.Zero);
                    entities.Add(arc);
                }
            }

            return(entities);
        }
Ejemplo n.º 2
0
        private List <EntityObject> CreateSquareCap(Vector2 start, Vector2 end, Matrix3 transformation, AciColor color1, Linetype linetype1, AciColor color2, Linetype linetype2)
        {
            List <EntityObject> entities = new List <EntityObject>();

            Vector2 midPoint = Vector2.MidPoint(start, end);

            if (!color1.Equals(color2) || !linetype1.Equals(linetype2))
            {
                Line line1 = this.CreateLine(start, midPoint, color1, linetype1);
                line1.TransformBy(transformation, Vector3.Zero);
                entities.Add(line1);
                Line line2 = this.CreateLine(midPoint, end, color2, linetype2);
                line2.TransformBy(transformation, Vector3.Zero);
                entities.Add(line2);
            }
            else
            {
                Line line = this.CreateLine(start, end, color1, linetype1);
                line.TransformBy(transformation, Vector3.Zero);
                entities.Add(line);
            }

            return(entities);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <c>MLineStyleElement</c> class.
 /// </summary>
 /// <param name="offset">Element offset.</param>
 /// <param name="color">Element color.</param>
 /// <param name="linetype">Element line type.</param>
 public MLineStyleElement(double offset, AciColor color, Linetype linetype)
 {
     this.offset   = offset;
     this.color    = color;
     this.linetype = linetype;
 }
Ejemplo n.º 4
0
        protected virtual Linetype OnMLineStyleElementLinetypeChangedEvent(Linetype oldLinetype, Linetype newLinetype)
        {
            MLineStyleElementLinetypeChangedEventHandler ae = this.MLineStyleElementLinetypeChanged;

            if (ae != null)
            {
                TableObjectChangedEventArgs <Linetype> eventArgs = new TableObjectChangedEventArgs <Linetype>(oldLinetype, newLinetype);
                ae(this, eventArgs);
                return(eventArgs.NewValue);
            }
            return(newLinetype);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Decompose the actual polyface mesh faces in <see cref="Point">points</see> (one vertex polyface mesh face),
        /// <see cref="Line">lines</see> (two vertexes polyface mesh face) and <see cref="Face3d">3d faces</see> (three or four vertexes polyface mesh face).
        /// </summary>
        /// <returns>A list of <see cref="Face3d">3d faces</see> that made up the polyface mesh.</returns>
        public List <EntityObject> Explode()
        {
            List <EntityObject> entities = new List <EntityObject>();

            foreach (PolyfaceMeshFace face in Faces)
            {
                if (face.VertexIndexes.Count == 1)
                {
                    Point point = new Point
                    {
                        Layer         = (Layer)Layer.Clone(),
                        Linetype      = (Linetype)Linetype.Clone(),
                        Color         = (AciColor)Color.Clone(),
                        Lineweight    = Lineweight,
                        Transparency  = (Transparency)Transparency.Clone(),
                        LinetypeScale = LinetypeScale,
                        Normal        = Normal,
                        Position      = Vertexes[Math.Abs(face.VertexIndexes[0]) - 1].Position,
                    };
                    entities.Add(point);
                    continue;
                }
                if (face.VertexIndexes.Count == 2)
                {
                    Line line = new Line
                    {
                        Layer         = (Layer)Layer.Clone(),
                        Linetype      = (Linetype)Linetype.Clone(),
                        Color         = (AciColor)Color.Clone(),
                        Lineweight    = Lineweight,
                        Transparency  = (Transparency)Transparency.Clone(),
                        LinetypeScale = LinetypeScale,
                        Normal        = Normal,
                        StartPoint    = Vertexes[Math.Abs(face.VertexIndexes[0]) - 1].Position,
                        EndPoint      = Vertexes[Math.Abs(face.VertexIndexes[1]) - 1].Position,
                    };
                    entities.Add(line);
                    continue;
                }

                Face3dEdgeFlags edgeVisibility = Face3dEdgeFlags.Visibles;

                short indexV1 = face.VertexIndexes[0];
                short indexV2 = face.VertexIndexes[1];
                short indexV3 = face.VertexIndexes[2];
                // Polyface mesh faces are made of 3 or 4 vertexes, we will repeat the third vertex if the number of face vertexes is three
                int indexV4 = face.VertexIndexes.Count == 3 ? face.VertexIndexes[2] : face.VertexIndexes[3];

                if (indexV1 < 0)
                {
                    edgeVisibility = edgeVisibility | Face3dEdgeFlags.First;
                }
                if (indexV2 < 0)
                {
                    edgeVisibility = edgeVisibility | Face3dEdgeFlags.Second;
                }
                if (indexV3 < 0)
                {
                    edgeVisibility = edgeVisibility | Face3dEdgeFlags.Third;
                }
                if (indexV4 < 0)
                {
                    edgeVisibility = edgeVisibility | Face3dEdgeFlags.Fourth;
                }

                Vector3 v1 = Vertexes[Math.Abs(indexV1) - 1].Position;
                Vector3 v2 = Vertexes[Math.Abs(indexV2) - 1].Position;
                Vector3 v3 = Vertexes[Math.Abs(indexV3) - 1].Position;
                Vector3 v4 = Vertexes[Math.Abs(indexV4) - 1].Position;

                Face3d face3d = new Face3d
                {
                    Layer         = (Layer)Layer.Clone(),
                    Linetype      = (Linetype)Linetype.Clone(),
                    Color         = (AciColor)Color.Clone(),
                    Lineweight    = Lineweight,
                    Transparency  = (Transparency)Transparency.Clone(),
                    LinetypeScale = LinetypeScale,
                    Normal        = Normal,
                    FirstVertex   = v1,
                    SecondVertex  = v2,
                    ThirdVertex   = v3,
                    FourthVertex  = v4,
                    EdgeFlags     = edgeVisibility,
                };

                entities.Add(face3d);
            }
            return(entities);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Decompose the actual multiline in its internal entities, <see cref="Line">lines</see> and <see cref="Arc">arcs</see>.
        /// </summary>
        /// <returns>A list of <see cref="Line">lines</see> and <see cref="Arc">arcs</see> that made up the multiline.</returns>
        public List <EntityObject> Explode()
        {
            List <EntityObject> entities = new List <EntityObject>();

            Matrix3 transformation = MathHelper.ArbitraryAxis(this.Normal);

            // precomputed points at multiline vertexes for start and end caps calculations
            Vector2[][] cornerVertexes = new Vector2[this.vertexes.Count][];

            for (int i = 0; i < this.vertexes.Count; i++)
            {
                MLineVertex vertex = this.vertexes[i];
                MLineVertex nextVertex;

                if (this.IsClosed && i == this.vertexes.Count - 1)
                {
                    nextVertex = this.vertexes[0];
                }
                else if (!this.IsClosed && i == this.vertexes.Count - 1)
                {
                    continue;
                }
                else
                {
                    nextVertex            = this.vertexes[i + 1];
                    cornerVertexes[i + 1] = new Vector2[this.style.Elements.Count];
                }

                cornerVertexes[i] = new Vector2[this.style.Elements.Count];

                for (int j = 0; j < this.style.Elements.Count; j++)
                {
                    if (vertex.Distances[j].Count == 0)
                    {
                        continue;
                    }

                    Vector2 refStart = vertex.Position + vertex.Miter * vertex.Distances[j][0];
                    cornerVertexes[i][j] = refStart;
                    for (int k = 1; k < vertex.Distances[j].Count; k++)
                    {
                        Vector2 start = refStart + vertex.Direction * vertex.Distances[j][k];
                        Vector2 end;
                        if (k >= vertex.Distances[j].Count - 1)
                        {
                            end = nextVertex.Position + nextVertex.Miter * nextVertex.Distances[j][0];
                            if (!this.IsClosed)
                            {
                                cornerVertexes[i + 1][j] = end;
                            }
                        }
                        else
                        {
                            end = refStart + vertex.Direction * vertex.Distances[j][k + 1];
                            k++; // skip next segment it is a blank space
                        }

                        Line line = this.CreateLine(start, end, this.style.Elements[j].Color, this.style.Elements[j].Linetype);
                        line.TransformBy(transformation, Vector3.Zero);
                        entities.Add(line);
                    }
                }
            }

            if (this.style.Flags.HasFlag(MLineStyleFlags.DisplayJoints))
            {
                AciColor color1    = this.style.Elements[0].Color;
                AciColor color2    = this.style.Elements[this.style.Elements.Count - 1].Color;
                Linetype linetype1 = this.style.Elements[0].Linetype;
                Linetype linetype2 = this.style.Elements[this.style.Elements.Count - 1].Linetype;

                for (int i = 0; i < cornerVertexes.Length; i++)
                {
                    if (!this.IsClosed && (i == 0 || i == cornerVertexes.Length - 1))
                    {
                        continue;
                    }

                    Vector2 start = cornerVertexes[i][0];
                    Vector2 end   = cornerVertexes[i][cornerVertexes[0].Length - 1];

                    entities.AddRange(this.CreateSquareCap(start, end, transformation, color1, linetype1, color2, linetype2));
                }
            }

            // when the multiline is closed there are no caps
            if (this.IsClosed)
            {
                return(entities);
            }

            if (!this.NoStartCaps)
            {
                if (this.style.Flags.HasFlag(MLineStyleFlags.StartRoundCap))
                {
                    AciColor color1    = this.style.Elements[0].Color;
                    AciColor color2    = this.style.Elements[this.style.Elements.Count - 1].Color;
                    Linetype linetype1 = this.style.Elements[0].Linetype;
                    Linetype linetype2 = this.style.Elements[this.style.Elements.Count - 1].Linetype;

                    Vector2 start = cornerVertexes[0][0];
                    Vector2 end   = cornerVertexes[0][cornerVertexes[0].Length - 1];

                    entities.AddRange(this.scale >= 0 ?
                                      this.CreateRoundCap(start, end, transformation, color1, linetype1, color2, linetype2) :
                                      this.CreateRoundCap(end, start, transformation, color2, linetype2, color1, linetype1));
                }

                if (this.style.Flags.HasFlag(MLineStyleFlags.StartInnerArcsCap))
                {
                    int j = (int)(this.style.Elements.Count * 0.5);  // Math.Floor

                    for (int i = 1; i < j; i++)
                    {
                        AciColor color1    = this.style.Elements[i].Color;
                        AciColor color2    = this.style.Elements[this.style.Elements.Count - 1 - i].Color;
                        Linetype linetype1 = this.style.Elements[i].Linetype;
                        Linetype linetype2 = this.style.Elements[this.style.Elements.Count - 1 - i].Linetype;

                        Vector2 start = cornerVertexes[0][i];
                        Vector2 end   = cornerVertexes[0][cornerVertexes[0].Length - 1 - i];

                        entities.AddRange(this.scale >= 0 ?
                                          this.CreateRoundCap(start, end, transformation, color1, linetype1, color2, linetype2) :
                                          this.CreateRoundCap(end, start, transformation, color2, linetype2, color1, linetype1));
                    }
                }

                if (this.style.Flags.HasFlag(MLineStyleFlags.StartSquareCap))
                {
                    AciColor color1    = this.style.Elements[0].Color;
                    AciColor color2    = this.style.Elements[this.style.Elements.Count - 1].Color;
                    Linetype linetype1 = this.style.Elements[0].Linetype;
                    Linetype linetype2 = this.style.Elements[this.style.Elements.Count - 1].Linetype;

                    Vector2 start = cornerVertexes[0][0];
                    Vector2 end   = cornerVertexes[0][cornerVertexes[0].Length - 1];

                    entities.AddRange(this.CreateSquareCap(start, end, transformation, color1, linetype1, color2, linetype2));
                }
            }

            if (!this.NoEndCaps)
            {
                if (this.style.Flags.HasFlag(MLineStyleFlags.EndRoundCap))
                {
                    AciColor color1    = this.style.Elements[this.style.Elements.Count - 1].Color;
                    AciColor color2    = this.style.Elements[0].Color;
                    Linetype linetype1 = this.style.Elements[this.style.Elements.Count - 1].Linetype;
                    Linetype linetype2 = this.style.Elements[0].Linetype;

                    Vector2 start = cornerVertexes[this.vertexes.Count - 1][cornerVertexes[0].Length - 1];
                    Vector2 end   = cornerVertexes[this.vertexes.Count - 1][0];

                    entities.AddRange(this.scale >= 0 ?
                                      this.CreateRoundCap(start, end, transformation, color1, linetype1, color2, linetype2) :
                                      this.CreateRoundCap(end, start, transformation, color2, linetype2, color1, linetype1));
                }

                if (this.style.Flags.HasFlag(MLineStyleFlags.EndInnerArcsCap))
                {
                    int j = (int)(this.style.Elements.Count * 0.5);  // Math.Floor

                    for (int i = 1; i < j; i++)
                    {
                        AciColor color1    = this.style.Elements[this.style.Elements.Count - 1 - i].Color;
                        AciColor color2    = this.style.Elements[i].Color;
                        Linetype linetype1 = this.style.Elements[this.style.Elements.Count - 1 - i].Linetype;
                        Linetype linetype2 = this.style.Elements[i].Linetype;

                        Vector2 start = cornerVertexes[this.vertexes.Count - 1][cornerVertexes[0].Length - 1 - i];
                        Vector2 end   = cornerVertexes[this.vertexes.Count - 1][i];

                        entities.AddRange(this.scale >= 0 ?
                                          this.CreateRoundCap(start, end, transformation, color1, linetype1, color2, linetype2) :
                                          this.CreateRoundCap(end, start, transformation, color2, linetype2, color1, linetype1));
                    }
                }

                if (this.style.Flags.HasFlag(MLineStyleFlags.EndSquareCap))
                {
                    AciColor color1    = this.style.Elements[this.style.Elements.Count - 1].Color;
                    AciColor color2    = this.style.Elements[0].Color;
                    Linetype linetype1 = this.style.Elements[this.style.Elements.Count - 1].Linetype;
                    Linetype linetype2 = this.style.Elements[0].Linetype;

                    Vector2 start = cornerVertexes[this.vertexes.Count - 1][cornerVertexes[0].Length - 1];
                    Vector2 end   = cornerVertexes[this.vertexes.Count - 1][0];

                    entities.AddRange(this.CreateSquareCap(start, end, transformation, color1, linetype1, color2, linetype2));
                }
            }

            return(entities);
        }
Ejemplo n.º 7
0
 private Arc CreateArc(Vector2 center, double radius, double startAngle, double endAngle, AciColor color, Linetype linetype)
 {
     return(new Arc(center, radius, startAngle, endAngle)
     {
         Layer = (Layer)this.Layer.Clone(),
         Linetype = (Linetype)linetype.Clone(),
         Color = (AciColor)color.Clone(),
         Lineweight = this.Lineweight,
         Transparency = (Transparency)this.Transparency.Clone(),
         LinetypeScale = this.LinetypeScale,
         Normal = this.Normal,
         IsVisible = this.IsVisible,
     });
 }
Ejemplo n.º 8
0
        // TODO: return IList for Explode methods
        /// <summary>
        /// Decompose the actual polyline in its internal entities, <see cref="Line">lines</see> and <see cref="Arc">arcs</see>.
        /// </summary>
        /// <returns>A list of <see cref="Line">lines</see> and <see cref="Arc">arcs</see> that made up the polyline.</returns>
        public List <EntityObject> Explode()
        {
            List <EntityObject> entities = new List <EntityObject>();
            int index = 0;

            foreach (LwPolylineVertex vertex in Vertexes)
            {
                double  bulge = vertex.Bulge;
                Vector2 p1;
                Vector2 p2;

                if (index == Vertexes.Count - 1)
                {
                    if (!IsClosed)
                    {
                        break;
                    }
                    p1 = new Vector2(vertex.Position.X, vertex.Position.Y);
                    p2 = new Vector2(vertexes[0].Position.X, vertexes[0].Position.Y);
                }
                else
                {
                    p1 = new Vector2(vertex.Position.X, vertex.Position.Y);
                    p2 = new Vector2(vertexes[index + 1].Position.X, vertexes[index + 1].Position.Y);
                }

                if (MathHelper.IsZero(bulge))
                {
                    // the polyline edge is a line
                    Vector3 start = MathHelper.Transform(new Vector3(p1.X, p1.Y, elevation), Normal, CoordinateSystem.Object, CoordinateSystem.World);
                    Vector3 end   = MathHelper.Transform(new Vector3(p2.X, p2.Y, elevation), Normal, CoordinateSystem.Object, CoordinateSystem.World);

                    entities.Add(new Line
                    {
                        Layer         = (Layer)Layer.Clone(),
                        Linetype      = (Linetype)Linetype.Clone(),
                        Color         = (AciColor)Color.Clone(),
                        Lineweight    = Lineweight,
                        Transparency  = (Transparency)Transparency.Clone(),
                        LinetypeScale = LinetypeScale,
                        Normal        = Normal,
                        StartPoint    = start,
                        EndPoint      = end,
                        Thickness     = Thickness
                    });
                }
                else
                {
                    // the polyline edge is an arc
                    double theta = 4 * Math.Atan(Math.Abs(bulge));
                    double c     = Vector2.Distance(p1, p2);
                    double r     = (c / 2) / Math.Sin(theta / 2);

                    // avoid arcs with very small radius, draw a line instead
                    if (MathHelper.IsZero(r))
                    {
                        // the polyline edge is a line
                        Vector3 start = MathHelper.Transform(new Vector3(p1.X, p1.Y, elevation), Normal, CoordinateSystem.Object, CoordinateSystem.World);
                        Vector3 end   = MathHelper.Transform(new Vector3(p2.X, p2.Y, elevation), Normal, CoordinateSystem.Object, CoordinateSystem.World);

                        entities.Add(new Line
                        {
                            Layer         = (Layer)Layer.Clone(),
                            Linetype      = (Linetype)Linetype.Clone(),
                            Color         = (AciColor)Color.Clone(),
                            Lineweight    = Lineweight,
                            Transparency  = (Transparency)Transparency.Clone(),
                            LinetypeScale = LinetypeScale,
                            Normal        = Normal,
                            StartPoint    = start,
                            EndPoint      = end,
                            Thickness     = Thickness,
                        });
                    }
                    else
                    {
                        double  gamma  = (Math.PI - theta) / 2;
                        double  phi    = Vector2.Angle(p1, p2) + Math.Sign(bulge) * gamma;
                        Vector2 center = new Vector2(p1.X + r * Math.Cos(phi), p1.Y + r * Math.Sin(phi));
                        double  startAngle;
                        double  endAngle;
                        if (bulge > 0)
                        {
                            startAngle = MathHelper.RadToDeg * Vector2.Angle(p1 - center);
                            endAngle   = startAngle + MathHelper.RadToDeg * theta;
                        }
                        else
                        {
                            endAngle   = MathHelper.RadToDeg * Vector2.Angle(p1 - center);
                            startAngle = endAngle - MathHelper.RadToDeg * theta;
                        }
                        Vector3 point = MathHelper.Transform(new Vector3(center.X, center.Y, elevation), Normal,
                                                             CoordinateSystem.Object,
                                                             CoordinateSystem.World);
                        entities.Add(new Arc
                        {
                            Layer         = (Layer)Layer.Clone(),
                            Linetype      = (Linetype)Linetype.Clone(),
                            Color         = (AciColor)Color.Clone(),
                            Lineweight    = Lineweight,
                            Transparency  = (Transparency)Transparency.Clone(),
                            LinetypeScale = LinetypeScale,
                            Normal        = Normal,
                            Center        = point,
                            Radius        = r,
                            StartAngle    = startAngle,
                            EndAngle      = endAngle,
                            Thickness     = Thickness,
                        });
                    }
                }
                index++;
            }

            return(entities);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Decompose the actual multiline in its internal entities, <see cref="Line">lines</see> and <see cref="Arc">arcs</see>.
        /// </summary>
        /// <returns>A list of <see cref="Line">lines</see> and <see cref="Arc">arcs</see> that made up the multiline.</returns>
        /// <exception cref="InvalidOperationException">An exception will be thrown if the number of distances for a given MLineStyleElement is not an even number.</exception>
        public List <EntityObject> Explode()
        {
            Matrix3 transformation = MathHelper.ArbitraryAxis(this.Normal);

            List <EntityObject> entities = new List <EntityObject>();

            // precomputed points at mline vertexes for start and end caps calculations
            Vector2[][] cornerVextexes = new Vector2[this.vertexes.Count][];

            for (int i = 0; i < this.vertexes.Count; i++)
            {
                MLineVertex vertex = this.vertexes[i];
                MLineVertex nextVertex;

                if (this.IsClosed && i == this.vertexes.Count - 1)
                {
                    nextVertex = this.vertexes[0];
                }
                else if (!this.IsClosed && i == this.vertexes.Count - 1)
                {
                    continue;
                }
                else
                {
                    nextVertex            = this.vertexes[i + 1];
                    cornerVextexes[i + 1] = new Vector2[this.style.Elements.Count];
                }

                cornerVextexes[i] = new Vector2[this.style.Elements.Count];

                for (int j = 0; j < this.style.Elements.Count; j++)
                {
                    if (this.style.Elements.Count % 2 != 0)
                    {
                        throw new InvalidOperationException("The number of distances for a given MLineStyleElement must be an even number.");
                    }

                    Vector2 refStart = vertex.Position + vertex.Miter * vertex.Distances[j][0];
                    cornerVextexes[i][j] = refStart;
                    for (int k = 1; k < vertex.Distances[j].Count; k++)
                    {
                        Vector2 start = refStart + vertex.Direction * vertex.Distances[j][k];
                        Vector2 end;
                        if (k >= vertex.Distances[j].Count - 1)
                        {
                            end = nextVertex.Position + nextVertex.Miter * nextVertex.Distances[j][0];
                            if (!this.IsClosed)
                            {
                                cornerVextexes[i + 1][j] = end;
                            }
                        }
                        else
                        {
                            end = refStart + vertex.Direction * vertex.Distances[j][k + 1];
                            k++; // skip next segment it is a blank space
                        }

                        Line line = this.CreateLine(start, end, this.style.Elements[j].Color, this.style.Elements[j].Linetype);
                        line.TransformBy(transformation, Vector3.Zero);
                        entities.Add(line);
                    }
                }
            }

            if (this.style.Flags.HasFlag(MLineStyleFlags.DisplayJoints))
            {
                AciColor color1    = this.style.Elements[0].Color;
                AciColor color2    = this.style.Elements[this.style.Elements.Count - 1].Color;
                Linetype linetype1 = this.style.Elements[0].Linetype;
                Linetype linetype2 = this.style.Elements[this.style.Elements.Count - 1].Linetype;

                bool trim = !color1.Equals(color2) || !linetype1.Equals(linetype2);

                for (int i = 0; i < cornerVextexes.Length; i++)
                {
                    if (!this.IsClosed && (i == 0 || i == cornerVextexes.Length - 1))
                    {
                        continue;
                    }

                    Vector2 start    = cornerVextexes[i][0];
                    Vector2 end      = cornerVextexes[i][cornerVextexes[0].Length - 1];
                    Vector2 midPoint = Vector2.MidPoint(start, end);
                    if (trim)
                    {
                        Line line1 = this.CreateLine(start, midPoint, color1, linetype1);
                        line1.TransformBy(transformation, Vector3.Zero);
                        entities.Add(line1);

                        Line line2 = this.CreateLine(midPoint, end, color2, linetype2);
                        line2.TransformBy(transformation, Vector3.Zero);
                        entities.Add(line2);
                    }
                    else
                    {
                        Line line = this.CreateLine(start, end, color1, linetype1);
                        line.TransformBy(transformation, Vector3.Zero);
                        entities.Add(line);
                    }
                }
            }

            // when the mline is closed there are no caps
            if (this.IsClosed)
            {
                return(entities);
            }

            if (!this.NoStartCaps)
            {
                if (this.style.Flags.HasFlag(MLineStyleFlags.StartRoundCap))
                {
                    AciColor color1    = this.style.Elements[0].Color;
                    AciColor color2    = this.style.Elements[this.style.Elements.Count - 1].Color;
                    Linetype linetype1 = this.style.Elements[0].Linetype;
                    Linetype linetype2 = this.style.Elements[this.style.Elements.Count - 1].Linetype;

                    bool trim = !color1.Equals(color2) || !linetype1.Equals(linetype2);

                    Vector2 center = Vector2.MidPoint(cornerVextexes[0][0], cornerVextexes[0][cornerVextexes.Length - 1]);
                    Vector2 start  = cornerVextexes[0][0];
                    //Vector2 end = cornerVextexes[0][cornerVextexes[0].Length - 1];

                    double startAngle = Vector2.Angle(start - center) * MathHelper.RadToDeg;
                    //double endAngle = Vector2.Angle(end - center) * MathHelper.RadToDeg;
                    double endAngle = startAngle + 180.0;
                    double radius   = (start - center).Modulus();

                    if (trim)
                    {
                        double midAngle = startAngle + 90.0;
                        Arc    arc1     = this.CreateArc(center, radius, startAngle, midAngle, color1, linetype1);
                        arc1.TransformBy(transformation, Vector3.Zero);
                        entities.Add(arc1);
                        Arc arc2 = this.CreateArc(center, radius, midAngle, endAngle, color2, linetype2);
                        arc2.TransformBy(transformation, Vector3.Zero);
                        entities.Add(arc2);
                    }
                    else
                    {
                        Arc arc = this.CreateArc(center, radius, startAngle, endAngle, color1, linetype1);
                        arc.TransformBy(transformation, Vector3.Zero);
                        entities.Add(arc);
                    }
                }

                if (this.style.Flags.HasFlag(MLineStyleFlags.StartInnerArcsCap))
                {
                    Vector2 center = Vector2.MidPoint(cornerVextexes[0][0], cornerVextexes[0][cornerVextexes.Length - 1]);;

                    int j = (int)Math.Floor(this.style.Elements.Count / 2.0);

                    for (int i = 1; i < j; i++)
                    {
                        AciColor color1    = this.style.Elements[i].Color;
                        AciColor color2    = this.style.Elements[this.style.Elements.Count - 1 - i].Color;
                        Linetype linetype1 = this.style.Elements[i].Linetype;
                        Linetype linetype2 = this.style.Elements[this.style.Elements.Count - 1 - i].Linetype;

                        bool trim = !color1.Equals(color2) || !linetype1.Equals(linetype2);

                        Vector2 start = cornerVextexes[0][i];
                        //Vector2 end = cornerVextexes[0][cornerVextexes[0].Length - 1 - i];

                        double startAngle = Vector2.Angle(start - center) * MathHelper.RadToDeg;
                        //double endAngle = Vector2.Angle(end - center) * MathHelper.RadToDeg;
                        double endAngle = startAngle + 180.0;
                        double radius   = (start - center).Modulus();

                        if (trim)
                        {
                            double midAngle = startAngle + 90.0;
                            Arc    arc1     = this.CreateArc(center, radius, startAngle, midAngle, color1, linetype1);
                            arc1.TransformBy(transformation, Vector3.Zero);
                            entities.Add(arc1);
                            Arc arc2 = this.CreateArc(center, radius, midAngle, endAngle, color2, linetype2);
                            arc2.TransformBy(transformation, Vector3.Zero);
                            entities.Add(arc2);
                        }
                        else
                        {
                            Arc arc = this.CreateArc(center, radius, startAngle, endAngle, color1, linetype1);
                            arc.TransformBy(transformation, Vector3.Zero);
                            entities.Add(arc);
                        }
                    }
                }

                if (this.style.Flags.HasFlag(MLineStyleFlags.StartSquareCap))
                {
                    AciColor color1    = this.style.Elements[0].Color;
                    AciColor color2    = this.style.Elements[this.style.Elements.Count - 1].Color;
                    Linetype linetype1 = this.style.Elements[0].Linetype;
                    Linetype linetype2 = this.style.Elements[this.style.Elements.Count - 1].Linetype;

                    bool trim = !color1.Equals(color2) || !linetype1.Equals(linetype2);

                    Vector2 start    = cornerVextexes[0][0];
                    Vector2 end      = cornerVextexes[0][cornerVextexes[0].Length - 1];
                    Vector2 midPoint = Vector2.MidPoint(start, end);

                    if (trim)
                    {
                        Line line1 = this.CreateLine(start, midPoint, color1, linetype1);
                        line1.TransformBy(transformation, Vector3.Zero);
                        entities.Add(line1);
                        Line line2 = this.CreateLine(midPoint, end, color2, linetype2);
                        line2.TransformBy(transformation, Vector3.Zero);
                        entities.Add(line2);
                    }
                    else
                    {
                        Line line = this.CreateLine(start, end, color1, linetype1);
                        line.TransformBy(transformation, Vector3.Zero);
                        entities.Add(line);
                    }
                }
            }

            if (!this.NoEndCaps)
            {
                if (this.style.Flags.HasFlag(MLineStyleFlags.EndRoundCap))
                {
                    AciColor color1    = this.style.Elements[0].Color;
                    AciColor color2    = this.style.Elements[this.style.Elements.Count - 1].Color;
                    Linetype linetype1 = this.style.Elements[0].Linetype;
                    Linetype linetype2 = this.style.Elements[this.style.Elements.Count - 1].Linetype;

                    bool trim = !color1.Equals(color2) || !linetype1.Equals(linetype2);

                    Vector2 center = Vector2.MidPoint(cornerVextexes[this.vertexes.Count - 1][0], cornerVextexes[this.vertexes.Count - 1][cornerVextexes.Length - 1]);
                    Vector2 start  = cornerVextexes[this.vertexes.Count - 1][cornerVextexes[0].Length - 1];
                    //Vector2 end = cornerVextexes[this.vertexes.Count - 1][0];

                    double startAngle = Vector2.Angle(start - center) * MathHelper.RadToDeg;
                    //double endAngle = Vector2.Angle(end - center) * MathHelper.RadToDeg;
                    double endAngle = startAngle + 180.0;
                    double radius   = (start - center).Modulus();

                    if (trim)
                    {
                        double midAngle = startAngle + 90.0;

                        Arc arc1 = this.CreateArc(center, radius, midAngle, endAngle, color1, linetype1);
                        arc1.TransformBy(transformation, Vector3.Zero);
                        entities.Add(arc1);

                        Arc arc2 = this.CreateArc(center, radius, startAngle, midAngle, color2, linetype2);
                        arc2.TransformBy(transformation, Vector3.Zero);
                        entities.Add(arc2);
                    }
                    else
                    {
                        Arc arc = this.CreateArc(center, radius, startAngle, endAngle, color1, linetype1);
                        arc.TransformBy(transformation, Vector3.Zero);
                        entities.Add(arc);
                    }
                }

                if (this.style.Flags.HasFlag(MLineStyleFlags.EndInnerArcsCap))
                {
                    Vector2 center = Vector2.MidPoint(cornerVextexes[this.vertexes.Count - 1][0], cornerVextexes[this.vertexes.Count - 1][cornerVextexes.Length - 1]);

                    int j = (int)Math.Floor(this.style.Elements.Count / 2.0);
                    for (int i = 1; i < j; i++)
                    {
                        AciColor color1    = this.style.Elements[i].Color;
                        AciColor color2    = this.style.Elements[this.style.Elements.Count - 1 - i].Color;
                        Linetype linetype1 = this.style.Elements[i].Linetype;
                        Linetype linetype2 = this.style.Elements[this.style.Elements.Count - 1 - i].Linetype;

                        bool trim = !color1.Equals(color2) || !linetype1.Equals(linetype2);

                        Vector2 start = cornerVextexes[this.vertexes.Count - 1][cornerVextexes[0].Length - 1 - i];
                        //Vector2 end = cornerVextexes[this.vertexes.Count - 1][i];

                        double startAngle = Vector2.Angle(start - center) * MathHelper.RadToDeg;
                        //double endAngle = Vector2.Angle(end - center) * MathHelper.RadToDeg;
                        double endAngle = startAngle + 180.0;
                        double radius   = (start - center).Modulus();

                        if (trim)
                        {
                            double midAngle = startAngle + 90.0;

                            Arc arc1 = this.CreateArc(center, radius, midAngle, endAngle, color1, linetype1);
                            arc1.TransformBy(transformation, Vector3.Zero);
                            entities.Add(arc1);

                            Arc arc2 = this.CreateArc(center, radius, startAngle, midAngle, color2, linetype2);
                            arc2.TransformBy(transformation, Vector3.Zero);
                            entities.Add(arc2);
                        }
                        else
                        {
                            Arc arc = this.CreateArc(center, radius, startAngle, endAngle, color1, linetype1);
                            arc.TransformBy(transformation, Vector3.Zero);
                            entities.Add(arc);
                        }
                    }
                }

                if (this.style.Flags.HasFlag(MLineStyleFlags.EndSquareCap))
                {
                    AciColor color1    = this.style.Elements[0].Color;
                    AciColor color2    = this.style.Elements[this.style.Elements.Count - 1].Color;
                    Linetype linetype1 = this.style.Elements[0].Linetype;
                    Linetype linetype2 = this.style.Elements[this.style.Elements.Count - 1].Linetype;

                    bool trim = !color1.Equals(color2) || !linetype1.Equals(linetype2);

                    Vector2 start    = cornerVextexes[this.vertexes.Count - 1][cornerVextexes[0].Length - 1];
                    Vector2 end      = cornerVextexes[this.vertexes.Count - 1][0];
                    Vector2 midPoint = Vector2.MidPoint(start, end);

                    if (trim)
                    {
                        Line line1 = this.CreateLine(midPoint, end, color1, linetype1);
                        line1.TransformBy(transformation, Vector3.Zero);
                        entities.Add(line1);

                        Line line2 = this.CreateLine(start, midPoint, color2, linetype2);
                        line2.TransformBy(transformation, Vector3.Zero);
                        entities.Add(line2);
                    }
                    else
                    {
                        Line line = this.CreateLine(start, end, color1, linetype1);
                        line.TransformBy(transformation, Vector3.Zero);
                        entities.Add(line);
                    }
                }
            }

            return(entities);
        }