- }
- //if (e == 0x0000) { // elem 0x0000 --> group length
- if ( (vr == "UL") || (vr == "US") || (vr == "SL") || (vr == "SS") ) {
- if (v == "4294967295") // to avoid troubles in convertion
- sprintf (st," x(ffffffff)");
- else {
- if ( GetLength() !=0 )
- sprintf(st," x(%x)", atoi(v.c_str()));//FIXME
- else
- sprintf(st," ");
+
+ uint16_t z = 0;
+ uint16_t shortLgr = lgr;
+
+ if (vr == "unkn")
+ {
+ // Unknown was 'written'
+ // deal with Little Endian
+ binary_write(*fp, shortLgr);
+ binary_write(*fp, z);
+ }
+ else
+ {
+ binary_write(*fp, vr);
+ assert( vr.size() == 2 );
+
+ if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") || (vr == "UN") )
+ {
+ binary_write(*fp, z);
+ if (vr == "SQ")
+ {
+ // we set SQ length to ffffffff
+ // and we shall write a Sequence Delimitor Item
+ // at the end of the Sequence!
+ binary_write(*fp, ffff);
+ }
+ else
+ {
+ binary_write(*fp, lgr);
+ }
+ }
+ else
+ {
+ binary_write(*fp, shortLgr);
+ }
+ }
+ }
+ else // IMPLICIT VR
+ {
+ if (vr == "SQ")
+ {
+ binary_write(*fp, ffff);
+ }
+ else
+ {
+ binary_write(*fp, lgr);