Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Modules/IO/GDCM/src/itkGDCMImageIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,11 @@ GDCMImageIO::Write(const void * buffer)
if (hasIPP)
{
double origin3D[3];
// save and reset old locale
std::locale currentLocale = std::locale::global(std::locale::classic());
sscanf(tempString.c_str(), "%lf\\%lf\\%lf", &(origin3D[0]), &(origin3D[1]), &(origin3D[2]));
// reset locale
std::locale::global(currentLocale);
image.SetOrigin(0, origin3D[0]);
image.SetOrigin(1, origin3D[1]);
image.SetOrigin(2, origin3D[2]);
Expand Down Expand Up @@ -1053,6 +1057,8 @@ GDCMImageIO::Write(const void * buffer)
if (hasIOP)
{
double directions[6];
// save and reset old locale
std::locale currentLocale = std::locale::global(std::locale::classic());
sscanf(tempString.c_str(),
"%lf\\%lf\\%lf\\%lf\\%lf\\%lf",
&(directions[0]),
Expand All @@ -1061,6 +1067,8 @@ GDCMImageIO::Write(const void * buffer)
&(directions[3]),
&(directions[4]),
&(directions[5]));
// reset locale
std::locale::global(currentLocale);
image.SetDirectionCosines(0, directions[0]);
image.SetDirectionCosines(1, directions[1]);
image.SetDirectionCosines(2, directions[2]);
Expand Down
16 changes: 16 additions & 0 deletions Modules/IO/Stimulate/src/itkStimulateImageIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,11 @@ StimulateImageIO::InternalReadImageInformation(std::ifstream & file)
// the origin is not specified, but the fov is, then the image is assumed
// to be centered:

// save and reset old locale
std::locale currentLocale = std::locale::global(std::locale::classic());
sscanf(line, "%*s %f %f %f %f", origin, origin + 1, origin + 2, origin + 3);
// reset locale
std::locale::global(currentLocale);
for (unsigned int i = 0; i < m_NumberOfDimensions; i++)
{
m_Origin[i] = origin[i];
Expand All @@ -277,7 +281,11 @@ StimulateImageIO::InternalReadImageInformation(std::ifstream & file)
// not
// specified it is calculated according to: fov = interval * dim

// save and reset old locale
std::locale currentLocale = std::locale::global(std::locale::classic());
sscanf(line, "%*s %f %f %f %f", fov, fov + 1, fov + 2, fov + 3);
// reset locale
std::locale::global(currentLocale);
fov_specified = true;
}
else if (text.find("interval") < text.length())
Expand All @@ -288,7 +296,11 @@ StimulateImageIO::InternalReadImageInformation(std::ifstream & file)
// one value for each dimension. If the interval is not specified it is
// calculated according to: interval = fov / dim

// save and reset old locale
std::locale currentLocale = std::locale::global(std::locale::classic());
sscanf(line, "%*s %f %f %f %f", spacing, spacing + 1, spacing + 2, spacing + 3);
// reset locale
std::locale::global(currentLocale);
for (unsigned int i = 0; i < m_NumberOfDimensions; i++)
{
m_Spacing[i] = spacing[i];
Expand Down Expand Up @@ -337,7 +349,11 @@ StimulateImageIO::InternalReadImageInformation(std::ifstream & file)
// the
// low_value and high_value.

// save and reset old locale
std::locale currentLocale = std::locale::global(std::locale::classic());
sscanf(line, "%*s %f %f", range, range + 1);
// reset locale
std::locale::global(currentLocale);
m_DisplayRange[0] = range[0];
m_DisplayRange[1] = range[1];
}
Expand Down
8 changes: 8 additions & 0 deletions Modules/IO/VTK/src/itkVTKImageIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ VTKImageIO::InternalReadImageInformation(std::ifstream & file)
if (text.find("spacing") < text.length() || text.find("aspect_ratio") < text.length())
{
double spacing[3];
// save and reset old locale
std::locale currentLocale = std::locale::global(std::locale::classic());
sscanf(text.c_str(), "%*s %lf %lf %lf", spacing, spacing + 1, spacing + 2);
// reset locale
std::locale::global(currentLocale);
for (unsigned int i = 0; i < m_NumberOfDimensions; i++)
{
this->SetSpacing(i, spacing[i]);
Expand All @@ -247,7 +251,11 @@ VTKImageIO::InternalReadImageInformation(std::ifstream & file)
else if (text.find("origin") < text.length())
{
double origin[3];
// save and reset old locale
std::locale currentLocale = std::locale::global(std::locale::classic());
sscanf(text.c_str(), "%*s %lf %lf %lf", origin, origin + 1, origin + 2);
// reset locale
std::locale::global(currentLocale);
for (unsigned int i = 0; i < m_NumberOfDimensions; i++)
{
this->SetOrigin(i, origin[i]);
Expand Down