<|start_filename|>ACadSharp/Tables/FontFlags.cs<|end_filename|>
﻿using System;

namespace ACadSharp.Tables
{
	/// <summary>
	/// Represent the font character formatting, such as italic, bold, or regular.
	/// </summary>
	[Flags]
	public enum FontFlags
	{
		/// <summary>
		/// Regular.
		/// </summary>
		Regular = 0,
		/// <summary>
		/// Italic or oblique.
		/// </summary>
		Italic = 1,
		/// <summary>
		/// Bold.
		/// </summary>
		Bold = 2
	}
}



<|start_filename|>ACadSharp/Entities/Text.cs<|end_filename|>
﻿using ACadSharp.IO.Templates;

namespace ACadSharp.Entities
{
	public class Text : TextEntity
	{
		public override ObjectType ObjectType => ObjectType.TEXT;
		public override string ObjectName => DxfFileToken.EntityText;

		public Text() : base() { }

		internal Text(DxfEntityTemplate template) : base(template) { }
	}
}


<|start_filename|>ACadSharp/Attributes/DxfSubClassEntityAttribute.cs<|end_filename|>
﻿using System;

namespace ACadSharp.Attributes
{
	[System.AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
	sealed class DxfSubClassEntityAttribute : Attribute
	{
		public string ClassName { get; }
		public DxfSubClassEntityAttribute(string className)
		{
			ClassName = className;
		}
	}
}


<|start_filename|>ACadSharp/Header/ObjectSnapMode.cs<|end_filename|>
﻿using System;

namespace ACadSharp.Header
{
	/// <summary>
	/// Object snap mode AcDb::OsnapMask
	/// </summary>
	[Flags]
	public enum ObjectSnapMode : ushort
	{
		/// <summary>
		/// Switch off all snapping modes
		/// </summary>
		None = 0,
		/// <summary>
		/// Snap to end point of lines, arcs, and to polyline vertices
		/// </summary>
		EndPoint = 1,
		/// <summary>
		/// Snap to mid point of lines, arcs, and polyline segments
		/// </summary>
		MidPoint = 2,
		/// <summary>
		/// Snap to center of circles, arcs. and polyline arc segments
		/// </summary>
		Center = 4,
		/// <summary>
		/// Snap to the center of point objects
		/// </summary>
		Node = 8,
		/// <summary>
		/// Snap to circle quadrant points at 0°, 90°, 180°, and 270°.
		/// </summary>
		Quadrant = 16, // 0x0010
		/// <summary>
		/// Snap to intersections of any two drawing objects
		/// </summary>
		Intersection = 32, // 0x0020
		/// <summary>
		/// Snap to insertion points of blocks, texts, and images.
		/// </summary>
		Insertion = 64, // 0x0040
		/// <summary>
		/// Snap to points which form a perpendicular with the selected object.
		/// </summary>
		Perpendicular = 128, // 0x0080
		/// <summary>
		/// Snap to tangent points
		/// </summary>
		Tangent = 256, // 0x0100
		/// <summary>
		/// Snap to the nearest point on a drawing object
		/// </summary>
		Nearest = 512, // 0x0200
		/// <summary>
		/// Clears all object snaps
		/// </summary>
		ClearsAllObjectSnaps = 1024, // 0x0400
		/// <summary>
		/// Snap to apparent intersections in the view
		/// </summary>
		ApparentIntersection = 2048, // 0x0800
		/// <summary>
		/// Snap to extensions of lines
		/// </summary>
		Extension = 4096, // 0x1000
		/// <summary>
		/// Parallel lines
		/// </summary>
		Parallel = 8192, // 0x2000
		/// <summary>
		/// All snapping modes on
		/// </summary>
		AllModes = Parallel | Extension | ApparentIntersection | ClearsAllObjectSnaps | Nearest | Tangent | Perpendicular | Insertion | Intersection | Quadrant | Node | Center | MidPoint | EndPoint, // 0x3FFF
		/// <summary>
		/// Switch off snapping
		/// </summary>
		SwitchedOff = 16384, // 0x4000
	}
}


<|start_filename|>ACadSharp/Header/DimensionAssociation.cs<|end_filename|>
﻿namespace ACadSharp.Header
{
	/// <summary>
	/// Controls the associativity of dimension objects.
	/// </summary>
	public enum DimensionAssociation : short
	{
		/// <summary>
		/// Creates exploded dimensions; there is no association between elements of the dimension, and the lines, arcs, arrowheads, and text of a dimension are drawn as separate objects
		/// </summary>
		CreateExplodedDimensions = 0,
		/// <summary>
		/// Creates non-associative dimension objects; the elements of the dimension are formed into a single object, and if the definition point on the object moves, then the dimension value is updated
		/// </summary>
		CreateNonAssociativeDimensions = 1,
		/// <summary>
		/// Creates associative dimension objects; the elements of the dimension are formed into a single object and one or more definition points of the dimension are coupled with association points on geometric objects
		/// </summary>
		CreateAssociativeDimensions = 2
	}
}


<|start_filename|>ACadSharp/Entities/InvisibleEdgeFlags.cs<|end_filename|>
﻿using System;
/// <summary>
/// Defines which edges are hidden.
/// </summary>
[Flags]
public enum InvisibleEdgeFlags
{
	/// <summary>
	/// No flags equivalent to all edges are visible.
	/// </summary>
	None = 0,
	/// <summary>
	/// First edge is invisible.
	/// </summary>
	First = 1,
	/// <summary>
	/// Second edge is invisible.
	/// </summary>
	Second = 2,
	/// <summary>
	/// Third edge is invisible.
	/// </summary>
	Third = 4,
	/// <summary>
	/// Fourth edge is invisible.
	/// </summary>
	Fourth = 8
}

<|start_filename|>ACadSharp/Entities/HatchStyleType.cs<|end_filename|>
﻿namespace ACadSharp.Entities
{
	/// <summary>
	/// Hatch pattern style.
	/// </summary>
	public enum HatchStyleType
	{
		/// <summary>
		/// Hatch "odd parity" area.
		/// </summary>
		Normal = 0,
		/// <summary>
		/// Hatch outermost area only.
		/// </summary>
		Outer = 1,
		/// <summary>
		/// Hatch through entire area.
		/// </summary>
		Ignore = 2
	}
}


<|start_filename|>ACadSharp/Attributes/CadSystemVariableAttribute.cs<|end_filename|>
﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ACadSharp.Attributes
{
	[System.AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	sealed class CadSystemVariableAttribute : Attribute
	{
		public string Name { get; }
		public DxfCode[] ValueCodes { get; }
		public CadSystemVariableAttribute(string variable, params DxfCode[] codes)
		{
			Name = variable;
			ValueCodes = codes;
		}
	}
}


<|start_filename|>ACadSharp/IO/DWG/FileHeaders/DwgFileHeader.cs<|end_filename|>
﻿using CSUtilities.Text;
using System;
using System.Collections.Generic;
using System.Text;

namespace ACadSharp.IO.DWG
{
	public abstract class DwgFileHeader
	{
		public ACadVersion AcadVersion { get; }
		public long PreviewAddress { get; set; } = -1;
		public int AcadMaintenanceVersion { get; set; }

		public DwgFileHeader() { }
		public DwgFileHeader(ACadVersion version)
		{
			AcadVersion = version;
		}

		public static DwgFileHeader GetFileHeader(ACadVersion version)
		{
			switch (version)
			{
				case ACadVersion.Unknown:
					throw new Exception();
				case ACadVersion.MC0_0:
				case ACadVersion.AC1_2:
				case ACadVersion.AC1_4:
				case ACadVersion.AC1_50:
				case ACadVersion.AC2_10:
				case ACadVersion.AC1002:
				case ACadVersion.AC1003:
				case ACadVersion.AC1004:
				case ACadVersion.AC1006:
				case ACadVersion.AC1009:
					throw new NotSupportedException();
				case ACadVersion.AC1012:
				case ACadVersion.AC1014:
				case ACadVersion.AC1015:
					return new DwgFileHeader15(version);
				case ACadVersion.AC1018:
					return new DwgFileHeader18(version);
				case ACadVersion.AC1021:
					return new DwgFileHeader21(version);
				case ACadVersion.AC1024:
				case ACadVersion.AC1027:
				case ACadVersion.AC1032:
					//Check if it works...
					return new DwgFileHeader18(version);
				default:
					break;
			}

			return null;
		}
	}

	public class DwgFileHeader15 : DwgFileHeader
	{
		public CodePage DrawingCodePage { get; set; }

		public Dictionary<int, DwgSectionLocatorRecord> Records { get; set; } = new Dictionary<int, DwgSectionLocatorRecord>();
		public DwgFileHeader15() : base() { }
		public DwgFileHeader15(ACadVersion version) : base(version) { }
	}
	public class DwgFileHeader18 : DwgFileHeader15
	{
		public byte DwgVersion { get; set; }
		public byte AppReleaseVersion { get; set; }
		public long SummaryInfoAddr { get; set; }
		public long SecurityType { get; set; }
		public long VbaProjectAddr { get; set; }
		public int RootTreeNodeGap { get; set; }
		public int GapArraySize { get; set; }
		public uint CRCSeed { get; set; }
		public int LastPageId { get; set; }
		public long LastSectionAddr { get; set; }
		public ulong SecondHeaderAddr { get; set; }
		public int GapAmount { get; set; }
		public int SectionAmount { get; set; }
		public uint SectionPageMapId { get; set; }
		public ulong PageMapAddress { get; set; }
		public uint SectionMapId { get; set; }
		public uint SectionArrayPageSize { get; set; }
		public int RigthGap { get; set; }
		public int LeftGap { get; set; }

		public Dictionary<string, DwgSectionDescriptor> Descriptors { get; set; } = new Dictionary<string, DwgSectionDescriptor>();

		public DwgFileHeader18() : base() { }
		public DwgFileHeader18(ACadVersion version) : base(version) { }

	}

	public class DwgFileHeader21 : DwgFileHeader18
	{
		public Dwg21CompressedMetadata CompressedMetadata { get; set; }
		public DwgFileHeader21() : base() { }
		public DwgFileHeader21(ACadVersion version) : base(version) { }
	}

	public class Dwg21CompressedMetadata
	{
		public ulong HeaderSize { get; set; } = 0x70;
		public ulong FileSize { get; set; }
		public ulong PagesMapCrcCompressed { get; set; }
		public ulong PagesMapCorrectionFactor { get; set; }
		public ulong PagesMapCrcSeed { get; set; }
		public ulong Map2Offset { get; set; }
		public ulong Map2Id { get; set; }
		public ulong PagesMapOffset { get; set; }
		public ulong Header2offset { get; set; }
		public ulong PagesMapSizeCompressed { get; set; }
		public ulong PagesMapSizeUncompressed { get; set; }
		public ulong PagesAmount { get; set; }
		public ulong PagesMaxId { get; set; }
		public ulong SectionsMap2Id { get; set; }
		public ulong PagesMapId { get; set; }
		public ulong Unknow0x20 { get; set; } = 32;
		public ulong Unknow0x40 { get; set; } = 64;
		public ulong PagesMapCrcUncompressed { get; set; }
		public ulong Unknown0x800 { get; set; } = 63488;
		public ulong Unknown4 { get; set; } = 4;
		public ulong Unknown1 { get; set; } = 1;
		public ulong SectionsAmount { get; set; }
		public ulong SectionsMapCrcUncompressed { get; set; }
		public ulong SectionsMapSizeCompressed { get; set; }
		public ulong SectionsMapId { get; set; }
		public ulong SectionsMapSizeUncompressed { get; set; }
		public ulong SectionsMapCrcCompressed { get; set; }
		public ulong SectionsMapCorrectionFactor { get; set; }
		public ulong SectionsMapCrcSeed { get; set; }
		public ulong StreamVersion { get; set; } = 393472;
		public ulong CrcSeed { get; set; }
		public ulong CrcSeedEncoded { get; set; }
		public ulong RandomSeed { get; set; }
		public ulong HeaderCRC64 { get; set; }
	}
}


<|start_filename|>ACadSharp/Header/ShadeEdgeType.cs<|end_filename|>
﻿namespace ACadSharp.Header
{
	/// <summary>
	/// Edge shape type
	/// </summary>
	public enum ShadeEdgeType : short
	{
		/// <summary>
		/// Faces shaded, edges not highlighted
		/// </summary>
		FacesShadedEdgesNotHighlighted,
		/// <summary>
		/// Faces shaded, edges highlighted in black
		/// </summary>
		FacesShadedEdgesHighlightedInBlack,
		/// <summary>
		/// Faces not filled, edges in entity color
		/// </summary>
		FacesNotFilledEdgesInEntityColor,
		/// <summary>
		/// Faces in entity color, edges in black
		/// </summary>
		FacesInEntityColorEdgesInBlack,
	}
}


<|start_filename|>ACadSharp/IO/DWG/FileHeaders/DwgSectionLocatorRecord.cs<|end_filename|>
﻿namespace ACadSharp.IO.DWG
{
	public class DwgSectionLocatorRecord
	{
		/// <summary>
		/// Number of the record or id.
		/// </summary>
		public int Number { get; set; }
		/// <summary>
		/// Offset where the record is.
		/// </summary>
		public long Seeker { get; set; }
		/// <summary>
		/// Size in bytes of this record.
		/// </summary>
		public long Size { get; set; }
		public DwgSectionLocatorRecord() { }
		public DwgSectionLocatorRecord(int number, int offset, int size)
		{
			this.Number = number;
			this.Seeker = offset;
			this.Size = size;
		}
		/// <summary>
		/// Check if the position is in the record.
		/// </summary>
		/// <param name="position"></param>
		/// <returns></returns>
		public bool IsInTheRecord(int position)
		{
			return position >= this.Seeker && position < this.Seeker + this.Size;
		}
	}
}

<|start_filename|>ACadSharp/IO/DWG/DwgStreamReaders/CRC8StreamHandler.cs<|end_filename|>
﻿using System.IO;

namespace ACadSharp.IO.DWG
{
	internal class CRC8StreamHandler : Stream
	{
		public override bool CanRead => StreamCRC.CanRead;
		public override bool CanSeek => StreamCRC.CanSeek;
		public override bool CanWrite => StreamCRC.CanWrite;
		public override long Length => StreamCRC.Length;
		public override long Position
		{
			get => StreamCRC.Position;
			set => StreamCRC.Position = value;
		}
		public Stream StreamCRC { get; }
		public ushort Seed { get; set; }
		public CRC8StreamHandler(Stream stream, ushort seed)
		{
			StreamCRC = stream;
			Seed = seed;
		}
		public override int Read(byte[] buffer, int offset, int count)
		{
			int nbytes = StreamCRC.Read(buffer, offset, count);
			int length = offset + count;

			for (int index = offset; index < length; ++index)
				Seed = decode(Seed, buffer[index]);

			return nbytes;
		}
		public override void Flush() => StreamCRC.Flush();
		public override long Seek(long offset, SeekOrigin origin) => StreamCRC.Seek(offset, origin);
		public override void SetLength(long value) => StreamCRC.SetLength(value);
		public override void Write(byte[] buffer, int offset, int count)
		{
			int length = offset + count;

			for (int index = offset; index < length; ++index)
				Seed = decode(Seed, buffer[index]);

			StreamCRC.Write(buffer, offset, count);
		}
		//**************************************************************************
		private ushort decode(ushort key, byte value)
		{
			int index = value ^ (byte)key;
			key = (ushort)((uint)key >> 8 ^ CRC.CrcTable[index]);
			return key;
		}
	}
}


<|start_filename|>ACadSharp/IO/DWG/FileHeaders/DwgSectionDescriptor.cs<|end_filename|>
﻿using System;
using System.Collections.Generic;

namespace ACadSharp.IO.DWG
{
	public class DwgSectionDescriptor
	{
		public string Name { get; set; }
		public ulong CompressedSize { get; set; }
		public int PageCount { get; set; }
		public ulong DecompressedSize { get; set; } = 29696;
		/// <remarks>
		/// Is only used for the version <see cref="ACadVersion.AC1018"/> and <see cref="ACadVersion.AC1024"/> or above.
		/// </remarks>
		public int CompressedCode
		{
			get => this.m_compressed;
			set => this.m_compressed = value == 1 || value == 2 ? value :
					throw new Exception();
		}
		private int m_compressed = 2;
		/// <remarks>
		/// Is only used for the version <see cref="ACadVersion.AC1018"/> and <see cref="ACadVersion.AC1024"/> or above.
		/// </remarks>
		public bool IsCompressed { get { return CompressedCode == 2; } }
		public int SectionId { get; set; }
		public int Encrypted { get; set; }

		public ulong? HashCode { get; internal set; }
		public ulong? Encoding { get; internal set; }

		public List<DwgLocalSectionMap> LocalSections { get; set; } = new List<DwgLocalSectionMap>();

		public DwgSectionDescriptor() { }
		public DwgSectionDescriptor(string name)
		{
			Name = name;
		}
	}
}

<|start_filename|>ACadSharp/IO/DWG/DwgStreamReaders/Dwg2004LZ77.cs<|end_filename|>
﻿using System.IO;

namespace ACadSharp.IO.DWG
{
	/// <summary>
	/// Variation of the algorithm LZ77 used in 2004 DWG files.
	/// </summary>
	internal static class Dwg2004LZ77
	{
		/// <summary>
		/// Decompress a stream with a specific decompressed size.
		/// </summary>
		/// <param name="compressed"></param>
		/// <param name="decompressedSize"></param>
		/// <returns></returns>
		public static Stream Decompress(Stream compressed, long decompressedSize)
		{
			//Create a new stream
			MemoryStream memoryStream = new MemoryStream(new byte[decompressedSize]);

			//Decompress the stream
			DecompressToDest(compressed, memoryStream);
			memoryStream.Position = 0L;

			return memoryStream;
		}
		/// <summary>
		/// Decompress a compressed source stream.
		/// </summary>
		/// <param name="src">Source, compressed stream.</param>
		/// <param name="dst">Destination, decompressed stream.</param>
		public static void DecompressToDest(Stream src, Stream dst)
		{
			int opcode1 = (byte)src.ReadByte();

			if ((opcode1 & 0xF0) == 0)
				opcode1 = copy(literalCount(opcode1, src) + 3, src, dst);

			//0x11 : Terminates the input stream.
			while (opcode1 != 0x11)
			{
				//0x00 – 0x0F : Not used, because this would be mistaken for a Literal Length in some situations.

				//Offset backwards from the current location in the decompressed data stream, where the “compressed” bytes should be copied from.
				int compOffset = 0;
				//Number of “compressed” bytes that are to be copied to this location from a previous location in the uncompressed data stream.
				int compressedBytes = 0;

				if (opcode1 < 0x10 || opcode1 >= 0x40)
				{
					compressedBytes = (opcode1 >> 4) - 1;
					//Read the next byte(call it opcode2):
					byte opcode2 = (byte)src.ReadByte();
					compOffset = ((opcode1 >> 2 & 3) | (opcode2 << 2)) + 1;
				}
				//0x12 – 0x1F
				else if (opcode1 < 0x20)
				{
					compressedBytes = readCompressedBytes(opcode1, 0b0111, src);
					compOffset = (opcode1 & 8) << 11;
					opcode1 = twoByteOffset(ref compOffset, 0x4000, src);
				}
				//0x20
				else if (opcode1 >= 0x20)
				{
					compressedBytes = readCompressedBytes(opcode1, 0b00011111, src);
					opcode1 = twoByteOffset(ref compOffset, 1, src);
				}

				long position = dst.Position;
				for (long i = compressedBytes + position; position < i; ++position)
				{
					dst.Position = position - compOffset;
					byte value = (byte)dst.ReadByte();
					dst.Position = position;
					dst.WriteByte(value);
				}
				//Number of uncompressed or literal bytes to be copied from the input stream, following the addition of the compressed bytes.
				int litCount = opcode1 & 3;
				//0x00 : litCount is read as the next Literal Length (see format below)
				if (litCount == 0)
				{
					opcode1 = (byte)src.ReadByte();
					if ((opcode1 & 240) == 0)
						litCount = literalCount(opcode1, src) + 3;
				}

				//Copy as literal
				if (litCount > 0U)
					opcode1 = copy(litCount, src, dst);
			}
		}
		private static byte copy(int count, Stream src, Stream dst)
		{
			for (int i = 0; i < count; ++i)
			{
				byte b = (byte)src.ReadByte();
				dst.WriteByte(b);
			}

			return (byte)src.ReadByte();
		}
		private static int literalCount(int code, Stream src)
		{
			int lowbits = code & 0b1111;
			//0x00 : Set the running total to 0x0F, and read the next byte. From this point on, a 0x00 byte adds 0xFF to the running total, and a non-zero byte adds that value to the running total and terminates the process. Add 3 to the final result.
			if (lowbits == 0)
			{
				byte lastByte;
				for (lastByte = (byte)src.ReadByte(); lastByte == 0; lastByte = (byte)src.ReadByte())
					lowbits += byte.MaxValue;  //0xFF

				lowbits += 15 + lastByte;
			}
			return lowbits;
		}
		private static int readCompressedBytes(int opcode1, int validBits, Stream compressed)
		{
			int compressedBytes = opcode1 & validBits;

			if (compressedBytes == 0)
			{
				byte lastByte;

				for (lastByte = (byte)compressed.ReadByte(); lastByte == 0; lastByte = (byte)compressed.ReadByte())
					compressedBytes += byte.MaxValue;

				compressedBytes += lastByte + validBits;
			}

			return compressedBytes + 2;
		}
		private static int twoByteOffset(ref int offset, int addedValue, Stream stream)
		{
			int firstByte = stream.ReadByte();

			offset |= firstByte >> 2;
			offset |= stream.ReadByte() << 6;
			offset += addedValue;

			return firstByte;
		}
	}
}


<|start_filename|>ACadSharp/Entities/BoundaryPathFlags.cs<|end_filename|>
﻿using System;

namespace ACadSharp.Entities
{
	/// <summary>
	/// Defines the boundary path type of the hatch.
	/// </summary>
	/// <remarks>Bit flag.</remarks>
	[Flags]
	public enum BoundaryPathFlags
	{
		/// <summary>
		/// Default.
		/// </summary>
		Default = 0,
		/// <summary>
		/// External.
		/// </summary>
		External = 1,
		/// <summary>
		/// Polyline.
		/// </summary>
		Polyline = 2,
		/// <summary>
		/// Derived.
		/// </summary>
		Derived = 4,
		/// <summary>
		/// Text box.
		/// </summary>
		Textbox = 8,
		/// <summary>
		/// Outermost.
		/// </summary>
		Outermost = 16,
		/// <summary>
		/// Loop is not closed.
		/// </summary>
		NotClosed = 32, 
		/// <summary>
		/// Self-intersecting loop.
		/// </summary>
		SelfIntersecting = 64, 
		/// <summary>
		/// Text loop surrounded by an even number of loops.
		/// </summary>
		TextIsland = 128, 
		/// <summary>
		/// Duplicate loop.
		/// </summary>
		Duplicate = 256,
		/// <summary>
		/// The bounding area is an annotative block.
		/// </summary>
		IsAnnotative = 512, 
		/// <summary>
		/// The bounding type does not support scaling.
		/// </summary>
		DoesNotSupportScale = 1024, 
		/// <summary>
		/// Forces all annotatives to be visible.
		/// </summary>
		ForceAnnoAllVisible = 2048, 
		/// <summary>
		/// Orients hatch loop to paper.
		/// </summary>
		OrientToPaper = 4096, 
		/// <summary>
		/// Describes if the hatch is an annotative block.
		/// </summary>
		IsAnnotativeBlock = 8192, 
	}
}


<|start_filename|>ACadSharp/IO/DWG/FileHeaders/DwgSectionHash.cs<|end_filename|>
﻿namespace ACadSharp.IO.DWG
{
	internal enum DwgSectionHash
	{
		AcDb_Unknown = 0x00000000,
		AcDb_Security = 0x4a0204ea,
		AcDb_FileDepList = 0x6c4205ca,
		AcDb_VBAProject = 0x586e0544,
		AcDb_AppInfo = 0x3fa0043e,
		AcDb_Preview = 0x40aa0473,
		AcDb_SummaryInfo = 0x717a060f,
		AcDb_RevHistory = 0x60a205b3,
		AcDb_AcDbObjects = 0x674c05a9,
		AcDb_ObjFreeSpace = 0x77e2061f,
		AcDb_Template = 0x4a1404ce,
		AcDb_Handles = 0x3f6e0450,
		AcDb_Classes = 0x3f54045f,
		AcDb_AuxHeader = 0x54f0050a,
		AcDb_Header = 0x32b803d9,
		AcDb_Signature = -0x00000001,
	}
}

<|start_filename|>ACadSharp/Header/SpaceLineTypeScaling.cs<|end_filename|>
﻿namespace ACadSharp.Header
{
	/// <summary>
	/// Controls paper space linetype scaling.
	/// </summary>
	public enum SpaceLineTypeScaling : short
	{
		/// <summary>
		/// Viewport scaling governs linetype scaling.
		/// </summary>
		Viewport = 0,
		/// <summary>
		/// No special linetype scaling.
		/// </summary>
		Normal = 1,
	}
}


<|start_filename|>ACadSharp/Classes/ProxyFlags.cs<|end_filename|>
﻿using System;

namespace ACadSharp.Classes
{
	//https://help.autodesk.com/view/OARX/2021/ENU/?guid=GUID-DBD5351C-E408-4CED-9336-3BD489179EF5

	[Flags]
	public enum ProxyFlags : ushort
	{
		/// <summary>
		/// None.
		/// </summary>
		None = 0,
		/// <summary>
		/// Erase allowed.
		/// </summary>
		EraseAllowed = 1,
		/// <summary>
		/// Transform allowed.
		/// </summary>
		TransformAllowed = 2,
		/// <summary>
		/// Clor change allowed.
		/// </summary>
		ColorChangeAllowed = 4,
		/// <summary>
		/// Layer change allowed.
		/// </summary>
		LayerChangeAllowed = 8,
		/// <summary>
		/// Line type change allowed.
		/// </summary>
		LinetypeChangeAllowed = 16,
		/// <summary>
		/// Line type scale change allowed.
		/// </summary>
		LinetypeScaleChangeAllowed = 32,
		/// <summary>
		/// Visibility change allowed.
		/// </summary>
		VisibilityChangeAllowed = 64,
		/// <summary>
		/// Cloning allowed.
		/// </summary>
		CloningAllowed = 128,
		/// <summary>
		/// Line weight change allowed.
		/// </summary>
		LineweightChangeAllowed = 256,
		/// <summary>
		/// Plot Style Name change allowed.
		/// </summary>
		PlotStyleNameChangeAllowed = 512,
		/// <summary>
		/// All operations except cloning allowed.
		/// </summary>
		AllOperationsExceptCloningAllowed = 895,
		/// <summary>
		/// All operations allowed.
		/// </summary>
		AllOperationsAllowed = 1023,
		/// <summary>
		/// Disables proxy warning dialog.
		/// </summary>
		DisablesProxyWarningDialog = 1024,
		/// <summary>
		/// R13 format proxy.
		/// </summary>
		R13FormatProxy = 32768,
	}
}


<|start_filename|>ACadSharp/Entities/VertexFlags.cs<|end_filename|>
﻿using System;

namespace ACadSharp.Entities
{
	/// <summary>
	/// Defines the vertex flags.
	/// </summary>
	[Flags]
	public enum VertexFlags
	{
		/// <summary>
		/// Default.
		/// </summary>
		Default = 0,
		/// <summary>
		/// Extra vertex created by curve-fitting.
		/// </summary>
		CurveFittingExtraVertex = 1,
		/// <summary>
		/// Curve-fit tangent defined for this vertex.
		/// A curve-fit tangent direction of 0 may be omitted from DXF output but is significant if this bit is set.
		/// </summary>
		CurveFitTangent = 2,
		/// <summary>
		/// Not used.
		/// </summary>
		NotUsed = 4,
		/// <summary>
		/// Spline vertex created by spline-fitting.
		/// </summary>
		SplineVertexFromSplineFitting = 8,
		/// <summary>
		/// Spline frame control point.
		/// </summary>
		SplineFrameControlPoint = 16,
		/// <summary>
		/// 3D polyline vertex.
		/// </summary>
		PolylineVertex3D = 32,
		/// <summary>
		/// 3D polygon mesh.
		/// </summary>
		PolygonMesh3D = 64,
		/// <summary>
		/// Polyface mesh vertex.
		/// </summary>
		PolyfaceMeshVertex = 128
	}
}


<|start_filename|>ACadSharp/IO/DWG/FileHeaders/DwgSectionDefinition.cs<|end_filename|>
﻿using System;
using System.Collections.Generic;

namespace ACadSharp.IO.DWG
{
	internal static class DwgSectionDefinition
	{
		public const string Header = "AcDb:Header";
		public const string Classes = "AcDb:Classes";
		public const string Handles = "AcDb:Handles";
		public const string ObjFreeSpace = "AcDb:ObjFreeSpace";
		public const string Template = "AcDb:Template";
		public const string SummaryInfo = "AcDb:SummaryInfo";
		public const string AcDbObjects = "AcDb:AcDbObjects";
		public const string FileDepList = "AcDb:FileDepList";

		public static Dictionary<string, byte[]> StartSentinels = new Dictionary<string, byte[]>()
		{
			{Header, new byte[16]{ 0xCF, 0x7B, 0x1F, 0x23, 0xFD, 0xDE, 0x38, 0xA9, 0x5F, 0x7C, 0x68, 0xB8, 0x4E, 0x6D, 0x33, 0x5F } },
			{Classes, new byte[16]{ 0x8D,0xA1, 0xC4, 0xB8, 0xC4, 0xA9, 0xF8, 0xC5, 0xC0, 0xDC, 0xF4, 0x5F, 0xE7, 0xCF, 0xB6, 0x8A } },
		};

		public static int GetSectionLocatorByName(string name)
		{
			switch (name)
			{
				case "AcDb:Header":
					return 0;
				case "AcDb:Classes":
					return 1;
				case "AcDb:Handles":
					return 2;
				case "AcDb:ObjFreeSpace":
					return 3;
				case "AcDb:Template":
					return 4;
				//No record id for this sections
				case "AcDb:SummaryInfo":
				case "AcDb:AcDbObjects":
				case "AcDb:FileDepList":
				default:
					return -1;
			}
		}
		public static string GetPageNameByRecordId(int id)
		{
			switch (id)
			{
				case 0:
					return "AcDb:Header";
				default:
					break;
			}

			throw new NotImplementedException();
		}
	}
}

<|start_filename|>ACadSharp/IO/DWG/DwgStreamReaders/CRC32StreamHandler.cs<|end_filename|>
﻿using System.IO;

namespace ACadSharp.IO.DWG
{
	internal class CRC32StreamHandler : Stream
	{
		public override bool CanRead => StreamCRC.CanRead;
		public override bool CanSeek => StreamCRC.CanSeek;
		public override bool CanWrite => StreamCRC.CanWrite;
		public override long Length => StreamCRC.Length;
		public override long Position
		{
			get => StreamCRC.Position;
			set => StreamCRC.Position = value;
		}
		public Stream StreamCRC { get; }
		public uint Seed => ~m_seed;
		private uint m_seed;
		/// <summary>
		/// Constructor that creates a magic sequence given an array of bytes.
		/// </summary>
		/// <param name="arr">Array of 108 bytes</param>
		/// <param name="seed"></param>
		public CRC32StreamHandler(byte[] arr, uint seed)
		{
			int randSeed = 1;

			for (int index = 0; index < arr.Length; ++index)
			{
				randSeed *= 0x343fd;
				randSeed += 0x269ec3;

				byte values = (byte)(randSeed >> 0x10);
				arr[index] = (byte)(arr[index] ^ (uint)values);
			}

			StreamCRC = new MemoryStream(arr);

			m_seed = ~seed;
		}
		public CRC32StreamHandler(Stream stream, uint seed)
		{
			StreamCRC = stream;
			//Reverse the bits
			m_seed = ~seed;
		}
		public override void Flush()
		{
			StreamCRC.Flush();
		}
		public override int Read(byte[] buffer, int offset, int count)
		{
			int nbytes = StreamCRC.Read(buffer, offset, count);
			int length = offset + count;

			for (int index = offset; index < length; ++index)
			{
				m_seed = m_seed >> 8 ^ CRC.Crc32Table[((int)m_seed ^ buffer[index]) & byte.MaxValue];
			}

			return nbytes;
		}
		public override long Seek(long offset, SeekOrigin origin)
		{
			return StreamCRC.Seek(offset, origin);
		}
		public override void SetLength(long value)
		{
			StreamCRC.SetLength(value);
		}
		public override void Write(byte[] buffer, int offset, int count)
		{
			int num = offset + count;

			for (int index = offset; index < num; ++index)
				m_seed = m_seed >> 8 ^ CRC.Crc32Table[((int)m_seed ^ buffer[index]) & byte.MaxValue];

			StreamCRC.Write(buffer, offset, count);
		}
	}
}


<|start_filename|>ACadSharp/Entities/SmoothSurfaceType.cs<|end_filename|>
﻿namespace ACadSharp.Entities
{
	/// <summary>
	/// Curves and smooth surface type.
	/// </summary>
	public enum SmoothSurfaceType : short
	{
		/// <summary>
		/// No smooth surface fitted.
		/// </summary>
		NoSmooth = 0,
		/// <summary>
		/// Quadratic B-spline curve.
		/// </summary>
		Quadratic = 5,
		/// <summary>
		/// Cubic B-spline curve.
		/// </summary>
		Cubic = 6,
		/// <summary>
		/// Bezier surface.
		/// </summary>
		BezierSurface = 8
	}
}


<|start_filename|>ACadSharp/Entities/TextHorizontalAlignment.cs<|end_filename|>
﻿namespace ACadSharp.Entities
{
	public enum TextHorizontalAlignment : short
	{
		Left = 0,
		Center = 1,
		Right = 2,
		/// <summary>
		/// Aligned (if vertical alignment = 0)
		/// </summary>
		Aligned = 3,
		/// <summary>
		/// Middle (if vertical alignment = 0)
		/// </summary>
		Middle = 4,
		/// <summary>
		/// Fit (if vertical alignment = 0)
		/// </summary>
		Fit = 5,
	}
}


<|start_filename|>ACadSharp/Entities/PolylineFlags.cs<|end_filename|>
﻿using System;

namespace ACadSharp.Entities
{
	/// <summary>
	/// Defines the polyline flags.
	/// </summary>
	[Flags]
	public enum PolylineFlags
	{
		/// <summary>
		/// Default, open polyline.
		/// </summary>
		Default = 0,
		/// <summary>
		/// This is a closed polyline (or a polygon mesh closed in the M direction).
		/// </summary>
		ClosedPolylineOrClosedPolygonMeshInM = 1,
		/// <summary>
		/// Curve-fit vertexes have been added.
		/// </summary>
		CurveFit = 2,
		/// <summary>
		/// Spline-fit vertexes have been added.
		/// </summary>
		SplineFit = 4,
		/// <summary>
		/// This is a 3D polyline.
		/// </summary>
		Polyline3D = 8,
		/// <summary>
		/// This is a 3D polygon mesh.
		/// </summary>
		PolygonMesh = 16,
		/// <summary>
		/// The polygon mesh is closed in the N direction.
		/// </summary>
		ClosedPolygonMeshInN = 32,
		/// <summary>
		/// The polyline is a polyface mesh.
		/// </summary>
		PolyfaceMesh = 64,
		/// <summary>
		/// The line type pattern is generated continuously around the vertexes of this polyline.
		/// </summary>
		ContinuousLinetypePattern = 128
	}
}


<|start_filename|>ACadSharp/Entities/ShadowMode.cs<|end_filename|>
﻿namespace ACadSharp.Entities
{
	/// <remarks>
	/// Starting with AutoCAD 2016-based products, this property is obsolete but still supported for backwards compatibility.
	/// </remarks>
	public enum ShadowMode
	{
		CastsAndReceivesShadows = 0,
		CastsShadows = 1,
		ReceivesShadows = 2,
		IgnoresShadows = 3,
	}

}


<|start_filename|>ACadSharp/IO/DWG/FileHeaders/DwgLocalSectionMap.cs<|end_filename|>
﻿namespace ACadSharp.IO.DWG
{
	public class DwgLocalSectionMap
	{
		public bool IsEmpty { get; internal set; }
		public ulong Offset { get; internal set; }
		public ulong CompressedSize { get; internal set; }
		public int PageNumber { get; internal set; }
		public ulong DecompressedSize { get; internal set; }
		public long Seeker { get; internal set; }
		public long Size { get; internal set; }
		public ulong Checksum { get; internal set; }
		public ulong CRC { get; internal set; }
		public long PageSize { get; internal set; }
	}
}

<|start_filename|>ACadSharp/Header/SplineType.cs<|end_filename|>
﻿namespace ACadSharp.Header
{
	/// <summary>
	/// Spline type
	/// </summary>
	public enum SplineType : short
	{
		/// <summary>
		/// None
		/// </summary>
		None = 0,
		/// <summary>
		/// Quadratic B spline
		/// </summary>
		QuadraticBSpline = 5,
		/// <summary>
		/// Cubic B Spline
		/// </summary>
		CubicBSpline = 6,
		/// <summary>
		/// Bezier curve
		/// </summary>
		Bezier = 8,
	}
}


<|start_filename|>ACadSharp/Entities/PolyLine.cs<|end_filename|>
﻿using ACadSharp.Attributes;
using ACadSharp.Entities.Collections;
using ACadSharp.IO.Templates;
using System.Collections.Generic;

namespace ACadSharp.Entities
{
	public class PolyLine : Entity
	{
		//https://help.autodesk.com/view/OARX/2021/ENU/?guid=GUID-ABF6B778-BE20-4B49-9B58-A94E64CEFFF3

		public override ObjectType ObjectType => ObjectType.POLYLINE_2D;    //Shit there is a 3d too...
		public override string ObjectName => DxfFileToken.EntityPolyline;

		/// <summary>
		/// The current elevation of the object.
		/// </summary>
		[DxfCodeValue(DxfCode.ZCoordinate)]
		public double Elevation { get; set; } = 0.0;
		/// <summary>
		/// Specifies the distance a 2D AutoCAD object is extruded above or below its elevation.
		/// </summary>
		[DxfCodeValue(DxfCode.Thickness)]
		public double Thickness { get; set; } = 0.0;
		/// <summary>
		/// 
		/// </summary>
		[DxfCodeValue(DxfCode.Int16)]
		public PolylineFlags Flags { get; set; }
		/// <summary>
		/// 
		/// </summary>
		[DxfCodeValue(DxfCode.StartWith)]
		public double StartWidth { get; set; } = 0.0;
		/// <summary>
		/// 
		/// </summary>
		[DxfCodeValue(DxfCode.EndWith)]
		public double EndWidth { get; set; } = 0.0;

		//71 Polyface mesh vertex index(optional; present only if nonzero)
		//72 Polyface mesh vertex index(optional; present only if nonzero)
		//73 Polyface mesh vertex index(optional; present only if nonzero)
		//74 Polyface mesh vertex index(optional; present only if nonzero)

		[DxfCodeValue(DxfCode.SmoothType)]
		public SmoothSurfaceType SmoothSurface { get; set; }

		/// <summary>
		/// Vertices that form this polyline.
		/// </summary>
		/// <remarks>
		/// Each <see cref="Vertex"/> has it's own unique handle.
		/// </remarks>
		[DxfSubClassEntity(DxfFileToken.EntityVertex)]
		public VertexCollection Vertices { get; set; } = new VertexCollection();
		//public List<Entity> Vertices { get; set; } = new List<Entity>();

		public PolyLine() : base() { }

		internal PolyLine(DxfEntityTemplate template) : base(template) { }
	}
}


<|start_filename|>ACadSharp/Header/ObjectSortingFlags.cs<|end_filename|>
﻿using System;

namespace ACadSharp.Header
{
	/// <summary>
	/// Bitmask flags to set the various object sorting types defined in AutoCAD.
	/// </summary>
	[Flags]
	public enum ObjectSortingFlags : byte
	{
		/// <summary>
		/// Disables SORTENTS.
		/// </summary>
		Disabled = 0,
		/// <summary>
		/// Sorts for object selection.
		/// </summary>
		Selection = 1,
		/// <summary>
		/// Sorts for object snap.
		/// </summary>
		Snap = 2,
		/// <summary>
		/// Sorts for redraws.
		/// </summary>
		Redraw = 4,
		/// <summary>
		/// Sorts for MSLIDE command slide creation.
		/// </summary>
		Slide = 8,
		/// <summary>
		/// Sorts for REGEN commands.
		/// </summary>
		Regen = 16, // 0x10
		/// <summary>
		/// Sorts for plotting.
		/// </summary>
		Plotting = 32, // 0x20
		/// <summary>
		/// Sorts for PostScript output.
		/// </summary>
		Postscript = 64, // 0x40
		/// <summary>
		/// Enable all sorting methods.
		/// </summary>
		All = Postscript | Plotting | Regen | Slide | Redraw | Snap | Selection, // 0x7F
	}
}


<|start_filename|>ACadSharp/IO/DWG/DwgStreamReaders/DwgR21LZ77.cs<|end_filename|>
﻿namespace ACadSharp.IO.DWG
{
	internal static class DwgR21LZ77
	{
		private delegate void copyDelegate(byte[] src, uint srcIndex, byte[] dst, uint dstIndex);

		private static uint m_sourceOffset = 0;
		private static uint m_length = 0;
		private static uint m_sourceIndex;
		private static uint m_opCode = 0;

		/// <summary>
		/// Decompress a compressed source buffer.
		/// </summary>
		/// <param name="source"></param>
		/// <param name="initialOffset"></param>
		/// <param name="length"></param>
		/// <param name="buffer"></param>
		public static void Decompress(byte[] source, uint initialOffset, uint length, byte[] buffer)
		{
			m_sourceOffset = 0;
			m_length = 0;
			m_sourceIndex = initialOffset;
			m_opCode = source[m_sourceIndex];

			uint destIndex = 0;
			uint endIndex = m_sourceIndex + length;

			++m_sourceIndex;

			if (m_sourceIndex >= endIndex)
				return;

			if (((int)m_opCode & 240) == 32)
			{
				m_sourceIndex += 3U;
				m_length = source[m_sourceIndex - 1];
				m_length &= 7U;
			}

			while (m_sourceIndex < endIndex)
			{
				nextIndex(source, buffer, ref destIndex);

				if (m_sourceIndex >= endIndex)
					break;

				destIndex = copyDecompressedChunks(source, endIndex, buffer, destIndex);
			}
		}
		private static void nextIndex(byte[] source, byte[] dest, ref uint index)
		{
			if (m_length == 0U)
				readLiteralLength(source);

			copy(source, m_sourceIndex, dest, index, m_length);

			m_sourceIndex += m_length;

			index += m_length;
		}
		private static uint copyDecompressedChunks(byte[] src, uint endIndex, byte[] dst, uint destIndex)
		{
			m_length = 0U;
			m_opCode = src[m_sourceIndex];
			++m_sourceIndex;

			readInstructions(src);

			while (true)
			{
				copyBytes(dst, destIndex, m_length, m_sourceOffset);

				destIndex += m_length;

				m_length = m_opCode & 0x07;

				if (m_length != 0U || m_sourceIndex >= endIndex)
					break;

				m_opCode = src[m_sourceIndex];
				++m_sourceIndex;

				if (m_opCode >> 4 == 0)
					break;

				if (m_opCode >> 4 == 15)
					m_opCode &= 15;

				readInstructions(src);
			}
			return destIndex;
		}
		private static void readInstructions(byte[] buffer)
		{
			switch (m_opCode >> 4)
			{
				case 0:
					m_length = (m_opCode & 0xF) + 0x13;
					m_sourceOffset = buffer[m_sourceIndex];
					++m_sourceIndex;
					m_opCode = buffer[m_sourceIndex];
					++m_sourceIndex;
					m_length = (m_opCode >> 3 & 0x10) + m_length;
					m_sourceOffset = ((m_opCode & 0x78) << 5) + 1 + m_sourceOffset;
					break;
				case 1:
					m_length = (m_opCode & 0xF) + 3;
					m_sourceOffset = buffer[m_sourceIndex];
					++m_sourceIndex;
					m_opCode = buffer[m_sourceIndex];
					++m_sourceIndex;
					m_sourceOffset = ((m_opCode & 248) << 5) + 1 + m_sourceOffset;
					break;
				case 2:
					m_sourceOffset = buffer[m_sourceIndex];
					++m_sourceIndex;
					m_sourceOffset = (uint)(buffer[m_sourceIndex] << 8 & 0xFF00) | m_sourceOffset;
					++m_sourceIndex;
					m_length = m_opCode & 7U;
					if ((m_opCode & 8) == 0)
					{
						m_opCode = buffer[m_sourceIndex];
						++m_sourceIndex;
						m_length = (m_opCode & 0xF8) + m_length;

					}
					else
					{
						++m_sourceOffset;
						m_length = (uint)((buffer[m_sourceIndex] << 3) + m_length);
						++m_sourceIndex;
						m_opCode = buffer[m_sourceIndex];
						++m_sourceIndex;
						m_length = ((m_opCode & 0xF8) << 8) + m_length + 0x100;
					}
					break;
				default:
					m_length = m_opCode >> 4;
					m_sourceOffset = m_opCode & 15U;
					m_opCode = buffer[m_sourceIndex];
					++m_sourceIndex;
					m_sourceOffset = ((m_opCode & 0xF8) << 1) + m_sourceOffset + 1;
					break;
			}
		}
		private static void readLiteralLength(byte[] buffer)
		{
			m_length = m_opCode + 8;
			if (m_length == 0x17)
			{
				uint n = buffer[m_sourceIndex];
				++m_sourceIndex;
				m_length += n;

				if (n == 0xFF)
				{
					do
					{
						n = buffer[m_sourceIndex];
						++m_sourceIndex;
						n |= (uint)buffer[m_sourceIndex] << 8;
						++m_sourceIndex;
						m_length += n;

					} while (n == 0xFFFF);
				}
			}
		}
		private static void copyBytes(byte[] dst, uint dstIndex, uint length, uint srcOffset)
		{
			uint initialIndex = dstIndex - srcOffset;
			uint maxIndex = initialIndex + length;

			while (initialIndex < maxIndex)
				dst[(int)dstIndex++] = dst[(int)initialIndex++];
		}
		/*
				 * The copying happens in chunks of 32 bytes, 
				 * and the remainder is copied using a specific copy function for each number of bytes 
				 * (so 31 separate copy functions). For copying 1-32 bytes, a combination of sub byte blocks is made:
				 */
		private static readonly copyDelegate[] m_copyMethods = new copyDelegate[32]
{
		null,
		(src, srcIndex, dst, dstIndex) =>{copy1b(src, srcIndex, dst, dstIndex); },
		(src, srcIndex, dst, dstIndex) =>{copy2b(src, srcIndex, dst, dstIndex); },
		(src, srcIndex, dst, dstIndex) =>{copy3b(src, srcIndex, dst, dstIndex); },
		(src, srcIndex, dst, dstIndex) =>{copy4b(src, srcIndex, dst, dstIndex); },
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy1b(src, srcIndex + 4U, dst, dstIndex);
	  copy4b(src, srcIndex, dst, dstIndex + 1U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy1b(src, srcIndex + 5U, dst, dstIndex);
	  copy4b(src, srcIndex + 1U, dst, dstIndex + 1U);
	  copy1b(src, srcIndex, dst, dstIndex + 5U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy2b(src, srcIndex + 5U, dst, dstIndex);
	  copy4b(src, srcIndex + 1U, dst, dstIndex + 2U);
	  copy1b(src, srcIndex, dst, dstIndex + 6U);
	},
	new copyDelegate(copy8b),
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy1b(src, srcIndex + 8U, dst, dstIndex);
	  copy8b(src, srcIndex, dst, dstIndex + 1U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy1b(src, srcIndex + 9U, dst, dstIndex);
	  copy8b(src, srcIndex + 1U, dst, dstIndex + 1U);
	  copy1b(src, srcIndex, dst, dstIndex + 9U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy2b(src, srcIndex + 9U, dst, dstIndex);
	  copy8b(src, srcIndex + 1U, dst, dstIndex + 2U);
	  copy1b(src, srcIndex, dst, dstIndex + 10U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy4b(src, srcIndex + 8U, dst, dstIndex);
	  copy8b(src, srcIndex, dst, dstIndex + 4U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy1b(src, srcIndex + 12U, dst, dstIndex);
	  copy4b(src, srcIndex + 8U, dst, dstIndex + 1U);
	  copy8b(src, srcIndex, dst, dstIndex + 5U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy1b(src, srcIndex + 13U, dst, dstIndex);
	  copy4b(src, srcIndex + 9U, dst, dstIndex + 1U);
	  copy8b(src, srcIndex + 1U, dst, dstIndex + 5U);
	  copy1b(src, srcIndex, dst, dstIndex + 13U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy2b(src, srcIndex + 13U, dst, dstIndex);
	  copy4b(src, srcIndex + 9U, dst, dstIndex + 2U);
	  copy8b(src, srcIndex + 1U, dst, dstIndex + 6U);
	  copy1b(src, srcIndex, dst, dstIndex + 14U);
	},
	new copyDelegate(copy16b),
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy8b(src, srcIndex + 9U, dst, dstIndex);
	  copy1b(src, srcIndex + 8U, dst, dstIndex + 8U);
	  copy8b(src, srcIndex, dst, dstIndex + 9U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy1b(src, srcIndex + 17U, dst, dstIndex);
	  copy16b(src, srcIndex + 1U, dst, dstIndex + 1U);
	  copy1b(src, srcIndex, dst, dstIndex + 17U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy3b(src, srcIndex + 16U, dst, dstIndex);
	  copy16b(src, srcIndex, dst, dstIndex + 3U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy4b(src, srcIndex + 16U, dst, dstIndex);
	  copy8b(src, srcIndex + 8U, dst, dstIndex + 4U);
	  copy8b(src, srcIndex, dst, dstIndex + 12U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy1b(src, srcIndex + 20U, dst, dstIndex);
	  copy4b(src, srcIndex + 16U, dst, dstIndex + 1U);
	  copy8b(src, srcIndex + 8U, dst, dstIndex + 5U);
	  copy8b(src, srcIndex, dst, dstIndex + 13U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy2b(src, srcIndex + 20U, dst, dstIndex);
	  copy4b(src, srcIndex + 16U, dst, dstIndex + 2U);
	  copy8b(src, srcIndex + 8U, dst, dstIndex + 6U);
	  copy8b(src, srcIndex, dst, dstIndex + 14U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy3b(src, srcIndex + 20U, dst, dstIndex);
	  copy4b(src, srcIndex + 16U, dst, dstIndex + 3U);
	  copy8b(src, srcIndex + 8U, dst, dstIndex + 7U);
	  copy8b(src, srcIndex, dst, dstIndex + 15U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy8b(src, srcIndex + 16U, dst, dstIndex);
	  copy16b(src, srcIndex, dst, dstIndex + 8U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy8b(src, srcIndex + 17U, dst, dstIndex);
	  copy1b(src, srcIndex + 16U, dst, dstIndex + 8U);
	  copy16b(src, srcIndex, dst, dstIndex + 9U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy1b(src, srcIndex + 25U, dst, dstIndex);
	  copy8b(src, srcIndex + 17U, dst, dstIndex + 1U);
	  copy1b(src, srcIndex + 16U, dst, dstIndex + 9U);
	  copy16b(src, srcIndex, dst, dstIndex + 10U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy2b(src, srcIndex + 25U, dst, dstIndex);
	  copy8b(src, srcIndex + 17U, dst, dstIndex + 2U);
	  copy1b(src, srcIndex + 16U, dst, dstIndex + 10U);
	  copy16b(src, srcIndex, dst, dstIndex + 11U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy4b(src, srcIndex + 24U, dst, dstIndex);
	  copy8b(src, srcIndex + 16U, dst, dstIndex + 4U);
	  copy8b(src, srcIndex + 8U, dst, dstIndex + 12U);
	  copy8b(src, srcIndex, dst, dstIndex + 20U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy1b(src, srcIndex + 28U, dst, dstIndex);
	  copy4b(src, srcIndex + 24U, dst, dstIndex + 1U);
	  copy8b(src, srcIndex + 16U, dst, dstIndex + 5U);
	  copy8b(src, srcIndex + 8U, dst, dstIndex + 13U);
	  copy8b(src, srcIndex, dst, dstIndex + 21U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy2b(src, srcIndex + 28U, dst, dstIndex);
	  copy4b(src, srcIndex + 24U, dst, dstIndex + 2U);
	  copy8b(src, srcIndex + 16U, dst, dstIndex + 6U);
	  copy8b(src, srcIndex + 8U, dst, dstIndex + 14U);
	  copy8b(src, srcIndex, dst, dstIndex + 22U);
	},
	 (src, srcIndex, dst, dstIndex) =>
	{
	  copy1b(src, srcIndex + 30U, dst, dstIndex);
	  copy4b(src, srcIndex + 26U, dst, dstIndex + 1U);
	  copy8b(src, srcIndex + 18U, dst, dstIndex + 5U);
	  copy8b(src, srcIndex + 10U, dst, dstIndex + 13U);
	  copy8b(src, srcIndex + 2U, dst, dstIndex + 21U);
	  copy2b(src, srcIndex, dst, dstIndex + 29U);
	}
};
		private static void copy(byte[] src, uint srcIndex, byte[] dst, uint dstIndex, uint length)
		{
			for (; length >= 32U; length -= 32U)
			{
				copy4b(src, srcIndex + 24U, dst, dstIndex);
				copy4b(src, srcIndex + 28U, dst, dstIndex + 4U);
				copy4b(src, srcIndex + 16U, dst, dstIndex + 8U);
				copy4b(src, srcIndex + 20U, dst, dstIndex + 12U);
				copy4b(src, srcIndex + 8U, dst, dstIndex + 16U);
				copy4b(src, srcIndex + 12U, dst, dstIndex + 20U);
				copy4b(src, srcIndex, dst, dstIndex + 24U);
				copy4b(src, srcIndex + 4U, dst, dstIndex + 28U);

				srcIndex += 32U;
				dstIndex += 32U;
			}
			if (length <= 0U)
				return;

			m_copyMethods[(int)length](src, srcIndex, dst, dstIndex);
		}
		private static void copy1b(byte[] src, uint srcIndex, byte[] dst, uint dstIndex)
		{
			dst[(int)dstIndex] = src[(int)srcIndex];
		}
		private static void copy2b(byte[] src, uint srcIndex, byte[] dst, uint dstIndex)
		{
			dst[(int)dstIndex] = src[(int)srcIndex + 1];
			dst[(int)dstIndex + 1] = src[(int)srcIndex];
		}
		private static void copy3b(byte[] src, uint srcIndex, byte[] dst, uint dstIndex)
		{
			dst[(int)dstIndex] = src[(int)srcIndex + 2];
			dst[(int)dstIndex + 1] = src[(int)srcIndex + 1];
			dst[(int)dstIndex + 2] = src[(int)srcIndex];
		}
		private static void copy4b(byte[] src, uint srcIndex, byte[] dst, uint dstIndex)
		{
			dst[(int)dstIndex] = src[(int)srcIndex];
			dst[(int)dstIndex + 1] = src[(int)srcIndex + 1];
			dst[(int)dstIndex + 2] = src[(int)srcIndex + 2];
			dst[(int)dstIndex + 3] = src[(int)srcIndex + 3];
		}
		private static void copy8b(byte[] src, uint srcIndex, byte[] dst, uint dstIndex)
		{
			copy4b(src, srcIndex, dst, dstIndex);
			copy4b(src, srcIndex + 4U, dst, dstIndex + 4U);
		}
		private static void copy16b(byte[] src, uint srcIndex, byte[] dst, uint dstIndex)
		{
			copy8b(src, srcIndex + 8U, dst, dstIndex);
			copy8b(src, srcIndex, dst, dstIndex + 8U);
		}
	}
}
