[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vtkusers
Subject:    Re: [vtkusers] vtkPolyDataWriter: comma decimal mark instead of dot decimal mark
From:       Romain LEGUAY <romain.leguay () gmail ! com>
Date:       2017-08-28 15:10:26
Message-ID: C095A597-ABA1-4223-9821-5B7940CFEE66 () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Thank you David for your quick answer!

If I have some time I will do those fixes and send a patch.

Romain

> Le 28 août 2017 à 17:03, David Gobbi <david.gobbi@gmail.com> a écrit :
> 
> Hi Romain,
> 
> I suspect that VTK could be fixed if someone simply added a call to \
> "imbue(std::locale::classic())" to vtkDataWriter::OpenVTKFile(), e.g.: 
> fptr = new std::ostringstream;
> fptr->imbue(std::locale::classic());
> 
> and
> 
> fptr = new ofstream(this->FileName, ios::out);
> fptr->imbue(std::locale::classic());
> 
> If you have built VTK from source, you can try making the above change to see if it \
> fixes the issue (the vtkDataSetReader might also need to be fixed, as well as many \
> other IO classes). 
> - David
> 
> 
> On Mon, Aug 28, 2017 at 8:33 AM, Romain LEGUAY <romain.leguay@gmail.com \
> <mailto:romain.leguay@gmail.com>> wrote: Hi everyone,
> 
> I have a little issue when I try to write then read a polydata.
> 
> This is the code I use to write  then read my polydata inside a string (not a \
> file): 
> // Writing part
> vtkSmartPointer<vtkPolyDataWriter> writer = \
> vtkSmartPointer<vtkPolyDataWriter>::New(); writer->WriteToOutputStringOn();
> writer->SetInputData(myPolyData);
> writer->Update();
> 
> char * data = writer->GetOutputString();
> 
> 
> // Reading part
> vtkSmartPointer<vtkPolyDataReader> polyReader = \
> vtkSmartPointer<vtkPolyDataReader>::New(); polyReader->ReadFromInputStringOn();
> polyReader->SetInputString(data);
> polyReader->Update();
> vtkSmartPointer<vtkPolyData> polyData = polyReader->GetOutput();
> 
> 
> Unfortunately, when I try to read the data, I have some error indicating some \
> Unrecognized symbols: the decimal mark is a comma instead of a dot. 
> Can we change easily this comportement or force VTK to write with dot decimal mark?
> 
> I know the command std::setlocale but I would like to know if there is another way \
> to fix this problem. 
> Thank you!
> 
> Romain


[Attachment #5 (unknown)]

<html><head><meta http-equiv="Content-Type" content="text/html \
charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space;" class="">Thank you David for your quick \
answer!<div class=""><br class=""></div><div class="">If I have some time I will do \
those fixes and send a patch.</div><div class=""><br class=""></div><div \
class="">Romain</div><div class=""><br class=""><div><blockquote type="cite" \
class=""><div class="">Le 28 août 2017 à 17:03, David Gobbi &lt;<a \
href="mailto:david.gobbi@gmail.com" class="">david.gobbi@gmail.com</a>&gt; a écrit \
:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" \
class=""><div class="">Hi Romain,</div><div class=""><br class=""></div>I suspect \
that VTK could be fixed if someone simply added a call to \
"imbue(std::locale::classic())" to vtkDataWriter::OpenVTKFile(), e.g.:<div \
class=""><br class=""></div><div class="">&nbsp; &nbsp; fptr = new \
std::ostringstream;<br class=""><div class="">&nbsp; &nbsp; \
fptr-&gt;imbue(std::locale::classic());</div><div class=""><br class=""></div><div \
class="">and</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; fptr = \
new ofstream(this-&gt;FileName, ios::out);<br class=""></div><div class="">&nbsp; \
&nbsp; fptr-&gt;imbue(std::locale::classic());</div><div class=""><br \
class=""></div><div class="">If you have built VTK from source, you can try making \
the above change to see if it fixes the issue (the vtkDataSetReader might also need \
to be fixed, as well as many other IO classes).</div><div class=""><br \
class=""></div><div class="">&nbsp;- David<div class=""><div class=""><br \
class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Aug \
28, 2017 at 8:33 AM, Romain LEGUAY <span dir="ltr" class="">&lt;<a \
href="mailto:romain.leguay@gmail.com" target="_blank" \
class="">romain.leguay@gmail.com</a>&gt;</span> wrote:<br class=""><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">Hi everyone,<br class=""> <br class="">
I have a little issue when I try to write then read a polydata.<br class="">
<br class="">
This is the code I use to write&nbsp; then read my polydata inside a string (not a \
file):<br class=""> <br class="">
// Writing part<br class="">
vtkSmartPointer&lt;<wbr class="">vtkPolyDataWriter&gt; writer = \
vtkSmartPointer&lt;<wbr class="">vtkPolyDataWriter&gt;::New();<br class=""> \
writer-&gt;WriteToOutputStringOn(<wbr class="">);<br class=""> \
writer-&gt;SetInputData(<wbr class="">myPolyData);<br class=""> \
writer-&gt;Update();<br class=""> <br class="">
char * data = writer-&gt;GetOutputString();<br class="">
<br class="">
<br class="">
// Reading part<br class="">
vtkSmartPointer&lt;<wbr class="">vtkPolyDataReader&gt; polyReader = \
vtkSmartPointer&lt;<wbr class="">vtkPolyDataReader&gt;::New();<br class=""> \
polyReader-&gt;<wbr class="">ReadFromInputStringOn();<br class=""> \
polyReader-&gt;SetInputString(<wbr class="">data);<br class=""> \
polyReader-&gt;Update();<br class=""> vtkSmartPointer&lt;vtkPolyData&gt; polyData = \
polyReader-&gt;GetOutput();<br class=""> <br class="">
<br class="">
Unfortunately, when I try to read the data, I have some error indicating some \
Unrecognized symbols: the decimal mark is a comma instead of a dot.<br class=""> <br \
class=""> Can we change easily this comportement or force VTK to write with dot \
decimal mark?<br class=""> <br class="">
I know the command std::setlocale but I would like to know if there is another way to \
fix this problem.<br class=""> <br class="">
Thank you!<br class="">
<br class="">
Romain<br class=""></blockquote></div></div></div></div></div></div></div>
</div></blockquote></div><br class=""></div></body></html>



_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic