]> Creatis software - gdcm.git/blob - src/gdcmObject.cxx
Sub-minor std-related fixes... Jpr+Frog
[gdcm.git] / src / gdcmObject.cxx
1 // gdcmObject.cxx
2 //-----------------------------------------------------------------------------
3 #include "gdcmObject.h"
4 #include "gdcmGlobal.h"
5 #include "gdcmDebug.h"
6 #include "gdcmValEntry.h"
7
8 //-----------------------------------------------------------------------------
9 /**
10  * \ingroup gdcmObject
11  * \brief  Constructor 
12  *          
13  * @param ptagHT pointer to the HTable (gdcmObject needs it 
14  *               to build the gdcmDocEntries)
15  * @param depth Seaquence depth level
16  */
17   
18 gdcmObject::gdcmObject(TagDocEntryHT *ptagHT, int depth) 
19           : gdcmSQItem (depth) {
20    this->ptagHT = ptagHT;
21 }
22
23
24 /**
25  * \ingroup gdcmObject
26  * \brief   Canonical destructor.
27  */
28 gdcmObject::~gdcmObject(void) {
29 }
30
31
32
33 //-----------------------------------------------------------------------------
34 // Public
35
36
37 /**
38  * \ingroup gdcmObject
39  * \brief   Builds a hash table (multimap) containing 
40  *          pointers to all Header Entries (i.e Dicom Element)
41  *          related to this 'object'
42  * @return
43  */ 
44 TagDocEntryHT gdcmObject::GetEntry(void) {
45    TagDocEntryHT HT;
46    docEntries=GetDocEntries();   
47    for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i) {
48       HT[(*i)->GetKey()]=*i;
49    }
50    return(HT);
51 }
52
53 /**
54  * \ingroup gdcmObject
55  * \brief   Builds a Chained List containing 
56  *          pointers to all Header Entries (i.e Dicom Element)
57  *          related to this 'object'
58  * @return
59  */
60  
61  // FIXME : what was it used for ?!?
62  /* 
63 ListTag gdcmObject::GetListEntry(void) {
64    return(GetDocEntries());
65 }
66 */
67
68 //-----------------------------------------------------------------------------
69 // Protected
70 /**
71  * \ingroup gdcmObject
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    guint16 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       //docEntries->insert(debInsertion ,entry); // ??? // add at the begining of the Patient list
119       AddDocEntry(entry);                                  
120    }   
121 }   
122 //-----------------------------------------------------------------------------
123 // Private
124
125 //-----------------------------------------------------------------------------