internal HatchBoundaryPath(List <Edge> edges) { if (edges == null) { throw new ArgumentNullException("edges"); } this.pathTypeFlag = HatchBoundaryPathTypeFlag.Derived | HatchBoundaryPathTypeFlag.External; this.edges = 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(IEnumerable <EntityObject> edges) { if (edges == null) { throw new ArgumentNullException("edges"); } this.edges = new List <Edge>(); this.pathTypeFlag = HatchBoundaryPathTypeFlag.Derived | HatchBoundaryPathTypeFlag.External; this.SetInternalInfo(edges); }
private void SetInternalInfo(IEnumerable <EntityObject> entities) { bool containsClosedPolyline = false; foreach (EntityObject entity in entities) { if ((pathTypeFlag & HatchBoundaryPathTypeFlag.Polyline) == HatchBoundaryPathTypeFlag.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 theorically 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 |= HatchBoundaryPathTypeFlag.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("The entity type " + entity.Type + " unknown or not implemented as part of a hatch boundary."); } } }