]> Creatis software - gdcm.git/blob - src/gdcmObject.cxx
73172ae2238d9cb8880422cb309345e3696fe576
[gdcm.git] / src / gdcmObject.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmObject.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/06/20 18:08:48 $
7   Version:   $Revision: 1.20 $
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  * \ingroup gdcmObject
71  * \brief   Builds a Chained List containing 
72  *          pointers to all Header Entries (i.e Dicom Element)
73  *          related to this 'object'
74  * @return
75  */
76  
77  // FIXME : what was it used for ?!?
78  /* 
79 ListTag gdcmObject::GetListEntry(void) {
80    return(GetDocEntries());
81 }
82 */
83
84 //-----------------------------------------------------------------------------
85 // Protected
86 /**
87  * \ingroup gdcmObject
88  * \brief   add the 'Object' related Dicom Elements to the listEntries
89  *          of a partially created DICOMDIR
90  */
91 void gdcmObject::FillObject(std::list<gdcmElement> elemList) {
92
93   // FillObject rempli le SQItem qui sera accroche au bon endroit
94
95    std::list<gdcmElement>::iterator it;
96    guint16 tmpGr,tmpEl;
97    gdcmDictEntry *dictEntry;
98    gdcmValEntry *entry;
99    
100    //gdcmSQItem *s = new gdcmSQItem;
101    
102    // for all the Elements found in they own part of the DicomDir dict.     
103    for(it=elemList.begin();it!=elemList.end();++it)
104    {
105       tmpGr=it->group;
106       tmpEl=it->elem;
107       dictEntry=gdcmGlobal::GetDicts()->GetDefaultPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
108       entry=new gdcmValEntry(dictEntry);
109       entry->SetOffset(0); // just to avoid further missprinting
110       entry->SetValue(it->value);
111
112       // dealing with value length ...
113   
114       if(dictEntry->GetGroup()==0xfffe) 
115          {
116             entry->SetLength(entry->GetValue().length());        
117          }
118       else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") ) 
119          {
120             entry->SetLength(4);
121          } 
122       else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") ) 
123          {
124             entry->SetLength(2); 
125          } 
126       else if(dictEntry->GetVR()=="SQ") 
127          {
128             entry->SetLength(0xffffffff);
129          }
130       else
131          {
132             entry->SetLength(entry->GetValue().length()); 
133          }                                
134       //docEntries->insert(debInsertion ,entry); // ??? // add at the begining of the Patient list
135       AddDocEntry(entry);                                  
136    }   
137 }   
138 //-----------------------------------------------------------------------------
139 // Private
140
141 //-----------------------------------------------------------------------------