]> Creatis software - gdcm.git/blob - src/gdcmObject.cxx
ENH: Dummy cleanup patch
[gdcm.git] / src / gdcmObject.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmObject.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/07/17 22:47:01 $
7   Version:   $Revision: 1.22 $
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.htm 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 "gdcmObject.h"
20 #include "gdcmGlobal.h"
21 #include "gdcmDebug.h"
22 #include "gdcmValEntry.h"
23
24 //-----------------------------------------------------------------------------
25 /**
26  * \ingroup gdcmObject
27  * \brief  Constructor 
28  *          
29  * @param ptagHT pointer to the HTable (gdcmObject needs it 
30  *               to build the gdcmDocEntries)
31  * @param depth Seaquence depth level
32  */
33   
34 gdcmObject::gdcmObject(TagDocEntryHT *ptagHT, int depth) 
35           : gdcmSQItem (depth) {
36    this->ptagHT = ptagHT;
37 }
38
39
40 /**
41  * \ingroup gdcmObject
42  * \brief   Canonical destructor.
43  */
44 gdcmObject::~gdcmObject(void) {
45 }
46
47
48
49 //-----------------------------------------------------------------------------
50 // Public
51
52
53 /**
54  * \ingroup gdcmObject
55  * \brief   Builds a hash table (multimap) containing 
56  *          pointers to all Header Entries (i.e Dicom Element)
57  *          related to this 'object'
58  * @return
59  */ 
60 TagDocEntryHT gdcmObject::GetEntry(void) {
61    TagDocEntryHT HT;
62    docEntries=GetDocEntries();   
63    for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i) {
64       HT[(*i)->GetKey()]=*i;
65    }
66    return(HT);
67 }
68
69 //-----------------------------------------------------------------------------
70 // Protected
71 /**
72  * \brief   add the 'Object' related Dicom Elements to the listEntries
73  *          of a partially created DICOMDIR
74  */
75 void gdcmObject::FillObject(std::list<gdcmElement> elemList) {
76
77   // FillObject rempli le SQItem qui sera accroche au bon endroit
78
79    std::list<gdcmElement>::iterator it;
80    uint16_t tmpGr,tmpEl;
81    gdcmDictEntry *dictEntry;
82    gdcmValEntry *entry;
83    
84    //gdcmSQItem *s = new gdcmSQItem;
85    
86    // for all the Elements found in they own part of the DicomDir dict.     
87    for(it=elemList.begin();it!=elemList.end();++it)
88    {
89       tmpGr=it->group;
90       tmpEl=it->elem;
91       dictEntry=gdcmGlobal::GetDicts()->GetDefaultPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
92       entry=new gdcmValEntry(dictEntry);
93       entry->SetOffset(0); // just to avoid further missprinting
94       entry->SetValue(it->value);
95
96       // dealing with value length ...
97   
98       if(dictEntry->GetGroup()==0xfffe) 
99       {
100          entry->SetLength(entry->GetValue().length());
101       }
102       else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") ) 
103       {
104          entry->SetLength(4);
105       } 
106       else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") ) 
107       {
108          entry->SetLength(2); 
109       } 
110       else if(dictEntry->GetVR()=="SQ") 
111       {
112          entry->SetLength(0xffffffff);
113       }
114       else
115       {
116          entry->SetLength(entry->GetValue().length()); 
117       }                                
118       AddDocEntry(entry);
119    }   
120 }