PageRenderTime 52ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/DICOM/DicomFragmentSequence.cs

https://github.com/petnet/fo-dicom
C# | 70 lines | 57 code | 13 blank | 0 comment | 4 complexity | afd560478e4ff679f48bf0e5d99403da MD5 | raw file
Possible License(s): BSD-3-Clause
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Dicom.IO;
  6. using Dicom.IO.Buffer;
  7. namespace Dicom {
  8. public abstract class DicomFragmentSequence : DicomItem, IEnumerable<IByteBuffer> {
  9. private IList<uint> _offsetTable;
  10. private IList<IByteBuffer> _fragments;
  11. protected DicomFragmentSequence(DicomTag tag) : base(tag) {
  12. _fragments = new List<IByteBuffer>();
  13. }
  14. public IList<uint> OffsetTable {
  15. get {
  16. if (_offsetTable == null)
  17. _offsetTable = new List<uint>();
  18. return _offsetTable;
  19. }
  20. }
  21. public IList<IByteBuffer> Fragments {
  22. get { return _fragments; }
  23. }
  24. internal void Add(IByteBuffer fragment) {
  25. if (_offsetTable == null) {
  26. var en = ByteBufferEnumerator<uint>.Create(fragment);
  27. _offsetTable = new List<uint>(en);
  28. return;
  29. }
  30. _fragments.Add(fragment);
  31. }
  32. public IEnumerator<IByteBuffer> GetEnumerator() {
  33. return _fragments.GetEnumerator();
  34. }
  35. System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
  36. return _fragments.GetEnumerator();
  37. }
  38. }
  39. public abstract class DicomFragmentSequenceT<T> : DicomFragmentSequence {
  40. protected DicomFragmentSequenceT(DicomTag tag) : base(tag) {
  41. }
  42. }
  43. public class DicomOtherByteFragment : DicomFragmentSequenceT<byte> {
  44. public DicomOtherByteFragment(DicomTag tag) : base(tag) {
  45. }
  46. public override DicomVR ValueRepresentation {
  47. get { return DicomVR.OB; }
  48. }
  49. }
  50. public class DicomOtherWordFragment : DicomFragmentSequenceT<ushort> {
  51. public DicomOtherWordFragment(DicomTag tag) : base(tag) {
  52. }
  53. public override DicomVR ValueRepresentation {
  54. get { return DicomVR.OW; }
  55. }
  56. }
  57. }