Open dgobbi opened 6 years ago
Of course, it would be better to report precision loss at compile time. For example, GDCM uses a template to map tags to VRs and from there to type and encoding: 'DS' has type 'double' and encoding 'ascii'. Philosophically, this is very different from vtk-dicom where the dictionary is simply a data structure. Architecturally, vtk-dicom uses metaprogramming only in its implementation, never in its interface.
The vtkDICOMValue class has AsInt(), AsDouble(), AsString() etc. methods for extracting the value of a DICOM data element. This extraction can result in loss of precision. For example:
Of course, the only lossless way to extract 'DS' is with AsString(), but that is not useful when the value is to be used as a number.
For each VR, each conversion can be characterized as:
Whenever a conversion is not exact, it might be good to have a warning produced at runtime if the code is compiled in debug mode. The signed/unsigned is tricky because sometimes DICOM is hazy on 'US' vs. 'SS', e.g. for implicit VR it can depend on PixelRepresentation. Also, the first/third values in the lookup table descriptor are always to be interpreted as unsigned even if the VR is 'SS'.