GDCM  2.2.6
gdcmElement.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: GDCM (Grassroots DICOM). A DICOM library
4 
5  Copyright (c) 2006-2011 Mathieu Malaterre
6  All rights reserved.
7  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 #ifndef GDCMELEMENT_H
15 #define GDCMELEMENT_H
16 
17 #include "gdcmTypes.h"
18 #include "gdcmVR.h"
19 #include "gdcmTag.h"
20 #include "gdcmVM.h"
21 #include "gdcmByteValue.h"
22 #include "gdcmDataElement.h"
23 #include "gdcmSwapper.h"
24 
25 #include <string>
26 #include <vector>
27 #include <sstream>
28 #include <limits>
29 #include <cmath>
30 #include <cstring>
31 
32 namespace gdcm
33 {
34 
35 // Forward declaration
41 template<int T> class EncodingImplementation;
42 
43 
51 template <int TVR, int TVM>
53 template <>
55 template <>
57 // Make it impossible to compile these other cases
58 template <int TVM>
59 class ElementDisableCombinations<VR::OB, TVM>;
60 template <int TVM>
61 class ElementDisableCombinations<VR::OW, TVM>;
62 
68 template<int TVR, int TVM>
69 class Element
70 {
71  enum { ElementDisableCombinationsCheck = sizeof ( ElementDisableCombinations<TVR, TVM> ) };
72 public:
74  typedef typename VRToType<TVR>::Type Type;
75 
76  static VR GetVR() { return (VR::VRType)TVR; }
77  static VM GetVM() { return (VM::VMType)TVM; }
78 
79  unsigned long GetLength() const {
81  }
82  // Implementation of Print is common to all Mode (ASCII/Binary)
83  // TODO: Can we print a \ when in ASCII...well I don't think so
84  // it would mean we used a bad VM then, right ?
85  void Print(std::ostream &_os) const {
86  _os << Internal[0]; // VM is at least garantee to be one
87  for(int i=1; i<VMToLength<TVM>::Length; ++i)
88  _os << "," << Internal[i];
89  }
90 
91  const typename VRToType<TVR>::Type *GetValues() const {
92  return Internal;
93  }
94  const typename VRToType<TVR>::Type &GetValue(unsigned int idx = 0) const {
95  assert( idx < VMToLength<TVM>::Length );
96  return Internal[idx];
97  }
98  typename VRToType<TVR>::Type &GetValue(unsigned int idx = 0) {
99  assert( idx < VMToLength<TVM>::Length );
100  return Internal[idx];
101  }
102  typename VRToType<TVR>::Type operator[] (unsigned int idx) const {
103  return GetValue(idx);
104  }
105  void SetValue(typename VRToType<TVR>::Type v, unsigned int idx = 0) {
106  assert( idx < VMToLength<TVM>::Length );
107  Internal[idx] = v;
108  }
109 
110  void SetFromDataElement(DataElement const &de) {
111  const ByteValue *bv = de.GetByteValue();
112  if( !bv ) return;
113 #ifdef GDCM_WORDS_BIGENDIAN
114  if( de.GetVR() == VR::UN /*|| de.GetVR() == VR::INVALID*/ )
115 #else
116  if( de.GetVR() == VR::UN || de.GetVR() == VR::INVALID )
117 #endif
118  {
119  Set(de.GetValue());
120  }
121  else
122  {
123  SetNoSwap(de.GetValue());
124  }
125  }
126 
128  DataElement ret;
129  std::ostringstream os;
131  GetLength(),os);
132  ret.SetVR( (VR::VRType)TVR );
133  assert( ret.GetVR() != VR::SQ );
135  {
136  if( GetVR() != VR::UI )
137  {
138  if( os.str().size() % 2 )
139  {
140  os << " ";
141  }
142  }
143  }
144  VL::Type osStrSize = (VL::Type)os.str().size();
145  ret.SetByteValue( os.str().c_str(), osStrSize );
146 
147  return ret;
148  }
149 
150  void Read(std::istream &_is) {
151  return EncodingImplementation<VRToEncoding<TVR>::Mode>::Read(Internal,
152  GetLength(),_is);
153  }
154  void Write(std::ostream &_os) const {
155  return EncodingImplementation<VRToEncoding<TVR>::Mode>::Write(Internal,
156  GetLength(),_os);
157  }
158 
159  // FIXME: remove this function
160  // this is only used in gdcm::SplitMosaicFilter / to pass value of a CSAElement
161  void Set(Value const &v) {
162  const ByteValue *bv = dynamic_cast<const ByteValue*>(&v);
163  if( bv ) {
164  //memcpy(Internal, bv->GetPointer(), bv->GetLength());
165  std::stringstream ss;
166  std::string s = std::string( bv->GetPointer(), bv->GetLength() );
167  ss.str( s );
169  GetLength(),ss);
170  }
171  }
172 protected:
173  void SetNoSwap(Value const &v) {
174  const ByteValue *bv = dynamic_cast<const ByteValue*>(&v);
175  assert( bv ); // That would be bad...
176  //memcpy(Internal, bv->GetPointer(), bv->GetLength());
177  std::stringstream ss;
178  std::string s = std::string( bv->GetPointer(), bv->GetLength() );
179  ss.str( s );
181  GetLength(),ss);
182  }
183 };
184 
185 struct ignore_char {
186  ignore_char(char c): m_char(c) {}
187  char m_char;
188 };
189 ignore_char const backslash('\\');
190 
191  inline std::istream& operator>> (std::istream& in, ignore_char const& ic) {
192  if (!in.eof())
193  in.clear(in.rdstate() & ~std::ios_base::failbit);
194  if (in.get() != ic.m_char)
195  in.setstate(std::ios_base::failbit);
196  return in;
197  }
198 
199 
200 // Implementation to perform formatted read and write
201 template<> class EncodingImplementation<VR::VRASCII> {
202 public:
203  template<typename T> // FIXME this should be VRToType<TVR>::Type
204  static inline void ReadComputeLength(T* data, unsigned int &length,
205  std::istream &_is) {
206  assert( data );
207  //assert( length ); // != 0
208  length = 0;
209  assert( _is );
210 #if 0
211  char sep;
212  while( _is >> data[length++] )
213  {
214  // Get the separator in between the values
215  assert( _is );
216  _is.get(sep);
217  assert( sep == '\\' || sep == ' ' ); // FIXME: Bad use of assert
218  if( sep == ' ' ) length--; // FIXME
219  }
220 #else
221  while( _is >> std::ws >> data[length++] >> std::ws >> backslash )
222  {
223  }
224 #endif
225  }
226 
227  template<typename T> // FIXME this should be VRToType<TVR>::Type
228  static inline void Read(T* data, unsigned long length,
229  std::istream &_is) {
230  assert( data );
231  assert( length ); // != 0
232  assert( _is );
233  // FIXME BUG: what if >> operation fails ?
234  // gdcmData/MR00010001.dcm / SpacingBetweenSlices
235  _is >> std::ws >> data[0];
236  char sep;
237  //std::cout << "GetLength: " << af->GetLength() << std::endl;
238  for(unsigned long i=1; i<length;++i) {
239  assert( _is );
240  // Get the separator in between the values
241  _is >> std::ws >> sep; //_is.get(sep);
242  assert( sep == '\\' ); // FIXME: Bad use of assert
243  _is >> std::ws >> data[i];
244  }
245  }
246 
247  template<typename T>
248  static inline void ReadNoSwap(T* data, unsigned long length,
249  std::istream &_is) {
250  Read(data,length,_is);
251 }
252  template<typename T>
253  static inline void Write(const T* data, unsigned long length,
254  std::ostream &_os) {
255  assert( data );
256  assert( length );
257  assert( _os );
258  _os << data[0];
259  for(unsigned long i=1; i<length; ++i) {
260  assert( _os );
261  _os << "\\" << data[i];
262  }
263  }
264 };
265 
266 template < typename Float >
267 std::string to_string ( Float data ) {
268  std::stringstream in;
269  // in.imbue(std::locale::classic()); // This is not required AFAIK
270  int const digits =
271  static_cast< int >(
272  - std::log( std::numeric_limits<Float>::epsilon() )
273  / std::log( 10.0 ) );
274  if ( in << std::dec << std::setprecision(/*2+*/digits) << data ) {
275  return ( in.str() );
276  } else {
277  throw "Impossible Conversion"; // should not happen ...
278  }
279 }
280 
281 /* Writing VR::DS is not that easy after all */
282 // http://groups.google.com/group/comp.lang.c++/browse_thread/thread/69ccd26f000a0802
283 template<> inline void EncodingImplementation<VR::VRASCII>::Write(const float * data, unsigned long length, std::ostream &_os) {
284  assert( data );
285  assert( length );
286  assert( _os );
287  _os << to_string(data[0]);
288  for(unsigned long i=1; i<length; ++i) {
289  assert( _os );
290  _os << "\\" << to_string(data[i]);
291  }
292  }
293 
294 template<> inline void EncodingImplementation<VR::VRASCII>::Write(const double* data, unsigned long length, std::ostream &_os) {
295  assert( data );
296  assert( length );
297  assert( _os );
298  _os << to_string(data[0]);
299  for(unsigned long i=1; i<length; ++i) {
300  assert( _os );
301  _os << "\\" << to_string(data[i]);
302  }
303  }
304 
305 
306 // Implementation to perform binary read and write
307 // TODO rewrite operation so that either:
308 // #1. dummy implementation use a pointer to Internal and do ++p (faster)
309 // #2. Actually do some meta programming to unroll the loop
310 // (no notion of order in VM ...)
311 template<> class EncodingImplementation<VR::VRBINARY> {
312 public:
313  template<typename T> // FIXME this should be VRToType<TVR>::Type
314  static inline void ReadComputeLength(T* data, unsigned int &length,
315  std::istream &_is) {
316  const unsigned int type_size = sizeof(T);
317  assert( data ); // Can we read from pointer ?
318  //assert( length );
319  length /= type_size;
320  assert( _is ); // Is stream valid ?
321  _is.read( reinterpret_cast<char*>(data+0), type_size);
322  for(unsigned long i=1; i<length; ++i) {
323  assert( _is );
324  _is.read( reinterpret_cast<char*>(data+i), type_size );
325  }
326  }
327  template<typename T>
328  static inline void ReadNoSwap(T* data, unsigned long length,
329  std::istream &_is) {
330  const unsigned int type_size = sizeof(T);
331  assert( data ); // Can we read from pointer ?
332  assert( length );
333  assert( _is ); // Is stream valid ?
334  _is.read( reinterpret_cast<char*>(data+0), type_size);
335  for(unsigned long i=1; i<length; ++i) {
336  assert( _is );
337  _is.read( reinterpret_cast<char*>(data+i), type_size );
338  }
339  //ByteSwap<T>::SwapRangeFromSwapCodeIntoSystem(data,
340  // _is.GetSwapCode(), length);
341  //SwapperNoOp::SwapArray(data,length);
342  }
343  template<typename T>
344  static inline void Read(T* data, unsigned long length,
345  std::istream &_is) {
346  const unsigned int type_size = sizeof(T);
347  assert( data ); // Can we read from pointer ?
348  assert( length );
349  assert( _is ); // Is stream valid ?
350  _is.read( reinterpret_cast<char*>(data+0), type_size);
351  for(unsigned long i=1; i<length; ++i) {
352  assert( _is );
353  _is.read( reinterpret_cast<char*>(data+i), type_size );
354  }
355  //ByteSwap<T>::SwapRangeFromSwapCodeIntoSystem(data,
356  // _is.GetSwapCode(), length);
357  SwapperNoOp::SwapArray(data,length);
358  }
359  template<typename T>
360  static inline void Write(const T* data, unsigned long length,
361  std::ostream &_os) {
362  const unsigned int type_size = sizeof(T);
363  assert( data ); // Can we write into pointer ?
364  assert( length );
365  assert( _os ); // Is stream valid ?
366  //ByteSwap<T>::SwapRangeFromSwapCodeIntoSystem((T*)data,
367  // _os.GetSwapCode(), length);
368  T swappedData = SwapperNoOp::Swap(data[0]);
369  _os.write( reinterpret_cast<const char*>(&swappedData), type_size);
370  for(unsigned long i=1; i<length;++i) {
371  assert( _os );
372  swappedData = SwapperNoOp::Swap(data[i]);
373  _os.write( reinterpret_cast<const char*>(&swappedData), type_size );
374  }
375  //ByteSwap<T>::SwapRangeFromSwapCodeIntoSystem((T*)data,
376  // _os.GetSwapCode(), length);
377  }
378 };
379 
380 // For particular case for ASCII string
381 // WARNING: This template explicitely instanciates a particular
382 // EncodingImplementation THEREFORE it is required to be declared after the
383 // EncodingImplementation is needs (doh!)
384 #if 0
385 template<int TVM>
386 class Element<TVM>
387 {
388 public:
389  Element(const char array[])
390  {
391  unsigned int i = 0;
392  const char sep = '\\';
393  std::string sarray = array;
394  std::string::size_type pos1 = 0;
395  std::string::size_type pos2 = sarray.find(sep, pos1+1);
396  while(pos2 != std::string::npos)
397  {
398  Internal[i++] = sarray.substr(pos1, pos2-pos1);
399  pos1 = pos2+1;
400  pos2 = sarray.find(sep, pos1+1);
401  }
402  Internal[i] = sarray.substr(pos1, pos2-pos1);
403  // Shouldn't we do the contrary, since we know how many separators
404  // (and default behavior is to discard anything after the VM declared
405  assert( GetLength()-1 == i );
406  }
407 
408  unsigned long GetLength() const {
409  return VMToLength<TVM>::Length;
410  }
411  // Implementation of Print is common to all Mode (ASCII/Binary)
412  void Print(std::ostream &_os) const {
413  _os << Internal[0]; // VM is at least garantee to be one
414  for(int i=1; i<VMToLength<TVM>::Length; ++i)
415  _os << "," << Internal[i];
416  }
417 
418  void Read(std::istream &_is) {
419  EncodingImplementation<VR::VRASCII>::Read(Internal, GetLength(),_is);
420  }
421  void Write(std::ostream &_os) const {
422  EncodingImplementation<VR::VRASCII>::Write(Internal, GetLength(),_os);
423  }
424 private:
425  typename String Internal[VMToLength<TVM>::Length];
426 };
427 
428 template< int TVM>
429 class Element<VR::PN, TVM> : public StringElement<TVM>
430 {
431  enum { ElementDisableCombinationsCheck = sizeof ( ElementDisableCombinations<VR::PN, TVM> ) };
432 };
433 #endif
434 
435 // Implementation for the undefined length (dynamically allocated array)
436 template<int TVR>
437 class Element<TVR, VM::VM1_n>
438 {
439  enum { ElementDisableCombinationsCheck = sizeof ( ElementDisableCombinations<TVR, VM::VM1_n> ) };
440 public:
441  // This the way to prevent default initialization
442  explicit Element() { Internal=0; Length=0; Save = false; }
444  if( Save ) {
445  delete[] Internal;
446  }
447  Internal = 0;
448  }
449 
450  static VR GetVR() { return (VR::VRType)TVR; }
451  static VM GetVM() { return VM::VM1_n; }
452 
453  // Length manipulation
454  // SetLength should really be protected anyway...all operation
455  // should go through SetArray
456  unsigned long GetLength() const { return Length; }
457  typedef typename VRToType<TVR>::Type Type;
458 
459  void SetLength(unsigned long len) {
460  const unsigned int size = sizeof(Type);
461  if( len ) {
462  if( len > Length ) {
463  // perform realloc
464  assert( (len / size) * size == len );
465  Type *internal = new Type[len / size];
466  assert( Save == false );
467  Save = true; // ????
468  if( Internal )
469  {
470  memcpy(internal, Internal, len);
471  delete[] Internal;
472  }
473  Internal = internal;
474  }
475  }
476  Length = len / size;
477  }
478 
479  // If save is set to zero user should not delete the pointer
480  //void SetArray(const typename VRToType<TVR>::Type *array, int len, bool save = false)
481  void SetArray(const Type *array, unsigned long len,
482  bool save = false) {
483  if( save ) {
484  SetLength(len); // realloc
485  memcpy(Internal, array, len/*/sizeof(Type)*/);
486  assert( Save == false );
487  }
488  else {
489  // TODO rewrite this stupid code:
490  assert( Length == 0 );
491  assert( Internal == 0 );
492  assert( Save == false );
493  Length = len / sizeof(Type);
494  //assert( (len / sizeof(Type)) * sizeof(Type) == len );
495  // MR00010001.dcm is a tough kid: 0019,105a is supposed to be VR::FL, VM::VM3 but
496  // length is 14 bytes instead of 12 bytes. Simply consider value is total garbage.
497  if( (len / sizeof(Type)) * sizeof(Type) != len ) { Internal = 0; Length = 0; }
498  else Internal = const_cast<Type*>(array);
499  }
500  Save = save;
501  }
502  void SetValue(typename VRToType<TVR>::Type v, unsigned int idx = 0) {
503  assert( idx < Length );
504  Internal[idx] = v;
505  }
506  const typename VRToType<TVR>::Type &GetValue(unsigned int idx = 0) const {
507  assert( idx < Length );
508  return Internal[idx];
509  }
510  typename VRToType<TVR>::Type &GetValue(unsigned int idx = 0) {
511  assert( idx < Length );
512  return Internal[idx];
513  }
514  typename VRToType<TVR>::Type operator[] (unsigned int idx) const {
515  return GetValue(idx);
516  }
517  void Set(Value const &v) {
518  const ByteValue *bv = dynamic_cast<const ByteValue*>(&v);
519  assert( bv ); // That would be bad...
521  {
522  const Type* array = (Type*)bv->GetPointer();
523  if( array ) {
524  assert( array ); // That would be bad...
525  assert( Internal == 0 );
526  SetArray(array, bv->GetLength() ); }
527  }
528  else
529  {
530  std::stringstream ss;
531  std::string s = std::string( bv->GetPointer(), bv->GetLength() );
532  ss.str( s );
534  GetLength(),ss);
535  }
536  }
537  void SetFromDataElement(DataElement const &de) {
538  const ByteValue *bv = de.GetByteValue();
539  if( !bv ) return;
540 #ifdef GDCM_WORDS_BIGENDIAN
541  if( de.GetVR() == VR::UN /*|| de.GetVR() == VR::INVALID*/ )
542 #else
543  if( de.GetVR() == VR::UN || de.GetVR() == VR::INVALID )
544 #endif
545  {
546  Set(de.GetValue());
547  }
548  else
549  {
550  SetNoSwap(de.GetValue());
551  }
552  }
553 
554 
555  // Need to be placed after definition of EncodingImplementation<VR::VRASCII>
556  void WriteASCII(std::ostream &os) const {
557  return EncodingImplementation<VR::VRASCII>::Write(Internal, GetLength(), os);
558  }
559 
560  // Implementation of Print is common to all Mode (ASCII/Binary)
561  void Print(std::ostream &_os) const {
562  assert( Length );
563  assert( Internal );
564  _os << Internal[0]; // VM is at least garantee to be one
565  const unsigned long length = GetLength() < 25 ? GetLength() : 25;
566  for(unsigned long i=1; i<length; ++i)
567  _os << "," << Internal[i];
568  }
569  void Read(std::istream &_is) {
570  if( !Internal ) return;
572  GetLength(),_is);
573  }
574  //void ReadComputeLength(std::istream &_is) {
575  // if( !Internal ) return;
576  // EncodingImplementation<VRToEncoding<TVR>::Mode>::ReadComputeLength(Internal,
577  // Length,_is);
578  // }
579  void Write(std::ostream &_os) const {
581  GetLength(),_os);
582  }
583 
585  DataElement ret;
586  ret.SetVR( (VR::VRType)TVR );
587  assert( ret.GetVR() != VR::SQ );
588  if( Internal )
589  {
590  std::ostringstream os;
592  GetLength(),os);
594  {
595  if( GetVR() != VR::UI )
596  {
597  if( os.str().size() % 2 )
598  {
599  os << " ";
600  }
601  }
602  }
603  VL::Type osStrSize = (VL::Type)os.str().size();
604  ret.SetByteValue( os.str().c_str(), osStrSize );
605  }
606  return ret;
607  }
608 
609  Element(const Element&_val) {
610  if( this != &_val) {
611  *this = _val;
612  }
613  }
614 
615  Element &operator=(const Element &_val) {
616  Length = 0; // SYITF
617  Internal = 0;
618  SetArray(_val.Internal, _val.Length, true);
619  return *this;
620  }
621 protected:
622  void SetNoSwap(Value const &v) {
623  const ByteValue *bv = dynamic_cast<const ByteValue*>(&v);
624  assert( bv ); // That would be bad...
626  {
627  const Type* array = (Type*)bv->GetPointer();
628  if( array ) {
629  assert( array ); // That would be bad...
630  assert( Internal == 0 );
631  SetArray(array, bv->GetLength() ); }
632  }
633  else
634  {
635  std::stringstream ss;
636  std::string s = std::string( bv->GetPointer(), bv->GetLength() );
637  ss.str( s );
639  GetLength(),ss);
640  }
641  }
642 
643 private:
644  typename VRToType<TVR>::Type *Internal;
645  unsigned long Length; // unsigned int ??
646  bool Save;
647 };
648 
649 //template <int TVM = VM::VM1_n>
650 //class Element<VR::OB, TVM > : public Element<VR::OB, VM::VM1_n> {};
651 
652 // Partial specialization for derivatives of 1-n : 2-n, 3-n ...
653 template<int TVR>
654 class Element<TVR, VM::VM1_2> : public Element<TVR, VM::VM1_n>
655 {
656 public:
658  void SetLength(int len) {
659  if( len != 1 || len != 2 ) return;
660  Parent::SetLength(len);
661  }
662 };
663 template<int TVR>
664 class Element<TVR, VM::VM2_n> : public Element<TVR, VM::VM1_n>
665 {
666  enum { ElementDisableCombinationsCheck = sizeof ( ElementDisableCombinations<TVR, VM::VM2_n> ) };
667 public:
669  void SetLength(int len) {
670  if( len <= 1 ) return;
671  Parent::SetLength(len);
672  }
673 };
674 template<int TVR>
675 class Element<TVR, VM::VM2_2n> : public Element<TVR, VM::VM2_n>
676 {
677  enum { ElementDisableCombinationsCheck = sizeof ( ElementDisableCombinations<TVR, VM::VM2_2n> ) };
678 public:
680  void SetLength(int len) {
681  if( len % 2 ) return;
682  Parent::SetLength(len);
683  }
684 };
685 template<int TVR>
686 class Element<TVR, VM::VM3_n> : public Element<TVR, VM::VM1_n>
687 {
688  enum { ElementDisableCombinationsCheck = sizeof ( ElementDisableCombinations<TVR, VM::VM3_n> ) };
689 public:
691  void SetLength(int len) {
692  if( len <= 2 ) return;
693  Parent::SetLength(len);
694  }
695 };
696 template<int TVR>
697 class Element<TVR, VM::VM3_3n> : public Element<TVR, VM::VM3_n>
698 {
699  enum { ElementDisableCombinationsCheck = sizeof ( ElementDisableCombinations<TVR, VM::VM3_3n> ) };
700 public:
702  void SetLength(int len) {
703  if( len % 3 ) return;
704  Parent::SetLength(len);
705  }
706 };
707 
708 
709 //template<int T> struct VRToLength;
710 //template <> struct VRToLength<VR::AS>
711 //{ enum { Length = VM::VM1 }; }
712 //template<>
713 //class Element<VR::AS> : public Element<VR::AS, VRToLength<VR::AS>::Length >
714 
715 // only 0010 1010 AS 1 Patient's Age
716 template<>
717 class Element<VR::AS, VM::VM5>
718 {
719  enum { ElementDisableCombinationsCheck = sizeof ( ElementDisableCombinations<VR::AS, VM::VM5> ) };
720 public:
722  void Print(std::ostream &_os) const {
723  _os << Internal;
724  }
725  unsigned long GetLength() const {
727  }
728 };
729 
730 
731 template <>
732 class Element<VR::OB, VM::VM1> : public Element<VR::OB, VM::VM1_n> {};
733 
734 // Same for OW:
735 template <>
736 class Element<VR::OW, VM::VM1> : public Element<VR::OW, VM::VM1_n> {};
737 
738 
739 } // namespace gdcm
740 
741 #endif //GDCMELEMENT_H
void SetVR(VR const &vr)
Definition: gdcmDataElement.h:88
Element(const Element &_val)
Definition: gdcmElement.h:609
Definition: gdcmVR.h:93
unsigned long GetLength() const
Definition: gdcmElement.h:725
static void Read(T *data, unsigned long length, std::istream &_is)
Definition: gdcmElement.h:228
void SetByteValue(const char *array, VL length)
Definition: gdcmDataElement.h:123
Definition: gdcmVR.h:59
Definition: gdcmVR.h:223
void Print(std::ostream &_os) const
Definition: gdcmElement.h:85
void SetLength(int len)
Definition: gdcmElement.h:702
void SetLength(int len)
Definition: gdcmElement.h:680
VRType
Definition: gdcmVR.h:57
void SetNoSwap(Value const &v)
Definition: gdcmElement.h:622
void SetValue(typename VRToType< TVR >::Type v, unsigned int idx=0)
Definition: gdcmElement.h:105
unsigned long GetLength() const
Definition: gdcmElement.h:79
char m_char
Definition: gdcmElement.h:187
VRBINARY
Definition: gdcmVR.h:283
void Write(std::ostream &_os) const
Definition: gdcmElement.h:154
Definition: gdcmVR.h:225
Class to represent the value of a Data Element.
Definition: gdcmValue.h:29
VRToType< TVR >::Type & GetValue(unsigned int idx=0)
Definition: gdcmElement.h:98
void SetLength(unsigned long len)
Definition: gdcmElement.h:459
VL GetLength() const
Definition: gdcmByteValue.h:76
const VRToType< TVR >::Type * GetValues() const
Definition: gdcmElement.h:91
Element< TVR, VM::VM1_n > Parent
Definition: gdcmElement.h:690
void SetLength(int len)
Definition: gdcmElement.h:691
unsigned long GetLength() const
Definition: gdcmElement.h:456
void Read(std::istream &_is)
Definition: gdcmElement.h:569
std::istream & operator>>(std::istream &is, String< TDelimiter, TMaxLength, TPadChar > &ms)
Definition: gdcmString.h:117
Definition: gdcmVR.h:78
static T Swap(T val)
Definition: gdcmSwapper.h:49
Definition: gdcmElement.h:185
static void Write(const T *data, unsigned long length, std::ostream &_os)
Definition: gdcmElement.h:360
void SetNoSwap(Value const &v)
Definition: gdcmElement.h:173
static void Read(T *data, unsigned long length, std::istream &_is)
Definition: gdcmElement.h:344
A class which is used to produce compile errors for an invalid combination of template parameters...
Definition: gdcmElement.h:52
std::string to_string(Float data)
Definition: gdcmElement.h:267
void SetFromDataElement(DataElement const &de)
Definition: gdcmElement.h:537
Element class.
Definition: gdcmElement.h:69
Definition: gdcmElement.h:686
const ByteValue * GetByteValue() const
Definition: gdcmDataElement.h:130
Definition: gdcmElement.h:437
Definition: gdcmElement.h:664
static void SwapArray(T *, size_t)
Definition: gdcmSwapper.h:50
DataElement GetAsDataElement() const
Definition: gdcmElement.h:584
void SetFromDataElement(DataElement const &de)
Definition: gdcmElement.h:110
Definition: gdcmVM.h:98
Class to represent a Data Element either Implicit or Explicit.
Definition: gdcmDataElement.h:58
Class to represent binary value (array of bytes)
Definition: gdcmByteValue.h:33
void Write(std::ostream &_os) const
Definition: gdcmElement.h:579
Element< TVR, VM::VM2_n > Parent
Definition: gdcmElement.h:679
~Element()
Definition: gdcmElement.h:443
void WriteASCII(std::ostream &os) const
Definition: gdcmElement.h:556
static void Write(const T *data, unsigned long length, std::ostream &_os)
Definition: gdcmElement.h:253
VR const & GetVR() const
Definition: gdcmDataElement.h:84
Value Multiplicity Looking at the DICOMV3 dict only there is very few cases: 1 2 3 4 5 6 8 16 24 1-2 ...
Definition: gdcmVM.h:67
static void ReadComputeLength(T *data, unsigned int &length, std::istream &_is)
Definition: gdcmElement.h:204
static VR GetVR()
Definition: gdcmElement.h:76
Value const & GetValue() const
Set/Get Value (bytes array, SQ of items, SQ of fragments):
Definition: gdcmDataElement.h:94
ignore_char const backslash('\\')
Definition: gdcmVR.h:94
static void ReadNoSwap(T *data, unsigned long length, std::istream &_is)
Definition: gdcmElement.h:248
void Print(std::ostream &_os) const
Definition: gdcmElement.h:561
void Set(Value const &v)
Definition: gdcmElement.h:161
Definition: gdcmVM.h:154
Element & operator=(const Element &_val)
Definition: gdcmElement.h:615
void SetLength(int len)
Definition: gdcmElement.h:669
Element< TVR, VM::VM1_n > Parent
Definition: gdcmElement.h:657
const VRToType< TVR >::Type & GetValue(unsigned int idx=0) const
Definition: gdcmElement.h:506
void SetValue(typename VRToType< TVR >::Type v, unsigned int idx=0)
Definition: gdcmElement.h:502
VRToType< TVR >::Type & GetValue(unsigned int idx=0)
Definition: gdcmElement.h:510
Element< TVR, VM::VM3_n > Parent
Definition: gdcmElement.h:701
void SetArray(const Type *array, unsigned long len, bool save=false)
Definition: gdcmElement.h:481
void Read(std::istream &_is)
Definition: gdcmElement.h:150
VRToType< TVR >::Type Type
Definition: gdcmElement.h:74
DataElement GetAsDataElement() const
Definition: gdcmElement.h:127
EncodingImplementation.
Definition: gdcmElement.h:41
void Print(std::ostream &_os) const
Definition: gdcmElement.h:722
const char * GetPointer() const
Definition: gdcmByteValue.h:138
static void ReadNoSwap(T *data, unsigned long length, std::istream &_is)
Definition: gdcmElement.h:328
void SetLength(int len)
Definition: gdcmElement.h:658
Definition: gdcmVR.h:84
ignore_char(char c)
Definition: gdcmElement.h:186
static void ReadComputeLength(T *data, unsigned int &length, std::istream &_is)
Definition: gdcmElement.h:314
static VM GetVM()
Definition: gdcmElement.h:77
void Set(Value const &v)
Definition: gdcmElement.h:517
Definition: gdcmVM.h:76
VR class This is adapted from DICOM standard The biggest difference is the INVALID VR and the composi...
Definition: gdcmVR.h:54
Element()
Definition: gdcmElement.h:442
VRToType< TVR >::Type Type
Definition: gdcmElement.h:457
VMType
Definition: gdcmVM.h:70
static VR GetVR()
Definition: gdcmElement.h:450
Definition: gdcmVM.h:72
Definition: gdcmVR.h:82
static VM GetVM()
Definition: gdcmElement.h:451
uint32_t Type
Definition: gdcmVL.h:32
Element< TVR, VM::VM1_n > Parent
Definition: gdcmElement.h:668
const VRToType< TVR >::Type & GetValue(unsigned int idx=0) const
Definition: gdcmElement.h:94

Generated on Sat Dec 21 2013 05:56:17 for GDCM by doxygen 1.8.5
SourceForge.net Logo