[vtk-developers] Call for Comments: Ascii representation of floats and doubles in files

Andras Lasso lasso at queensu.ca
Wed Mar 28 23:36:50 EDT 2018


ITK already uses DoubleConversion library. Could VTK include it the same way?

Andras

-----Original Message-----
From: vtk-developers <vtk-developers-bounces at vtk.org> On Behalf Of Bill Lorensen
Sent: Wednesday, March 28, 2018 8:55 PM
To: Utkarsh Ayachit <utkarsh.ayachit at kitware.com>
Cc: VTK Developers <vtk-developers at vtk.org>; Will Schroeder <will.schroeder at kitware.com>; David Gobbi <david.gobbi at gmail.com>
Subject: Re: [vtk-developers] Call for Comments: Ascii representation of floats and doubles in files

I'm having problems on a Windows platform. I'll be asking for help.

The ThirdParty stuff is tricky since not all ThirdParty packages follow the recommended way.

Bill

On Wed, Mar 28, 2018 at 5:19 PM, Utkarsh Ayachit <utkarsh.ayachit at kitware.com> wrote:
> Funny coincidence, I just got bit but this double-string precision 
> problem in a ParaView issue [1]. Looks forward to having this library 
> in VTK so we can use it. Bill, if you need help with the 3rd party 
> stuff, just holler.
>
> Utkarsh
>
>
> [1] 
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitla
> b.kitware.com%2Fparaview%2Fparaview%2Fissues%2F18083&data=02%7C01%7Cla
> sso%40queensu.ca%7Cab25aee0e0ae47e090b608d5950fa5ec%7Cd61ecb3b38b142d5
> 82c4efb2838b925c%7C1%7C0%7C636578816799629721&sdata=%2F1yBI%2B25wC1xr7
> Z2agKh1IslyksB6y1k0GUKpfp8PtQ%3D&reserved=0
>
> On Wed, Mar 21, 2018 at 8:10 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>> I'm still working in the MR. It works great but I'm having cmake 
>> issues on Windows. Adding a new third party library is tricky.
>>
>> On Mar 21, 2018 2:08 PM, "Isaiah Norton" <isaiah.norton at gmail.com> wrote:
>>>
>>> +1. I needed this recently in Slicer, and ended up using ITK's 
>>> +version
>>> because we link it anyway.
>>>
>>>>
>>>> Not sure if we need to add a new third-party library for this, 
>>>> though, especially one that duplicates so much of C++'s built-in machinery.
>>>
>>>
>>>  Grisu3 (double-conversion) appears to be ~13x faster than the C++ 
>>> stream functions (and 6x faster than sprintf):
>>>
>>>   
>>> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
>>> hub.com%2Fmiloyip%2Fdtoa-benchmark&data=02%7C01%7Classo%40queensu.ca
>>> %7Cab25aee0e0ae47e090b608d5950fa5ec%7Cd61ecb3b38b142d582c4efb2838b92
>>> 5c%7C1%7C0%7C636578816799629721&sdata=XjioME1t%2F1TwLSUObFB5GGG9d%2B
>>> S8f4%2ByVls1%2B5oB1q4%3D&reserved=0
>>>
>>> Those numbers are on VS2013/Windows, but that code is easy to build 
>>> locally. The sprintf vs double-conversion conclusion holds on 2015 
>>> macbook with 10.12 SDK. The C++ stream functionality is somewhat closer to sprintf.
>>>
>>> [usual benchmark NaCl disclaimer here]
>>>
>>> On Thu, Mar 1, 2018 at 11:32 AM, David Gobbi <david.gobbi at gmail.com>
>>> wrote:
>>>>
>>>> I agree that floats should be printed so that conversion is lossless.
>>>> Python's console output does this and I find it incredibly useful.
>>>>
>>>> Not sure if we need to add a new third-party library for this, 
>>>> though, especially one that duplicates so much of C++'s built-in machinery.
>>>> Isn't it just a matter of printing enough digits?  That's basically 
>>>> what I do in my own code (plus checks for isnan(x) and isinf(x), 
>>>> and a check of the size of fabs(x) for whether to force scientific 
>>>> notation.)
>>>>
>>>>  - David
>>>>
>>>>
>>>> On Thu, Mar 1, 2018 at 8:48 AM, Bill Lorensen 
>>>> <bill.lorensen at gmail.com>
>>>> wrote:
>>>>>
>>>>> Will,
>>>>>
>>>>> It would go in Common/Core I think. The vtk class would be very small.
>>>>>
>>>>> Bill
>>>>>
>>>>> On Thu, Mar 1, 2018 at 7:36 AM, Will Schroeder 
>>>>> <will.schroeder at kitware.com> wrote:
>>>>> > If it works why mess with success? Where would this class
>>>>> > (vtkNumberToString) be placed, in Common/Core (like vtkIndent) 
>>>>> > or in some IO directory like VTK/IO/Core?
>>>>> >
>>>>> > On Thu, Mar 1, 2018 at 10:06 AM, Bill Lorensen 
>>>>> > <bill.lorensen at gmail.com>
>>>>> > wrote:
>>>>> >>
>>>>> >> Folks,
>>>>> >>
>>>>> >> I'm working on some examples to save/restore camera, polydata, 
>>>>> >> property, etc. in XML files. The files can be saved as binary 
>>>>> >> or ascii. If I save/restore the info in binary, I get the same 
>>>>> >> values for the saved info. But, to no surprise, when I save the 
>>>>> >> same data in ascii, I don't get the same values. This is 
>>>>> >> because the file writing code does not write enough significant 
>>>>> >> digits.
>>>>> >>
>>>>> >> In ITK we solved this problem many years ago. ITK uses a 
>>>>> >> reduced version of the Google double-conversion library, 
>>>>> >> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgoogle%2Fdouble-conversion&data=02%7C01%7Classo%40queensu.ca%7Cab25aee0e0ae47e090b608d5950fa5ec%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636578816799629721&sdata=Iaj1ntftOmg4TsPj7U3eaMXoYfiNmT0yqRlQxZvpMC8%3D&reserved=0.
>>>>> >>
>>>>> >> We added a small class to ITK that uses the library. The class, 
>>>>> >> itkNumberToString, has a simple API. To convert floating and 
>>>>> >> fixed point numbers to ascii without numerical precision erros,
>>>>> >>
>>>>> >> For example, to convert a float, #include "itkNumberToString.h:
>>>>> >> itk::NumberToString<float> convert; float a = 1.0f/3.0f; 
>>>>> >> std::cout << convert(a) << std::endl;
>>>>> >>
>>>>> >> I propose a similar approach in VTK.
>>>>> >>
>>>>> >> Comments please,
>>>>> >>
>>>>> >> Bill
>>>>
>>>>
>>>> _______________________________________________
>>>> Powered by 
>>>> https://na01.safelinks.protection.outlook.com/?url=www.kitware.com&
>>>> data=02%7C01%7Classo%40queensu.ca%7Cab25aee0e0ae47e090b608d5950fa5e
>>>> c%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636578816799629721&s
>>>> data=PSctDI%2BN60sIjEpXkZjufI%2BkcclVZKoI2T2bzBAoj9w%3D&reserved=0
>>>>
>>>> Visit other Kitware open-source projects at
>>>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww
>>>> .kitware.com%2Fopensource%2Fopensource.html&data=02%7C01%7Classo%40
>>>> queensu.ca%7Cab25aee0e0ae47e090b608d5950fa5ec%7Cd61ecb3b38b142d582c
>>>> 4efb2838b925c%7C1%7C0%7C636578816799639730&sdata=puooqmxO4eh7NCSUol
>>>> wTdGnnWJvFjnk8Xo%2FscXkXSnQ%3D&reserved=0
>>>>
>>>> Search the list archives at: 
>>>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmar
>>>> kmail.org%2Fsearch%2F%3Fq%3Dvtk-developers&data=02%7C01%7Classo%40q
>>>> ueensu.ca%7Cab25aee0e0ae47e090b608d5950fa5ec%7Cd61ecb3b38b142d582c4
>>>> efb2838b925c%7C1%7C0%7C636578816799639730&sdata=QQnylc0vj5YP7A%2BFI
>>>> f5kGUo6%2BBAXlpxGxyFsAb0WvAg%3D&reserved=0
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fvt
>>>> k.org%2Fmailman%2Flistinfo%2Fvtk-developers&data=02%7C01%7Classo%40
>>>> queensu.ca%7Cab25aee0e0ae47e090b608d5950fa5ec%7Cd61ecb3b38b142d582c
>>>> 4efb2838b925c%7C1%7C0%7C636578816799639730&sdata=FmBgc4o0HsL7Nqb5u0
>>>> nT8PNtbFF%2BUG9R9kpeMLYvb4I%3D&reserved=0
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> Powered by 
>> https://na01.safelinks.protection.outlook.com/?url=www.kitware.com&da
>> ta=02%7C01%7Classo%40queensu.ca%7Cab25aee0e0ae47e090b608d5950fa5ec%7C
>> d61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636578816799639730&sdata=s
>> 4hn6gw5SNnQrTmqnud8rld8Hh8KAGzfLH7qJYGPaRw%3D&reserved=0
>>
>> Visit other Kitware open-source projects at
>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.k
>> itware.com%2Fopensource%2Fopensource.html&data=02%7C01%7Classo%40quee
>> nsu.ca%7Cab25aee0e0ae47e090b608d5950fa5ec%7Cd61ecb3b38b142d582c4efb28
>> 38b925c%7C1%7C0%7C636578816799639730&sdata=puooqmxO4eh7NCSUolwTdGnnWJ
>> vFjnk8Xo%2FscXkXSnQ%3D&reserved=0
>>
>> Search the list archives at: 
>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmarkm
>> ail.org%2Fsearch%2F%3Fq%3Dvtk-developers&data=02%7C01%7Classo%40queen
>> su.ca%7Cab25aee0e0ae47e090b608d5950fa5ec%7Cd61ecb3b38b142d582c4efb283
>> 8b925c%7C1%7C0%7C636578816799639730&sdata=QQnylc0vj5YP7A%2BFIf5kGUo6%
>> 2BBAXlpxGxyFsAb0WvAg%3D&reserved=0
>>
>> Follow this link to subscribe/unsubscribe:
>> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fvtk.
>> org%2Fmailman%2Flistinfo%2Fvtk-developers&data=02%7C01%7Classo%40quee
>> nsu.ca%7Cab25aee0e0ae47e090b608d5950fa5ec%7Cd61ecb3b38b142d582c4efb28
>> 38b925c%7C1%7C0%7C636578816799639730&sdata=FmBgc4o0HsL7Nqb5u0nT8PNtbF
>> F%2BUG9R9kpeMLYvb4I%3D&reserved=0
>>
>>



--
Unpaid intern in BillsParadise at noware dot com _______________________________________________
Powered by https://na01.safelinks.protection.outlook.com/?url=www.kitware.com&data=02%7C01%7Classo%40queensu.ca%7Cab25aee0e0ae47e090b608d5950fa5ec%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636578816799639730&sdata=s4hn6gw5SNnQrTmqnud8rld8Hh8KAGzfLH7qJYGPaRw%3D&reserved=0

Visit other Kitware open-source projects at https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com%2Fopensource%2Fopensource.html&data=02%7C01%7Classo%40queensu.ca%7Cab25aee0e0ae47e090b608d5950fa5ec%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636578816799639730&sdata=puooqmxO4eh7NCSUolwTdGnnWJvFjnk8Xo%2FscXkXSnQ%3D&reserved=0

Search the list archives at: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmarkmail.org%2Fsearch%2F%3Fq%3Dvtk-developers&data=02%7C01%7Classo%40queensu.ca%7Cab25aee0e0ae47e090b608d5950fa5ec%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636578816799639730&sdata=QQnylc0vj5YP7A%2BFIf5kGUo6%2BBAXlpxGxyFsAb0WvAg%3D&reserved=0

Follow this link to subscribe/unsubscribe:
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fvtk.org%2Fmailman%2Flistinfo%2Fvtk-developers&data=02%7C01%7Classo%40queensu.ca%7Cab25aee0e0ae47e090b608d5950fa5ec%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636578816799639730&sdata=FmBgc4o0HsL7Nqb5u0nT8PNtbFF%2BUG9R9kpeMLYvb4I%3D&reserved=0



More information about the vtk-developers mailing list