[vtkusers] Localization problem with reading and writing of human readable file formats, obj, ply, ...

Peter Eipert eipert at web.de
Mon Feb 13 06:16:43 EST 2012


Hello

I have got the same problem using vtk with Java wrappings under a german 
Linux.

Peter

Am 13.02.2012 10:30, schrieb Hanno Hugenberg:
> Hi everyone,
>
> we detected a minor problem today with the fileimport of obj (and 
> probably all other human readable file formats).
>
> Loading an obj file on a different localized system results in a 
> failure. valid files wont get loaded on our systems.
>
> The reason is:
>
> the obj loader wants to read floating point values like this:
>
> vtkOBJReader.cxx, line 183:
>
>  if (strcmp(cmd, "v") == 0)
>       {
>       // this is a vertex definition, expect three floats, separated 
> by whitespace:
>       if (sscanf(pLine, "%f %f %f", xyz, xyz+1, xyz+2) == 3)
>         {
>         points->InsertNextPoint(xyz);
>         }
>       else
>         {
>           vtkErrorMacro(<<"Error reading 'v' at line " << lineNr );
>         everything_ok = false;
>         }
>       }
>
> Since the localisation was changed due to the application needs, the 
> functions used by vtk who are influenced by this now create "wrong" 
> results.
>
> a german localized "sscanf" expects as float a string with comma 
> seperation like:
>  "7,123"
>
>  BUT: the obj standard defines the use of point seperation like:
> "7.123"
>
> This problem is similar to a very old topic in the mailinglist archive:
> http://public.kitware.com/pipermail/insight-users/2006-July/018783.html
>
> The suggestion was to use the
>
> setlocale (LC_NUMERIC,"C");
>
> command from the standard c library to switch back to the general 
> "7.123" reading behaviour.
> But this may corrupt other parts in a program which rely on the local 
> settings already done.
>
> So the only option is to push/pop the local setting everytime there is 
> a need to call one of the load/save/etc functions/classes which uses 
> the standard c functions.
>
>
> Is there not a way to change the loader functions to be fully file 
> format compatible no matter which languages is set in an application 
> via setLocal?
>
> Any ideas regarding this?
> I think we are not the only people having this problem
>
> Best regards & thx for an awesome library.
>
> Hanno
> _______________________________________________
> 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
>




More information about the vtkusers mailing list