private void SetInternalInfo(IEnumerable <EntityObject> entities) { bool containsClosedPolyline = false; this.edges.Clear(); foreach (EntityObject entity in entities) { if (containsClosedPolyline) { 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: this.edges.Add(Arc.ConvertFrom(entity)); break; case EntityType.Circle: this.edges.Add(Arc.ConvertFrom(entity)); break; case EntityType.Ellipse: this.edges.Add(Ellipse.ConvertFrom(entity)); break; case EntityType.Line: this.edges.Add(Line.ConvertFrom(entity)); break; case EntityType.LightWeightPolyline: LwPolyline poly = (LwPolyline)entity; if (poly.IsClosed) { if (this.edges.Count != 0) { throw new ArgumentException("Closed polylines cannot be combined with other entities to make a hatch boundary path."); } 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: 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)); } } }
internal HatchBoundaryPath(List<Edge> edges) { if (edges == null) throw new ArgumentNullException("edges"); this.pathTypeFlag = HatchBoundaryPathTypeFlags.Derived | HatchBoundaryPathTypeFlags.External; this.contour = new List<EntityObject>(); this.edges = edges; }
internal HatchBoundaryPath(IEnumerable<Edge> edges) { if (edges == null) throw new ArgumentNullException(nameof(edges)); this.pathType = HatchBoundaryPathTypeFlags.Derived | HatchBoundaryPathTypeFlags.External; this.contour = new List<EntityObject>(); this.edges = new List<Edge>(edges); }
/// <summary> /// Initializes a new instance of the <c>Hatch</c> class. /// </summary> /// <param name="edges">List of entities that makes a loop for the hatch boundary paths.</param> public HatchBoundaryPath(ICollection<EntityObject> edges) { if (edges == null) throw new ArgumentNullException("edges"); this.edges = new List<Edge>(); this.pathTypeFlag = HatchBoundaryPathTypeFlags.Derived | HatchBoundaryPathTypeFlags.External; this.contour = new List<EntityObject>(edges); this.SetInternalInfo(edges); }
internal HatchBoundaryPath(List <Edge> edges) { if (edges == null) { throw new ArgumentNullException("edges"); } this.pathTypeFlag = HatchBoundaryPathTypeFlags.Derived | HatchBoundaryPathTypeFlags.External; this.edges = edges; }
internal HatchBoundaryPath(IEnumerable <Edge> edges) { if (edges == null) { throw new ArgumentNullException(nameof(edges)); } this.pathType = HatchBoundaryPathTypeFlags.Derived | HatchBoundaryPathTypeFlags.External; this.contour = new List <EntityObject>(); this.edges = new List <Edge>(edges); }
/// <summary> /// Initializes a new instance of the <c>Hatch</c> class. /// </summary> /// <param name="edges">List of entities that makes a loop for the hatch boundary paths.</param> public HatchBoundaryPath(ICollection <EntityObject> edges) { if (edges == null) { throw new ArgumentNullException("edges"); } this.edges = new List <Edge>(); this.pathTypeFlag = HatchBoundaryPathTypeFlags.Derived | HatchBoundaryPathTypeFlags.External; this.SetInternalInfo(edges); }
internal HatchBoundaryPath(IEnumerable <Edge> edges) { if (edges == null) { throw new ArgumentNullException(nameof(edges)); } this.pathType = HatchBoundaryPathTypeFlags.Derived | HatchBoundaryPathTypeFlags.External; this.entities = new List <EntityObject>(); this.edges = new List <Edge>(edges); if (this.edges.Count == 1 && this.edges[0].Type == EdgeType.Polyline) { this.pathType |= HatchBoundaryPathTypeFlags.Polyline; } else { foreach (Edge edge in this.edges) { if (edge.Type == EdgeType.Polyline) { throw new ArgumentException("Only a single polyline edge can be part of a HatchBoundaryPath.", nameof(edges)); } } } }
private void SetInternalInfo(IList<EntityObject> entities) { bool containsClosedPolyline = false; this.edges.Clear(); foreach (EntityObject entity in entities) { if ((this.pathTypeFlag & HatchBoundaryPathTypeFlags.Polyline) == 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.pathTypeFlag |= 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)); } } }
static public bool HasFlag(this HatchBoundaryPathTypeFlags flags, HatchBoundaryPathTypeFlags flag) { return((flags & flag) != 0); }