dcmtkpp
BasicDirectoryCreator.h
1 /*************************************************************************
2  * dcmtkpp - Copyright (C) Universite de Strasbourg
3  * Distributed under the terms of the CeCILL-B license, as published by
4  * the CEA-CNRS-INRIA. Refer to the LICENSE file or to
5  * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
6  * for details.
7  ************************************************************************/
8 
9 #ifndef _8836a563_24f6_4afb_89ba_377d49ce9f5d
10 #define _8836a563_24f6_4afb_89ba_377d49ce9f5d
11 
12 #include <map>
13 #include <memory>
14 #include <string>
15 #include <utility>
16 #include <vector>
17 
18 #include "dcmtkpp/DataSet.h"
19 #include "dcmtkpp/Tag.h"
20 #include "dcmtkpp/Writer.h"
21 
22 namespace dcmtkpp
23 {
24 
27 {
28 public:
29  typedef std::pair<Tag, int> RecordKey;
30 
32  static std::map<std::string, std::vector<RecordKey>> const default_record_keys;
33 
40  std::string root;
41 
47  std::vector<std::string> files;
48 
50  std::map<std::string, std::vector<RecordKey>> extra_record_keys;
51 
54 
56  std::string const & root="",
57  std::vector<std::string> const & files=std::vector<std::string>(),
58  std::map<std::string, std::vector<RecordKey>> const & extra_record_keys=
59  std::map<std::string, std::vector<RecordKey>>(),
60  Writer::ItemEncoding item_encoding=Writer::ItemEncoding::ExplicitLength
61  );
62 
63  void operator()() const;
64 
65 private:
66  struct Record
67  {
68  typedef std::shared_ptr<Record> Pointer;
69  DataSet data_set;
70  std::map<std::string, Record::Pointer> children;
71  };
72 
73  struct LinearizedTree
74  {
75  std::vector<Record::Pointer> records;
76  std::vector<long> sibling;
77  std::vector<long> child;
78  };
79 
80  typedef std::map<std::string, Record::Pointer> RecordMap;
81 
83  std::map<std::string, Record::Pointer> _create_records() const;
84 
86  Record & _find_record(RecordMap & records, std::string const & key) const;
87 
89  void _fill_record(
90  DataSet const & data_set, Record & record,
91  std::string const & type) const;
92 
94  void _update_record(
95  DataSet const & data_set, Record & record,
96  std::vector<RecordKey> const & keys) const;
97 
99  LinearizedTree _linearize_records(RecordMap const & record_tree) const;
100 
102  std::vector<std::streampos> _get_relative_offsets(
103  std::vector<Record::Pointer> const & records) const;
104 
106  void _write(
107  LinearizedTree const & linearized_tree,
108  std::vector<std::streampos> const & relative_offsets) const;
109 };
110 
111 }
112 
113 #endif // _8836a563_24f6_4afb_89ba_377d49ce9f5d
Definition: Association.cpp:22
std::vector< std::string > files
Path to the DICOM files, relative to root.
Definition: BasicDirectoryCreator.h:47
ItemEncoding
Encodings of sequence items.
Definition: Writer.h:29
std::string root
Root of the DICOM files and location of the output DICOMDIR file.
Definition: BasicDirectoryCreator.h:40
std::map< std::string, std::vector< RecordKey > > extra_record_keys
User-defined record keys, classified by record type.
Definition: BasicDirectoryCreator.h:50
static std::map< std::string, std::vector< RecordKey > > const default_record_keys
Default record keys, classified by record type.
Definition: BasicDirectoryCreator.h:32
DICOM Data set.
Definition: DataSet.h:66
Write a Basic Directory (i.e. DICOMDIR) object to the disk.
Definition: BasicDirectoryCreator.h:26
Writer::ItemEncoding item_encoding
Encoding of sequence items, defaults to Writer::ItemEncoding::ExplicitLength.
Definition: BasicDirectoryCreator.h:53