//-------------------------------------------------------------------------------------------------- void _ReadHeader(DxfReader reader) { while (reader.GroupCode > 0) { if (reader.GroupCode != 9) { reader.Skip(); continue; } var variableName = reader.ReadString()?.ToUpper(); if (variableName == null) { continue; } switch (variableName) { /* case "$MEASUREMENT": * var measurement = reader.ReadInteger(); * break;*/ default: reader.Skip(); break; } } }
//-------------------------------------------------------------------------------------------------- public override bool Read(DxfReader reader) { var pointList = new List <Pnt2d>(); Pnt2d point = default; bool skipNextVertex = false; var readBits = new BitVector32(0); // read POLYLINE while (reader.GroupCode > 0) { switch (reader.GroupCode) { case 70: int flags = reader.ReadInteger(); if (flags > 1) { Messages.Warning($"DxfReader: Entity POLYGON has flags set in line {reader.Line} which are not supported for import. The polygon will be imported using straight lines between vertices."); } break; default: reader.Skip(); break; } } // read VERTEX var type = reader.ReadString().ToUpper(); while (type.Equals("VERTEX")) { while (reader.GroupCode > 0) { switch (reader.GroupCode) { case 70: int flags = reader.ReadInteger(); if (flags != 0) { skipNextVertex = true; } break; case 10: point.X = reader.ReadCoord(); readBits[0b01] = true;
//-------------------------------------------------------------------------------------------------- void _Read(DxfReader reader) { while (reader.GroupCode >= 0) { if (reader.GroupCode != 0) { reader.Skip(); continue; } var type = reader.ReadString()?.ToUpper(); if (type == null) { continue; } if (type.Equals("EOF")) { break; } if (type.Equals("SECTION") && reader.GroupCode == 2) { var name = reader.ReadString()?.ToUpper(); if (name == null) { continue; } if (name.Equals("HEADER")) { _ReadHeader(reader); } else if (name.Equals("ENTITIES")) { _ReadEntities(reader); } } } }
//-------------------------------------------------------------------------------------------------- void _ReadEntities(DxfReader reader) { while (reader.GroupCode >= 0) { if (reader.GroupCode != 0) { reader.Skip(); continue; } var type = reader.ReadString()?.ToUpper(); if (type == null) { continue; } DxfDomEntity entity = null; switch (type) { case "ENDSEC": return; case "LINE": entity = new DxfDomLine(); break; case "CIRCLE": case "ARC": entity = new DxfDomCircle(); break; case "ELLIPSE": entity = new DxfDomEllipse(); break; case "LWPOLYLINE": entity = new DxfDomLwPolyline(); break; case "POLYLINE": entity = new DxfDomPolyline(); break; case "SPLINE": entity = new DxfDomSpline(); break; } if (entity == null) { continue; } if (entity.Read(reader)) { Entities.Add(entity); } else { Messages.Error($"DxfReader: Incomplete entity description at line {reader.Line}."); } } }