File: DefaultPrivateDicts.xsl

package info (click to toggle)
gdcm 2.4.4-3%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 32,912 kB
  • ctags: 52,166
  • sloc: cpp: 188,527; ansic: 124,526; xml: 41,799; sh: 7,162; python: 3,667; cs: 2,128; java: 1,344; lex: 1,290; tcl: 677; php: 128; makefile: 116
file content (351 lines) | stat: -rw-r--r-- 13,762 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="text" indent="yes"/>
<!-- share common code to transform a VM Part 6 string into a gdcm::VM type
-->
<!--
  Program: GDCM (Grassroots DICOM). A DICOM library

  Copyright (c) 2006-2011 Mathieu Malaterre
  All rights reserved.
  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.
-->
  <xsl:include href="VM.xsl"/>
<!-- The main template that loop over all dict/entry -->
  <xsl:key name="entries" match="entry" use="@group"/>
  <xsl:template match="/">
    <xsl:text>
// GENERATED FILE DO NOT EDIT
// $ xsltproc DefaultPrivateDicts.xsl privatedicts.xml &gt; gdcmPrivateDefaultDicts.cxx

/*=========================================================================

  Program: GDCM (Grassroots DICOM). A DICOM library

  Copyright (c) 2006-2011 Mathieu Malaterre
  All rights reserved.
  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/

#ifndef GDCMDEFAULTDICTS_CXX
#define GDCMDEFAULTDICTS_CXX

#include "gdcmDicts.h"
#include "gdcmVR.h"
#include "gdcmDict.h"
#include "gdcmDictEntry.h"

namespace gdcm {
typedef struct
{
  uint16_t group;
  uint16_t element;
  const char *owner;
  VR::VRType vr;
  VM::VMType vm;
  const char *name;
  bool ret;
} DICT_ENTRY;

static const DICT_ENTRY DICOMV3DataDict [] = {
</xsl:text>
    <xsl:for-each select="dict/entry">
      <xsl:variable name="group" select="translate(@group,'x','0')"/>
      <xsl:variable name="element" select="translate(@element,'x','0')"/>
      <xsl:choose>
        <xsl:when test="substring(@group,3) != 'xx' and substring(@element,3) = 'xx' and substring(@element,1,2) != '00' and substring(@element,1,2) != '10'">
          <xsl:call-template name="do-one-entry">
            <xsl:with-param name="count" select="0"/>
            <xsl:with-param name="do-element" select="1"/>
            <xsl:with-param name="group" select="@group"/>
            <xsl:with-param name="element" select="$element"/>
            <!--xsl:with-param name="owner" select="@owner"/-->
            <xsl:with-param name="vr" select="@vr"/>
            <xsl:with-param name="vm" select="@vm"/>
            <xsl:with-param name="retired" select="@retired"/>
            <xsl:with-param name="name" select="@name"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:when test="substring(@group,3) = 'xx' and contains(@element,'x') = false ">
          <xsl:call-template name="do-one-entry">
            <xsl:with-param name="count" select="0"/>
            <xsl:with-param name="do-group" select="1"/>
            <xsl:with-param name="group" select="$group"/>
            <xsl:with-param name="element" select="@element"/>
            <!--xsl:with-param name="owner" select="@owner"/-->
            <xsl:with-param name="vr" select="@vr"/>
            <xsl:with-param name="vm" select="@vm"/>
            <xsl:with-param name="retired" select="@retired"/>
            <xsl:with-param name="name" select="@name"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:when test="contains(@group,'x') = false and contains(@element,'x') = false">
          <xsl:call-template name="do-one-entry">
            <xsl:with-param name="count" select="255"/>
            <xsl:with-param name="group" select="@group"/>
            <xsl:with-param name="element" select="@element"/>
            <!--xsl:with-param name="owner" select="@owner"/-->
            <xsl:with-param name="vr" select="@vr"/>
            <xsl:with-param name="vm" select="@vm"/>
            <xsl:with-param name="retired" select="@retired"/>
            <xsl:with-param name="name" select="@name"/>
          </xsl:call-template>
        </xsl:when>
        <!-- Private element e.g (0019,xx26) -->
        <xsl:when test="contains(@group,'x') = false and substring(@element,1,2) = 'xx' and not(contains(substring(@element,3,4),'x'))">
          <xsl:call-template name="do-one-entry">
            <xsl:with-param name="count" select="255"/>
            <xsl:with-param name="group" select="@group"/>
            <xsl:with-param name="element" select="$element"/> <!-- replaced xx with 00 which is what we want -->
            <xsl:with-param name="owner" select="@owner"/>
            <xsl:with-param name="vr" select="@vr"/>
            <xsl:with-param name="vm" select="@vm"/>
            <xsl:with-param name="retired" select="@retired"/>
            <xsl:with-param name="name" select="@name"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:when test="contains(@group,'x') = false and @element = '00xx'">
          <xsl:call-template name="do-one-entry">
            <xsl:with-param name="count" select="255"/>
            <xsl:with-param name="group" select="@group"/>
            <xsl:with-param name="element" select="$element"/>
            <xsl:with-param name="owner" select="@owner"/>
            <xsl:with-param name="vr" select="@vr"/>
            <xsl:with-param name="vm" select="@vm"/>
            <xsl:with-param name="retired" select="@retired"/>
            <xsl:with-param name="name" select="@name"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:message>Problem with element:(<xsl:value-of select="@group"/>,<xsl:value-of select="@element"/>)
</xsl:message>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>
    <xsl:for-each select="//entry[generate-id() = generate-id(key('entries',@group)[1])]">
<!--
Note: We need to produce generic group length for all known groups but 0000 and 0002 since they have there own
already

Implementation note:
generating group length for arbitrary even group number seems to get my xsltproc on its knees
-->
      <xsl:if test="contains(@group,'x') = false and @group!='0000' and @group!='0002'">
        <xsl:call-template name="do-one-entry">
          <xsl:with-param name="count" select="0"/>
          <xsl:with-param name="group" select="@group"/>
          <xsl:with-param name="element" select="'0000'"/>
          <xsl:with-param name="vr" select="'UL'"/>
          <xsl:with-param name="vm" select="'1'"/>
          <xsl:with-param name="owner" select="@owner"/>
          <xsl:with-param name="retired" select="'true'"/>
          <xsl:with-param name="name" select="concat('Group Length ',@group)"/>
        </xsl:call-template>
      </xsl:if>
    </xsl:for-each>
    <xsl:text>
  {0xffff,0xffff,0,VR::INVALID,VM::VM0,0,true } // Gard
};

void Dict::LoadDefault()
{
   unsigned int i = 0;
   DICT_ENTRY n = DICOMV3DataDict[i];
   while( n.name != 0 )
   {
   if( n.group % 2 == 0 )
     {
     assert( n.owner == 0 );
     Tag t(n.group, n.element);
     DictEntry e( n.name, n.vr, n.vm, n.ret );
     AddDictEntry( t, e );
     }
     n = DICOMV3DataDict[++i];
   }
}

void PrivateDict::LoadDefault()
{
   unsigned int i = 0;
   DICT_ENTRY n = DICOMV3DataDict[i];
   while( n.name != 0 )
   {
   if( n.group % 2 != 0 )
     {
     assert( n.owner != 0 );
     PrivateTag t(n.group, n.element,n.owner);
     DictEntry e( n.name, n.vr, n.vm, n.ret );
     AddDictEntry( t, e );
     }
     n = DICOMV3DataDict[++i];
   }
}

} // end namespace gdcm
#endif // GDCMDEFAULTDICTS_CXX
</xsl:text>
  </xsl:template>
  <xsl:template name="do-group-length">
    <xsl:param name="count" select="0"/>
    <xsl:if test="$count &lt; 65535">
<!-- 0xffff -->
      <xsl:variable name="group-length">
        <xsl:call-template name="printHex">
          <xsl:with-param name="number" select="$count"/>
        </xsl:call-template>
      </xsl:variable>
<!--xsl:call-template name="do-one-entry">
        <xsl:with-param name="count" select="0"/>
        <xsl:with-param name="group" select="$group-length"/>
        <xsl:with-param name="element" select="'0000'"/>
        <xsl:with-param name="vr" select="'UL'"/>
        <xsl:with-param name="vm" select="'1'"/>
      </xsl:call-template-->
      <xsl:call-template name="do-group-length">
        <xsl:with-param name="count" select="$count + 2"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
  <xsl:template name="do-one-entry">
    <xsl:param name="count" select="0"/>
    <xsl:param name="do-group" select="0"/>
    <xsl:param name="do-element" select="0"/>
    <xsl:param name="group"/>
    <xsl:param name="element"/>
    <xsl:param name="owner" select="''"/>
    <xsl:param name="vr"/>
    <xsl:param name="vm"/>
    <xsl:param name="retired"/>
    <xsl:param name="name"/>
    <xsl:if test="$count &lt; 256">
      <xsl:text>  {0x</xsl:text>
      <xsl:value-of select="$group"/>
      <xsl:text>,0x</xsl:text>
      <xsl:value-of select="$element"/>
      <xsl:text>,"</xsl:text>
      <xsl:value-of select="$owner"/>
      <xsl:text>"</xsl:text>
<!--xsl:value-of select="$temp"/-->
      <xsl:text>,VR::</xsl:text>
      <xsl:if test="not ($vr != '')">
<!-- FIXME -->
        <xsl:text>INVALID</xsl:text>
      </xsl:if>
      <xsl:if test="$vr != ''">
        <xsl:value-of select="$vr"/>
      </xsl:if>
      <xsl:text>,VM::</xsl:text>
      <xsl:call-template name="VMStringToVMType">
        <xsl:with-param name="vmstring" select="$vm"/>
      </xsl:call-template>
      <xsl:text>,"</xsl:text>
      <xsl:value-of select="$name"/>
      <xsl:text>",</xsl:text>
      <xsl:value-of select="$retired = 'true'"/>
      <xsl:text> },</xsl:text>
      <xsl:text>
</xsl:text>
    </xsl:if>
    <xsl:if test="$count &lt; 255">
<!--xsl:message><xsl:value-of select="$do-group"/></xsl:message-->
      <xsl:if test="$do-group != '0'">
        <xsl:variable name="temp">
          <xsl:call-template name="printHex">
            <xsl:with-param name="number" select="$count + 2"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="tail">
          <xsl:if test="string-length($temp) != 1">
            <xsl:value-of select="$temp"/>
          </xsl:if>
          <xsl:if test="string-length($temp) = 1">
            <xsl:value-of select="concat('0',$temp)"/>
          </xsl:if>
        </xsl:variable>
        <xsl:variable name="group_xx" select="concat(substring($group,1,2),$tail)"/>
        <xsl:call-template name="do-one-entry">
          <xsl:with-param name="count" select="$count + 2"/>
          <xsl:with-param name="do-group" select="$do-group"/>
          <xsl:with-param name="do-element" select="$do-element"/>
          <xsl:with-param name="group" select="$group_xx"/>
          <xsl:with-param name="element" select="$element"/>
          <xsl:with-param name="vr" select="$vr"/>
          <xsl:with-param name="vm" select="$vm"/>
          <xsl:with-param name="owner" select="$owner"/>
          <xsl:with-param name="retired" select="$retired"/>
          <xsl:with-param name="name" select="$name"/>
        </xsl:call-template>
      </xsl:if>
      <xsl:if test="$do-element != '0'">
        <xsl:variable name="temp">
          <xsl:call-template name="printHex">
            <xsl:with-param name="number" select="$count + 1"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="tail">
          <xsl:if test="string-length($temp) != 1">
            <xsl:value-of select="$temp"/>
          </xsl:if>
          <xsl:if test="string-length($temp) = 1">
            <xsl:value-of select="concat('0',$temp)"/>
          </xsl:if>
        </xsl:variable>
        <xsl:variable name="element_xx" select="concat(substring($element,1,2),$tail)"/>
        <xsl:call-template name="do-one-entry">
          <xsl:with-param name="count" select="$count + 1"/>
          <xsl:with-param name="do-group" select="$do-group"/>
          <xsl:with-param name="do-element" select="$do-element"/>
          <xsl:with-param name="group" select="$group"/>
          <xsl:with-param name="element" select="$element_xx"/>
          <xsl:with-param name="vr" select="$vr"/>
          <xsl:with-param name="vm" select="$vm"/>
          <xsl:with-param name="owner" select="$owner"/>
          <xsl:with-param name="retired" select="$retired"/>
          <xsl:with-param name="name" select="$name"/>
        </xsl:call-template>
      </xsl:if>
    </xsl:if>
  </xsl:template>
<!-- A function to convert a decimal into an hex -->
  <xsl:template name="printHex">
    <xsl:param name="number">0</xsl:param>
    <xsl:variable name="low">
      <xsl:value-of select="$number mod 16"/>
    </xsl:variable>
    <xsl:variable name="high">
      <xsl:value-of select="floor($number div 16)"/>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="$high &gt; 0">
        <xsl:call-template name="printHex">
          <xsl:with-param name="number">
            <xsl:value-of select="$high"/>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:when>
<!--<xsl:otherwise>
      <xsl:text>0x</xsl:text>
    </xsl:otherwise>-->
    </xsl:choose>
    <xsl:choose>
      <xsl:when test="$low &lt; 10">
        <xsl:value-of select="format-number($low,&quot;0&quot;)"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:variable name="temp">
          <xsl:value-of select="$low - 10"/>
        </xsl:variable>
        <xsl:value-of select="translate($temp, '012345', 'abcdef')"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>