+ // We then consider the "Planes" entry as the third dimension
+ strSize = GetEntryByNumber(0x0028,0x0012);
+ if ( strSize != GDCM_UNFOUND )
+ {
+ return atoi( strSize.c_str() );
+ }
+
+ return 1;
+}
+
+/**
+ * \brief gets the info from 0028,0030 : Pixel Spacing
+ * else 1.0
+ * @return X dimension of a pixel
+ */
+float gdcmHeader::GetXSpacing()
+{
+ float xspacing, yspacing;
+ std::string strSpacing = GetEntryByNumber(0x0028,0x0030);
+
+ if ( strSpacing == GDCM_UNFOUND )
+ {
+ dbg.Verbose(0, "gdcmHeader::GetXSpacing: unfound Pixel Spacing (0028,0030)");
+ return 1.;
+ }
+
+ int nbValues;
+ if( ( nbValues = sscanf( strSpacing.c_str(),
+ "%f\\%f", &yspacing, &xspacing)) != 2 )
+ {
+ // if single value is found, xspacing is defaulted to yspacing
+ if ( nbValues == 1 )
+ {
+ return yspacing;
+ }
+ }
+ if ( xspacing == 0.)
+ {
+ dbg.Verbose(0, "gdcmHeader::GetYSpacing: gdcmData/CT-MONO2-8-abdo.dcm problem");
+ // seems to be a bug in the header ...
+ sscanf( strSpacing.c_str(), "%f\\0\\%f", &yspacing, &xspacing);
+ }
+
+ return xspacing;
+}
+
+/**
+ * \brief gets the info from 0028,0030 : Pixel Spacing
+ * else 1.0
+ * @return Y dimension of a pixel
+ */
+float gdcmHeader::GetYSpacing()
+{
+ float yspacing = 0;
+ std::string strSpacing = GetEntryByNumber(0x0028,0x0030);
+
+ if ( strSpacing == GDCM_UNFOUND )
+ {
+ dbg.Verbose(0, "gdcmHeader::GetYSpacing: unfound Pixel Spacing (0028,0030)");
+ return 1.;
+ }
+
+ // if sscanf cannot read any float value, it won't affect yspacing
+ sscanf( strSpacing.c_str(), "%f", &yspacing);
+
+ return yspacing;
+}
+
+/**
+ * \brief gets the info from 0018,0088 : Space Between Slices
+ * else from 0018,0050 : Slice Thickness
+ * else 1.0
+ * @return Z dimension of a voxel-to be
+ */
+float gdcmHeader::GetZSpacing()
+{
+ // Spacing Between Slices : distance entre le milieu de chaque coupe
+ // Les coupes peuvent etre :
+ // jointives (Spacing between Slices = Slice Thickness)
+ // chevauchantes (Spacing between Slices < Slice Thickness)
+ // disjointes (Spacing between Slices > Slice Thickness)
+ // Slice Thickness : epaisseur de tissus sur laquelle est acquis le signal
+ // ca interesse le physicien de l'IRM, pas le visualisateur de volumes ...
+ // Si le Spacing Between Slices est absent,
+ // on suppose que les coupes sont jointives
+
+ std::string strSpacingBSlices = GetEntryByNumber(0x0018,0x0088);
+
+ if ( strSpacingBSlices == GDCM_UNFOUND )
+ {
+ dbg.Verbose(0, "gdcmHeader::GetZSpacing: unfound StrSpacingBSlices");
+ std::string strSliceThickness = GetEntryByNumber(0x0018,0x0050);
+ if ( strSliceThickness == GDCM_UNFOUND )
+ {
+ return 1.;
+ }
+ else
+ {
+ // if no 'Spacing Between Slices' is found,
+ // we assume slices join together
+ // (no overlapping, no interslice gap)
+ // if they don't, we're fucked up
+ return atof( strSliceThickness.c_str() );
+ }
+ }
+ else
+ {
+ return atof( strSpacingBSlices.c_str() );
+ }