[Insight-developers] gdcm warning may have uncovered error

Mathieu Malaterre mathieu.malaterre at gmail.com
Thu Dec 9 05:22:55 EST 2010


Hi,

Here is the long answer:
  TVR=512 means (if we look up in gdcmVR.h) that we are currently
using VR::IS for storing the value.
  Indeed (to answer Bill's worries) we are actually storing a floating
point value (the GDCM API for defining a spacing) into something that
only accept Integer. This happen for the UltraSound family of
instances, where one can only define a PixelAspectRatio since there is
no such thing as spacing in the US world. There is mechanism in GDCM
so that a spacing of 0.5 is actually converted to a PixelAspectRatio
of "1\\2", which respect the ratio (this is the best we can do).

Short answer:
  Mark, please go ahead and explicitly cast to int.

Thanks,

On Wed, Dec 8, 2010 at 5:23 PM, Mark Roden <mmroden at gmail.com> wrote:
> Hi Bill,
>
> That warning shows up on windows as:
>
> 1>..\..\..\..\..\ITK\Utilities\gdcm\Source\MediaStorageAndFileFormat\gdcmImageHelper.cxx(1122)
> : warning C4244: 'argument' : conversion from 'const double' to
> 'gdcm::VRToType<512>::Type', possible loss of data
>
> using the 2008 win64 compiler.  This was one of those warnings that
> took me aback, and decided not to touch for the time being.  I'm not
> sure what VRToType<512> does; as in, is that a 512 byte character
> array?  A uint short that is capped to 512?  If the latter is the
> case, then it's possible that code for extent got swapped in for code
> for value, but then having an extent that's just 512 is a bit
> limiting.
>
> So I'm leaving it for Mathieu, since I really don't know what's up there.
>
> Mark
>
>
> On Wed, Dec 8, 2010 at 7:05 AM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>> Mathieu and Mark,
>>
>> My gcc 3.4.5 compiler gives this warning:
>> c:/lorensen/ProjectsGIT/ITKGerrit/Utilities/gdcm/Source/MediaStorageAndFileFormat/gdcmImageHelper.cxx:
>> In static member function `static void
>> gdcm::ImageHelper::SetSpacingValue(gdcm::DataSet&, const
>> std::vector<double, std::allocator<double> >&)':
>> c:/lorensen/ProjectsGIT/ITKGerrit/Utilities/gdcm/Source/MediaStorageAndFileFormat/gdcmImageHelper.cxx:1122:
>> warning: passing `const double' for converting 1 of `void
>> gdcm::Element<TVR, 218367>::SetValue(typename gdcm::VRToType<T>::Type,
>> unsigned int) [with int TVR = 512]'
>>
>> The code in question is here:
>>          for( unsigned int i = 0; i < entry.GetVM().GetLength(); ++i)
>>            {
>>            el.SetValue( spacing[i], i );
>>            }
>>
>> It seems that the value is being converted to unsigned int which, to
>> me, does not seem appropriate for spacing.
>>
>> Is this a possible error?
>>
>> Bill
>>
>



-- 
Mathieu


More information about the Insight-developers mailing list