[vtkusers] [Insight-developers] wx/vtk weirdness

Bill Lorensen bill.lorensen at gmail.com
Sat Nov 28 13:58:28 EST 2009


Sorry, i17n -> i18n.

Ugly American ( http://en.wikipedia.org/wiki/Ugly_American ),

Bill

On Sat, Nov 28, 2009 at 1:19 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> Luis,
>
> Actually, we can surround certain functions with c-style setlocale and
> it solves the problems. I already fixed StimulateImageIO,
> PolygonGroupSpatialObjectXMLFile and VTKImageIO. I have not checked in
> any changes yet. Still more investigation is needed as to the best
> portable solution.
>
> I do this:
>  const char *originalLocale;
>  char *currentLocale;
>  originalLocale = setlocale(LC_NUMERIC, NULL);
>  currentLocale = strdup(originalLocale ? originalLocale : "C");
>  setlocale(LC_NUMERIC, "C");
>
> ......
>
>
> setlocale(LC_NUMERIC, currentLocale);
>        free(currentLocale);
>
> For example in StimulateImageIO I surrounded the calls in
> StimulateImageIO::InternalReadImageInformation with the above
> snippets.
>
> There are other readers/writers that use C++ streams, and there we
> will have to imbue.
>
> Even in some code that uses streams, people still use sscanf, atof,
> etc. In the long run we probably should address these cases with
> stream replacements.
>
> This also brings up the larger i17n issue. We need to have a plan of
> attack for itk.
>
> Bill
>
> On Sat, Nov 28, 2009 at 12:31 PM, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>> Bill,
>>
>> Catching up with this discussion....
>>
>> What I gather from the email-thread is that we should
>> replace uses of sscanf with the use of C++ streams
>> and to use the imbue method for setting the locale.
>>
>> Is that right ?
>>
>>
>>      Luis
>>
>>
>> ----------------------------------------------------------------------------------
>> On Sat, Nov 28, 2009 at 11:36 AM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>>> I just verified several itk reader problems. I modified the itkIOTests
>>> test driver so that it set the locale to fr_FR (in honor of Mathieu).
>>> Sure enough several tests fail.
>>>
>>> I am going to start a discussion to the itk developers' mail list.
>>>
>>> Bill
>>>
>>> On Fri, Nov 27, 2009 at 11:53 AM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>>>> I see that itk has similar issues, but only for 2 of its readers. So
>>>> what is the proper way to read floats? With streams?
>>>>
>>>> Bill
>>>>
>>>> On Fri, Nov 27, 2009 at 11:50 AM, Mathieu Malaterre
>>>> <mathieu.malaterre at gmail.com> wrote:
>>>>> Yes.
>>>>>
>>>>> On Fri, Nov 27, 2009 at 5:49 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>>>>>> Mathieu,
>>>>>>
>>>>>> There are many vtk readers that use sscanf to read floating point
>>>>>> numbers. Does that mean that these readers may also misinterpret
>>>>>> floating point if LC_NUMERIC is different.
>>>>>>
>>>>>> Bill
>>>>>>
>>>>>> On Fri, Nov 27, 2009 at 11:25 AM, Mathieu Malaterre
>>>>>> <mathieu.malaterre at gmail.com> wrote:
>>>>>>> On Fri, Nov 27, 2009 at 5:17 PM, "Eduardo M. Suárez Santana"
>>>>>>> <esuarez at itccanarias.org> wrote:
>>>>>>>> Mathieu Malaterre wrote:
>>>>>>>>> On Fri, Nov 27, 2009 at 4:47 PM, "Eduardo M. Suárez Santana"
>>>>>>>>> <esuarez at itccanarias.org> wrote:
>>>>>>>>>
>>>>>>>>>> This looks weird to me. Spacing of vtkDICOMImageReader depends on
>>>>>>>>>> whether I use wx or not.
>>>>>>>>>>
>>>>>>>>>> Can anyone reproduce?
>>>>>>>>>>
>>>>>>>>>> It fails in vtk-5.2.1 and vtk-5.4.2 on linux, python-2.6.2 and wxpython-2.8.10.1
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> DICOMParser is using internally sscanf to decode the spacing. It will
>>>>>>>>> fails to work when LC_NUMERIC is not compatible with "C" style. I
>>>>>>>>> believe by default GTK (underlying implementation of wx on linux) sets
>>>>>>>>> the LC_NUMERIC corresponding to your locales.
>>>>>>>>>
>>>>>>>>> HTH
>>>>>>>>>
>>>>>>>> Rethinking.
>>>>>>>>
>>>>>>>> Is not a bug if the correct behaviour depends on setting an unrelated
>>>>>>>> variable (DICOM - LC_NUMERIC)?
>>>>>>>>
>>>>>>>
>>>>>>> I /personally/ believe it is. This is up to the DICOM implementor to
>>>>>>> make sure the reading/writing of floating point value works as per
>>>>>>> DICOM specs (ie. use '.' and not ',').
>>>>>>> Maybe log a bug for that.
>>>>>>>
>>>>>>> 2cts
>>>>>>> --
>>>>>>> Mathieu
>>>>>>> _______________________________________________
>>>>>>> Powered by www.kitware.com
>>>>>>>
>>>>>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>>>>>>
>>>>>>> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>>>>>>
>>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Mathieu
>>>>>
>>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://kitware.com/products/protraining.html
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-developers
>>>
>>
>



More information about the vtkusers mailing list