~ubuntu-branches/ubuntu/utopic/ginkgocadx/utopic-proposed

« back to all changes in this revision

Viewing changes to src/cadxcore/api/controllers/ipacscontroller.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2014-01-09 07:37:09 UTC
  • mfrom: (1.2.3)
  • Revision ID: package-import@ubuntu.com-20140109073709-rpuh5x3p3finvtze
Tags: 3.6.0.1228.33+dfsg-1
New upstream release [December 2013]

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#undef verify
19
19
#endif
20
20
#include <api/controllers/ipacscontroller.h>
21
 
#include "dcmtk/dcmdata/dcdict.h"
22
 
#include <dcmtk/dcmdata/dctk.h>
23
 
#include "dcmtk/dcmimgle/dcmimage.h"
24
21
 
25
22
#ifdef MACRO_QUE_ESTORBA
26
23
#define verify MACRO_QUE_ESTORBA
27
24
#endif
28
25
 
 
26
GIL::DICOM::PACSException::PACSException(const std::string& msg, const std::string& component, bool fatal) throw() : GNC::GCS::IException(msg, component, fatal)
 
27
{
 
28
}
 
29
 
 
30
GIL::DICOM::IPACSController::IPACSController()
 
31
{
 
32
}
 
33
 
29
34
GIL::DICOM::IPACSController::~IPACSController()
30
35
{
31
36
}
32
37
 
33
 
namespace GIL {
34
 
        namespace DICOM {
35
 
 
36
 
 
37
 
                /*------------------------------*/
38
 
                DcmElement* TagPrivadoString::ToElement(unsigned int group, unsigned int element)
39
 
                {
40
 
                        OFCondition cond;
41
 
                        DcmVR vr(EVR_LT);
42
 
                        DcmTagKey key(group,element);
43
 
                        DcmTag tag(key,vr);
44
 
                        if (tag.error() != EC_Normal) {
45
 
                                std::cerr << "error al almacenar los tags privados, tag desconocido: (" << group << ","<<element<<")" <<std::endl;
46
 
                                return NULL;
47
 
                        }
48
 
 
49
 
                        DcmElement* pElement = newDicomElement(tag);
50
 
 
51
 
                        if(pElement==NULL){
52
 
                                std::cerr << "error al almacenar los tags privados, error al crear el elemento: (" << group << ","<<element<<") " <<std::endl;
53
 
                                return NULL;
54
 
                        }
55
 
 
56
 
                        cond=pElement->putString(Valor.c_str());
57
 
                        
58
 
                        if (cond.bad()) {
59
 
                                std::cerr << "error al almacenar los tags privados, error al escribir los datos: (" << group << ","<<element<<")" << cond.text() <<std::endl;
60
 
                                return NULL;
61
 
                        }
62
 
 
63
 
                        return pElement;
64
 
                }
65
 
                /*------------------------------*/
66
 
                TagPrivadoUndefined::TagPrivadoUndefined()
67
 
                {
68
 
                        Valor = NULL;
69
 
                        Size = 0;
70
 
                }
71
 
 
72
 
                TagPrivadoUndefined::TagPrivadoUndefined(unsigned int size)
73
 
                {
74
 
                        Size = size;
75
 
                        Valor = new unsigned char[Size];
76
 
                }
77
 
 
78
 
                TagPrivadoUndefined::TagPrivadoUndefined(unsigned char* valor, unsigned int size)
79
 
                {
80
 
                        Size = size;
81
 
                        Valor = new unsigned char[Size];
82
 
                        memcpy(Valor,valor,Size*sizeof(unsigned char));
83
 
                }
84
 
 
85
 
                TagPrivadoUndefined::~TagPrivadoUndefined() 
86
 
                {
87
 
                        if (Valor != NULL) {
88
 
                                delete [] Valor;
89
 
                        }
90
 
                        Valor = NULL;
91
 
                        Size = 0;
92
 
                }
93
 
 
94
 
                TagPrivadoUndefined::TagPrivadoUndefined(const TagPrivadoUndefined& otro) 
95
 
                {
96
 
                        this->Size = otro.Size;
97
 
                        this->Valor = new unsigned char[Size];
98
 
                        memcpy(otro.Valor,this->Valor,Size*sizeof(unsigned char));
99
 
                }
100
 
 
101
 
                TagPrivadoUndefined& TagPrivadoUndefined::operator = (const TagPrivadoUndefined& otro) 
102
 
                {
103
 
                        this->Size = otro.Size;
104
 
                        this->Valor = new unsigned char[Size];
105
 
                        memcpy(otro.Valor,this->Valor,Size*sizeof(unsigned char));
106
 
                        return *this;
107
 
                }
108
 
 
109
 
                void TagPrivadoUndefined::Copiar(void* ptrCopia, int size) 
110
 
                {
111
 
                        if(this->Valor != NULL) {
112
 
                                delete[] this->Valor;
113
 
                        }
114
 
                        this->Size = size;
115
 
                        this->Valor = new unsigned char [Size];
116
 
                        memcpy(this->Valor,ptrCopia,Size*sizeof(unsigned char));
117
 
                }
118
 
 
119
 
                std::string TagPrivadoUndefined::ToString() 
120
 
                {
121
 
                        return std::string ((char*)Valor,Size);
122
 
                }
123
 
 
124
 
                unsigned char* TagPrivadoUndefined::GetValor()
125
 
                {
126
 
                        return Valor;
127
 
                }
128
 
 
129
 
                unsigned int TagPrivadoUndefined::GetSize()
130
 
                {
131
 
                        return Size;
132
 
                }
133
 
 
134
 
                DcmElement* TagPrivadoUndefined::ToElement(unsigned int group, unsigned int element)
135
 
                {
136
 
                        OFCondition cond;
137
 
                        DcmVR vr(EVR_UN);
138
 
                        DcmTagKey key(group,element);
139
 
                        DcmTag tag(key,vr);
140
 
                        if (tag.error() != EC_Normal) {
141
 
                                std::cerr << "error al almacenar los tags privados, tag desconocido: (" << group << ","<<element<<")" <<std::endl;
142
 
                                return NULL;
143
 
                        }
144
 
 
145
 
                        DcmElement* pElement = newDicomElement(tag);
146
 
 
147
 
                        if(pElement==NULL){
148
 
                                std::cerr << "error al almacenar los tags privados, error al crear el elemento: (" << group << ","<<element<<")" <<std::endl;
149
 
                                return NULL;
150
 
                        }
151
 
 
152
 
                        cond=pElement->putUint8Array(Valor,Size);
153
 
                        
154
 
                        if (cond.bad()) {
155
 
                                std::cerr << "error al almacenar los tags privados, error al escribir los datos: (" << group << ","<<element<<")" <<std::endl;
156
 
                                return NULL;
157
 
                        }
158
 
 
159
 
                        return pElement;
160
 
                }
161
 
        }
162
 
}
163