private void PrepareForWriting() { var nextHandle = DxfPointer.AssignHandles(this); Header.NextAvailableHandle = nextHandle; SetExtents(); UpdateTimes(); Normalize(); }
private DxfWriter PrepareWriter(Stream stream, bool asText) { UpdateTimes(); Normalize(); var writer = new DxfWriter(stream, asText); writer.Open(); var nextHandle = DxfPointer.AssignHandles(this); Header.NextAvailableHandle = nextHandle; return(writer); }
internal static DxfFile LoadFromReader(IDxfCodePairReader reader) { var file = new DxfFile(); file.Clear(); var buffer = new DxfCodePairBufferReader(reader); var version = DxfAcadVersion.R14; while (buffer.ItemsRemain) { var pair = buffer.Peek(); if (DxfCodePair.IsSectionStart(pair)) { buffer.Advance(); // swallow (0, SECTION) pair var section = DxfSection.FromBuffer(buffer, file, version); if (section != null) { switch (section.Type) { case DxfSectionType.Blocks: file.BlocksSection = (DxfBlocksSection)section; break; case DxfSectionType.Entities: file.EntitiesSection = (DxfEntitiesSection)section; break; case DxfSectionType.Classes: file.ClassSection = (DxfClassesSection)section; break; case DxfSectionType.Header: file.HeaderSection = (DxfHeaderSection)section; version = file.Header.Version; break; case DxfSectionType.Objects: file.ObjectsSection = (DxfObjectsSection)section; break; case DxfSectionType.Tables: file.TablesSection = (DxfTablesSection)section; break; case DxfSectionType.Thumbnail: file.ThumbnailImageSection = (DxfThumbnailImageSection)section; break; } } } else if (DxfCodePair.IsEof(pair)) { // swallow and quit buffer.Advance(); break; } else if (DxfCodePair.IsComment(pair)) { // swallow comments buffer.Advance(); } else { // swallow unexpected code pair buffer.Advance(); } } Debug.Assert(!buffer.ItemsRemain); DxfPointer.BindPointers(file); return(file); }