Beispiel #1
0
        public LwPolyline ToPolyline(int precision)
        {
            IEnumerable <Vector2> vertexes = this.PolygonalVertexes(precision);
            Vector3 ocsCenter = MathHelper.Transform(this.center, this.Normal, CoordinateSystem.World, CoordinateSystem.Object);

            LwPolyline poly = new LwPolyline
            {
                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      = false
            };

            foreach (Vector2 v in vertexes)
            {
                poly.Vertexes.Add(new LwPolylineVertex(v.X + ocsCenter.X, v.Y + ocsCenter.Y));
            }
            return(poly);
        }
Beispiel #2
0
        public override object Clone()
        {
            LwPolyline entity = new LwPolyline
            {
                //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 (LwPolylineVertex vertex in this.vertexes)
            {
                entity.Vertexes.Add((LwPolylineVertex)vertex.Clone());
            }

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

            return(entity);
        }
Beispiel #3
0
        private void SetInternalInfo(IEnumerable <EntityObject> entities)
        {
            bool containsClosedPolyline = false;

            this.edges.Clear();

            foreach (EntityObject entity in entities)
            {
                if (this.pathType.HasFlag(HatchBoundaryPathTypeFlags.Polyline))
                {
                    if (this.edges.Count >= 1)
                    {
                        throw new ArgumentException("Closed polylines cannot be combined with other entities to make a hatch boundary path.");
                    }
                }

                // it seems that AutoCad does not have problems on creating loops that theoretically does not make sense, like, for example an internal loop that is made of a single arc.
                // so if AutoCAD is OK with that I am too, the program that make use of this information will take care of this inconsistencies
                switch (entity.Type)
                {
                case EntityType.Arc:
                    if (containsClosedPolyline)
                    {
                        throw new ArgumentException("Closed polylines cannot be combined with other entities to make a hatch boundary path.");
                    }
                    this.edges.Add(Arc.ConvertFrom(entity));
                    break;

                case EntityType.Circle:
                    if (containsClosedPolyline)
                    {
                        throw new ArgumentException("Closed polylines cannot be combined with other entities to make a hatch boundary path.");
                    }
                    this.edges.Add(Arc.ConvertFrom(entity));
                    break;

                case EntityType.Ellipse:
                    if (containsClosedPolyline)
                    {
                        throw new ArgumentException("Closed polylines cannot be combined with other entities to make a hatch boundary path.");
                    }
                    this.edges.Add(Ellipse.ConvertFrom(entity));
                    break;

                case EntityType.Line:
                    if (containsClosedPolyline)
                    {
                        throw new ArgumentException("Closed polylines cannot be combined with other entities to make a hatch boundary path.");
                    }
                    this.edges.Add(Line.ConvertFrom(entity));
                    break;

                case EntityType.LightWeightPolyline:
                    if (containsClosedPolyline)
                    {
                        throw new ArgumentException("Closed polylines cannot be combined with other entities to make a hatch boundary path.");
                    }
                    LwPolyline poly = (LwPolyline)entity;
                    if (poly.IsClosed)
                    {
                        this.edges.Add(Polyline.ConvertFrom(entity));     // A polyline HatchBoundaryPath must be closed
                        this.pathType         |= HatchBoundaryPathTypeFlags.Polyline;
                        containsClosedPolyline = true;
                    }
                    else
                    {
                        this.SetInternalInfo(poly.Explode());     // open polylines will always be exploded, only one polyline can be present in a path
                    }
                    break;

                case EntityType.Spline:
                    if (containsClosedPolyline)
                    {
                        throw new ArgumentException("Closed polylines cannot be combined with other entities to make a hatch boundary path.");
                    }
                    this.edges.Add(Spline.ConvertFrom(entity));
                    break;

                default:
                    throw new ArgumentException(string.Format("The entity type {0} cannot be part of a hatch boundary.", entity.Type));
                }
            }
        }
Beispiel #4
0
 private static LwPolyline ProcessLwPolyline(LwPolyline polyline, Vector3 normal, double elevation)
 {
     polyline.Elevation = elevation;
     polyline.Normal    = normal;
     return(polyline);
 }