]> Creatis software - gdcm.git/blob - src/gdcmDicomDirObject.cxx
* Test/TestUtil.cxx : reformat the source code
[gdcm.git] / src / gdcmDicomDirObject.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDirObject.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/12/07 13:39:33 $
7   Version:   $Revision: 1.12 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 #include "gdcmDicomDirObject.h"
20 #include "gdcmGlobal.h"
21 #include "gdcmDebug.h"
22 #include "gdcmValEntry.h"
23 #include "gdcmDictSet.h"
24
25 namespace gdcm 
26 {
27
28 //-----------------------------------------------------------------------------
29 /**
30  * \ingroup DicomDirObject
31  * \brief  Constructor 
32  *          
33  * @param ptagHT pointer to the HTable (DicomDirObject needs it 
34  *               to build the DocEntries)
35  * @param depth Sequence depth level
36  */
37   
38 DicomDirObject::DicomDirObject(int depth) 
39           : SQItem (depth)
40 {
41 }
42
43
44 /**
45  * \ingroup DicomDirObject
46  * \brief   Canonical destructor.
47  */
48 DicomDirObject::~DicomDirObject()
49 {
50 }
51
52
53
54 //-----------------------------------------------------------------------------
55 // Public
56
57
58 /**
59  * \ingroup DicomDirObject
60  * \brief   Builds a hash table (multimap) containing 
61  *          pointers to all Header Entries (i.e Dicom Element)
62  *          related to this 'object'
63  * @return
64  */ 
65 TagDocEntryHT DicomDirObject::GetEntry()
66 {
67    TagDocEntryHT HT;
68    DocEntries = GetDocEntries();   
69    for(ListDocEntry::iterator i = DocEntries.begin(); 
70                               i != DocEntries.end(); ++i)
71    {
72       HT[(*i)->GetKey()] = *i;
73    }
74    return HT;
75 }
76
77 //-----------------------------------------------------------------------------
78 // Protected
79 /**
80  * \brief   add the 'Object' related Dicom Elements to the listEntries
81  *          of a partially created DICOMDIR
82  */
83 void DicomDirObject::FillObject(ListDicomDirMetaElem const & elemList)
84 {
85   // FillObject rempli le SQItem qui sera accroche au bon endroit
86
87    ListDicomDirMetaElem::const_iterator it;
88    uint16_t tmpGr,tmpEl;
89    DictEntry *dictEntry;
90    ValEntry *entry;
91       
92    // for all the Elements found in they own part of the DicomDir dict.     
93    for(it = elemList.begin(); it != elemList.end(); ++it)
94    {
95       tmpGr = it->Group;
96       tmpEl = it->Elem;
97       dictEntry = Global::GetDicts()->GetDefaultPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
98       entry = new ValEntry(dictEntry);
99       entry->SetOffset(0); // just to avoid further missprinting
100       entry->SetValue(it->Value);
101
102       AddEntry(entry);
103    }   
104 }   
105 } // end namespace gdcm
106